group
group__libshare__memkey
Utility functions to generate unique checksums of data.

ShareKey Hash Digest

typedef
typedef struct shkey_t shkey_t
typedef
typedef uint32_t sh160_t[5]
A 160-bit key.
variable
shkey_t _shkey_blank
function
shkey_t* shkey_bin
(char *data, size_t data_len)
Generates a unique 192-bit key from a segment of data.
Note
Algorythm is a combination of adler32 and sha256.
function
shkey_t* ashkey_bin
(char *data, size_t data_len)
function
shkey_t* shkey_str
(char *kvalue)
Create a hashmap key reference from The string to generate into a .
shkey_t structshkey__t compound kvalue shkey_t structshkey__t compound
kvalue
Return Value
A referencing a kvalue
shkey_t structshkey__t compound
function
shkey_t* shkey_num
(long kvalue)
Create a hashmap key reference from a 32bit number.
shkey_t structshkey__t compound
The number to generate into a kvalue
shkey_t structshkey__t compound
Return Value
A statically allocated version of
function
shkey_t* shkey_num64
(uint64_t kvalue)
Create a hashmap key reference from a 64bit number.
shkey_t structshkey__t compound
The number to generate into a kvalue
shkey_t structshkey__t compound
Return Value
A statically allocated version of
function
shkey_t* shkey_uniq
(void)
Create a unique hashmap key reference.
shkey_t structshkey__t compound
Return Value
A containing a unique key value.
shkey_t structshkey__t compound
function
shkey_t* ashkey_uniq
(void)
function
uint64_t shkey_crc
(shkey_t *key)
A 64-bit numeric representation of a . shkey_t structshkey__t compound
function
void shkey_free
(shkey_t **key_p)
function
uint64_t shrand
(void)
function
shkey_t* shkey_xor
(shkey_t *key1, shkey_t *key2)
function
shkey_t* ashkey_xor
(shkey_t *key1, shkey_t *key2)
function
shkey_t* shkey_dup
(shkey_t *key)
function
const char* shkey_print
(shkey_t *key)
A ascii string representation of a libshare key.
Note
The string returned will be 36 characters long in a format similar to base64.
function
shkey_t* ashkey_str
(char *name)
Generates a from a string that does not need to be freed. shkey_t structshkey__t compound
See
shkey_free()
Bug psuedo thread-safe bug_1_bug000001
function
shkey_t* ashkey_num
(long num)
Generates a from a number that does not need to be freed. shkey_t structshkey__t compound
See
shkey_free()
Bug psuedo thread-safe bug_1_bug000002
function
int shkey_cmp
(shkey_t *key_1, shkey_t *key_2)
Compare two shkek_t key tokens.
Return Value
TRUE is keys are ientical and FALSE if not.
function
shkey_t* shkey_clone
(shkey_t *key)
function
shkey_t* shkey_cert
(shkey_t *key, uint64_t crc, shtime_t stamp)
Creates a certificate's signature key based off content attributes.
function
int shkey_verify
(shkey_t *sig, uint64_t crc, shkey_t *key, shtime_t stamp)
Verifies whether content attributes match a generated certificate signature key.
function
shkey_t* shkey_gen
(char *hex_str)
Converts a hex string into a binary key.
function
const char* shkey_hex
(shkey_t *key)
A string hexadecimal representation of a libshare key.
Note
The string returned will be 48 characters long.
function
shkey_t* shkey_hexgen
(char *hex_str)
Generate a libshare key from a 48-character long hexadecimal string.
function
shkey_t* shkey_shr160
(sh160_t raw)
Generate a allocated share-key from a 160bit binary segment.
function
shkey_t* ashkey_shr160
(sh160_t raw)
Generate a share-key on the stack from a 160bit binary segment.
Note
Do not free the return value.
function
void sh160_key
(shkey_t *in_key, sh160_t u160)
Obtain a 160bit binary segment from a pre-set 160-bit share-key.
function
void shkey_shr160_hash
(shkey_t *ret_key, unsigned char *data, size_t data_len)
Generate a SHA256+RIPEMD160 20-byte hash in the form of a share-key.
function
shkey_t* shkey_shr160_gen
(char *key_str)
Generate a 'u160' key from a printed key string.
function
char* shkey_shr160_print
(shkey_t *key)
function
int shkey_shr160_ver
(shkey_t *key)
function
int shr224
(unsigned char *data, size_t data_len, unsigned char *ret_digest)
function
int shr224_init
(shr224_t *ctx)
function
int shr224_write
(shr224_t *ctx, unsigned char *data, size_t data_len)
function
int shr224_result
(shr224_t *ctx, unsigned char *ret_digest)
function
int shr224_hmac
(unsigned char *key, size_t key_len, unsigned char *data, size_t data_len, unsigned char *ret_digest)
function
int shr224_hmac_init
(shr224_t *ctx, unsigned char *key, size_t key_len)
function
int shr224_hmac_write
(shr224_t *ctx, unsigned char *data, size_t data_len)
function
int shr224_hmac_result
(shr224_t *ctx, unsigned char *ret_digest)
function
int shr224_expand
(unsigned char *digest, unsigned char *data, size_t data_len)
function
int shr224_shrink
(uint64_t crc, unsigned char *data, size_t data_len, unsigned char *ret_digest)
function
uint64_t shr224_crc
(shr224_t *ctx)
function
shkey_t* ashkey_shr224
(void *data, size_t data_len)
function
shkey_t* shkey_shr224
(void *data, size_t data_len)
function
int shkey_shr224_ver
(shkey_t *key, unsigned char *data, size_t data_len)
function
int shr224_result_key
(shr224_t *ctx, shkey_t *key)
function
uint64_t shr224_result_crc
(shr224_t *ctx, shkey_t *key)
function
void* memxor
(void *dest, const void *src, size_t n)
function
int shkey_alg
(shkey_t *key)
function
void shkey_alg_set
(shkey_t *key, int alg)
define
SHKEY_WORDS
7
The maximum word size of the share key.
define
SHR224_SIZE
28
define
SHR224_BLOCKS
12
define
SHR224_BLOCK_SIZE
(SHR224_BLOCKS * sizeof(uint64_t))
define
SHR224_IPAD_MAGIC
(uint8_t)SHMEM8_MAGIC
define
SHR224_OPAD_MAGIC
(uint8_t)~SHMEM8_MAGIC
define
ashkey_blank
(( *)&_shkey_blank)structshkey__tcompoundshkey_t
Generates a blank key token. shkey_t structshkey__t compound
Return Value
A statically allocated blank key token.
Note
Do not free the returned value.
define
shkey_is_blank
(0 == memcmp((_key), &_shkey_blank, sizeof()))structshkey__tcompoundshkey_t
Determines whether a has been initialized. shkey_t structshkey__t compound
Return Value
FALSE is key is not blank, and TRUE is the key is blank.
Note
It is possible to generate keys which equal a blank key, for example a key generated from a zero-length data segment. This macro should be utilitized only when it is known that the key being compared against has a unique value.