Distributed Hash Table File System for Linux








openssl_sha1.c File Reference

#include "magma.h"

Defines

#define ARMOUR_HASH   1
#define print_key(key)
#define print_key(key)

Functions

unsigned char * sha1_data (const void *data, unsigned int length)
unsigned char * sha1_fd (int fd)
char * armour_hash (const unsigned char *hash)
int decrement_key_p (char *key, char *p)
int increment_key_p (char *key, char *p)
int move_key (char *actual, const char *destination)
int get_char_val (char c)
char get_int_val (int i)
void riporto (char *result, int c)
char * key_difference_by_char (char *max, char *min)
long int real_key_difference (char *max, char *min)
long int key_difference (char *k1, char *k2)
magma_sha1_tsha1_aton (char *key)
char * subtract_key (char *k1, char *k2)

Define Documentation

#define ARMOUR_HASH   1

#define print_key ( key   ) 

print a key to standard err

#define print_key ( key   ) 

Value:

fprintf(stderr, "E: %.8lx\n", (unsigned long int) key->e);\
        fprintf(stderr, "D: %.8lx\n", (unsigned long int) key->d);\
        fprintf(stderr, "C: %.8lx\n", (unsigned long int) key->c);\
        fprintf(stderr, "B: %.8lx\n", (unsigned long int) key->b);\
        fprintf(stderr, "A: %.8lx\n", (unsigned long int) key->a);
print a key to standard err


Function Documentation

char* armour_hash ( const unsigned char *  hash  ) 

provides printable (armoured) hash bucked

Parameters:
hash the binary hash value to be armoured
Returns:
pointer to armoured hash

int decrement_key_p ( char *  key,
char *  p 
)

decrement key value by one. returns 1 if key has been decremented, 0 otherwise (tipically if key is already all zero). Should never be called directly: always use macro decrement_key(key)!

Parameters:
key buffer holding armoured key
p used internally for recursive operations
Returns:
1 on success, 0 otherwise

int get_char_val ( char  c  ) 

transform hexadecimal character into its integer value

Parameters:
c given hexadecimal character
Returns:
numeric integer value of c

char get_int_val ( int  i  ) 

transform an integer value to hexadecimal rappresentation

Parameters:
i integer given value
Returns:
ASCII rappresentation

int increment_key_p ( char *  key,
char *  p 
)

increment key value by one. returns 1 if key has been incremented, 0 otherwise (tipically if key is already all 0xf). Should never be called directly: always use macro increment_key(key)!

Parameters:
key buffer holding armoured key
p used internally for recursive operations
Returns:
1 on success, 0 otherwise

long int key_difference ( char *  k1,
char *  k2 
)

return difference between two keys.

Parameters:
k1 pointer to first key
k2 pointer to second key
Returns:
integer difference between the keys

char * key_difference_by_char ( char *  max,
char *  min 
)

calculate difference between two keys

Parameters:
max first key, supposed to be the greater
min second key, supposed to be the smallest
Returns:
pointer to a key which is the difference. memory is dynamically allocated and should be freed by outside code.
Todo:
unused code to be removed?

int move_key ( char *  actual,
const char *  destination 
)

change a key to move near destination key

Todo:
unused code!!

long int real_key_difference ( char *  max,
char *  min 
)

return key difference between two keys. max is supposed to be greater than min. never use this function directly. use key_difference().

Parameters:
max pointer to first key, supposed to be the greater
min pointer to second key, supposed to be the smaller
Returns:
integer difference of the keys

void riporto ( char *  result,
int  c 
)

internally used by key_difference_by_char()

magma_sha1_t* sha1_aton ( char *  key  ) 

transform ASCII key rappresentation to numeric rappresentation

Parameters:
key pointer to given key
Returns:
numeric rappresentation of key, NULL if something went wrong

unsigned char* sha1_data ( const void *  data,
unsigned int  length 
)

return hash bucket of buffered data

Parameters:
data memory location of given data
length size of memory buffer *data
Returns:
binary hashing of given data

unsigned char* sha1_fd ( int  fd  ) 

return hash bucked of an open filedescriptor

Parameters:
fd file descriptor open on data file
Returns:
binary hashing of given data

char* subtract_key ( char *  k1,
char *  k2 
)

make the difference of two keys

Parameters:
k1 pointer to first key
k2 pointer to second key
Returns:
pointer to difference key, NULL if something went wrong

This file last modified Wednesday, 09-Jan-2008 20:02:35 CET