KEYHASH

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

Macros

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

Functions

void pcphash_del (PCPCTX *ptx, void *key, int type)
 Delete an entry from a hash. More...
 
void pcphash_clean (PCPCTX *ptx)
 Free memory used by key global ptx-attached hashes. More...
 
void pcphash_cleanpub (pcp_pubkey_t *pub)
 Free memory by local pubkey hash. More...
 
pcp_key_tpcphash_keyexists (PCPCTX *ptx, char *id)
 Check if a secret key with a given key-id exists in the hash. More...
 
pcp_pubkey_tpcphash_pubkeyexists (PCPCTX *ptx, char *id)
 Check if a publickey with a given key-id exists in the hash. More...
 
void pcphash_add (PCPCTX *ptx, void *key, int type)
 Add a key structure to the hash list. More...
 
int pcphash_count (PCPCTX *ptx)
 Returns the number of secret keys in the hash. More...
 
int pcphash_countpub (PCPCTX *ptx)
 Returns the number of public keys in the hash. More...
 

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, and is stored in the PCP Context object.

Macro Definition Documentation

#define pcphash_iterate (   ptx,
  key 
)
Value:
pcp_key_t *__k = NULL; \
HASH_ITER(hh, ptx->pcpkey_hash, key, __k)

Iterate over the list of secret keys.

Sample use:

pcp_key_t k = NULL;
pcphash_iterate(ptx, k) {
}

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

Definition at line 57 of file keyhash.h.

#define pcphash_iteratepub (   ptx,
  key 
)
Value:
pcp_pubkey_t *__p = NULL; \
HASH_ITER(hh, ptx->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 76 of file keyhash.h.

Function Documentation

void pcphash_add ( PCPCTX ptx,
void *  key,
int  type 
)

Add a key structure to the hash list.

Parameters
[in]ptxPcp Context object.
[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 ( PCPCTX ptx)

Free memory used by key global ptx-attached hashes.

void pcphash_cleanpub ( pcp_pubkey_t pub)

Free memory by local pubkey hash.

int pcphash_count ( PCPCTX ptx)

Returns the number of secret keys in the hash.

Parameters
[in]ptxPcp Context object.
Returns
Number of keys.
int pcphash_countpub ( PCPCTX ptx)

Returns the number of public keys in the hash.

Parameters
[in]ptxPcp Context object.
Returns
Number of keys.
void pcphash_del ( PCPCTX ptx,
void *  key,
int  type 
)

Delete an entry from a hash.

Parameters
[in]ptxPcp Context object.
[in]keyA pointer to the key structure to delete.
[in]typeAn integer specifying the key type to delete.
See Also
_PCP_KEY_TYPES.
pcp_key_t* pcphash_keyexists ( PCPCTX ptx,
char *  id 
)

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

Parameters
[in]ptxPcp Context object.
[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 ( PCPCTX ptx,
char *  id 
)

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

Parameters
[in]ptxPcp Context object.
[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.