libpcp  0.2.1
Macros | Functions | Variables
KEYHASH

Uthashes of secret and public key structures. More...

Macros

#define pcphash_iterate(key)
 Iterate over the list of secret keys.
 
#define pcphash_iteratepub(key)
 Iterate over the list of public keys.
 

Functions

void pcphash_init ()
 Initialize the global hashes.
 
void pcphash_del (void *key, int type)
 Delete an entry from a hash.
 
void pcphash_clean ()
 Frees the memory allocated by the hashes.
 
pcp_key_tpcphash_keyexists (char *id)
 Check if a secret key with a given key-id exists in the hash.
 
pcp_pubkey_tpcphash_pubkeyexists (char *id)
 Check if a publickey with a given key-id exists in the hash.
 
void pcphash_add (void *key, int type)
 Add a key structure to the hash list.
 
int pcphash_count ()
 Returns the number of secret keys in the hash.
 
int pcphash_countpub ()
 Returns the number of public keys in the hash.
 

Variables

pcp_key_tpcpkey_hash
 Global hash for secret keys.
 
pcp_pubkey_tpcppubkey_hash
 Global hash for public keys.
 
pcp_keysig_t * pcpkeysig_hash
 Global hash for key signatures.
 

Detailed Description

Uthashes of secret and public key structures.

Libpcp uses the uthash system to maintain lists of keys. There's one hash per key type. The hash has the same type as the key structure itself, but is global.

Macro Definition Documentation

#define pcphash_iterate (   key)
Value:
__k = NULL; \
HASH_ITER(hh, pcpkey_hash, key, __k)

Iterate over the list of secret keys.

Sample use:

pcp_key_t k = NULL;
}

Also, don't free() the keyhash or the temporary key pointer yourself. Use pcphash_clean() instead when done.

Definition at line 64 of file keyhash.h.

#define pcphash_iteratepub (   key)
Value:
__p = NULL; \
HASH_ITER(hh, pcppubkey_hash, key, __p)

Iterate over the list of public keys.

Sample use:

Also, don't free() the keyhash or the temporary key pointer yourself. Use pcphash_clean() instead when done.

Definition at line 83 of file keyhash.h.

Function Documentation

void pcphash_add ( void *  key,
int  type 
)

Add a key structure to the hash list.

Parameters
[in]keyA pointer to the key structure to delete.
[in]typeAn integer specifying the key type to delete.
See Also
_PCP_KEY_TYPES.
void pcphash_clean ( )

Frees the memory allocated by the hashes.

Clears and frees memory of all keys in the hash lists and the hashes themselfes.

int pcphash_count ( )

Returns the number of secret keys in the hash.

Returns
Number of keys.
int pcphash_countpub ( )

Returns the number of public keys in the hash.

Returns
Number of keys.
void pcphash_del ( void *  key,
int  type 
)

Delete an entry from a hash.

Parameters
[in]keyA pointer to the key structure to delete.
[in]typeAn integer specifying the key type to delete.
See Also
_PCP_KEY_TYPES.
void pcphash_init ( )

Initialize the global hashes.

pcp_key_t* pcphash_keyexists ( char *  id)

Check if a secret key with a given key-id exists in the hash.

Parameters
[in]idA string with the key-id (max 17 chars incl 0).
Returns
Returns a pointer to the matching key or NULL if the id doesn't match.
pcp_pubkey_t* pcphash_pubkeyexists ( char *  id)

Check if a publickey with a given key-id exists in the hash.

Parameters
[in]idA string with the key-id (max 17 chars incl 0).
Returns
Returns a pointer to the matching key or NULL if the id doesn't match.

Variable Documentation

pcp_key_t* pcpkey_hash

Global hash for secret keys.

pcp_keysig_t* pcpkeysig_hash

Global hash for key signatures.

pcp_pubkey_t* pcppubkey_hash

Global hash for public keys.