From 6f47b86f98eabd1863c2b6454a4abe3794fffe3a Mon Sep 17 00:00:00 2001 From: TLINDEN Date: Sun, 14 Dec 2014 14:36:08 +0100 Subject: [PATCH] added pcpkey_setowner(), removed pcp[pub]key_exists() (unused currently) --- include/pcp/key.h | 35 +++++++---------------------------- libpcp/key.c | 6 +++++- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/include/pcp/key.h b/include/pcp/key.h index e6db146..2e958fb 100644 --- a/include/pcp/key.h +++ b/include/pcp/key.h @@ -245,34 +245,6 @@ byte *pcppubkey_getchecksum(pcp_pubkey_t *k); byte *pcpkey_getchecksum(pcp_key_t *k); -/** Checks if a secret key structure is registered in the secret key hash. - - Returns a pointer to a pcp_key_t structure if there - exists a secret key structure with the given id in the - secret key hash. - - FIXME: needs to be moved to keyhash.h. - - \param[in] id A null-terminated char pointer of 17 bytes containing a key-id. - - \return Returns a pointer to a pcp_key_t struture or NULL if no key exists. - */ -pcp_key_t *pcpkey_exists(char *id); - -/** Checks if a public key structure is registered in the public key hash. - - Returns a pointer to a pcp_pubkey_t structure if there - exists a public key structure with the given id in the - public key hash. - - FIXME: needs to be moved to keyhash.h. - - \param[in] id A null-terminated char pointer of 17 bytes containing a key-id. - - \return Returns a pointer to a pcp_pubkey_t struture or NULL if no key exists. - */ -pcp_pubkey_t *pcppubkey_exists(char *id); - pcp_key_t * key2be(pcp_key_t *k); pcp_key_t *key2native(pcp_key_t *k); pcp_pubkey_t * pubkey2be(pcp_pubkey_t *k); @@ -332,6 +304,13 @@ void pcp_dumpkey(pcp_key_t *k); */ void pcp_dumppubkey(pcp_pubkey_t *k); +/** Set Owner and Mail. + + \param[in] key The secret key structure. + \param[in] owner Owner string. + \param[in] mail Email string. +*/ +void pcpkey_setowner(pcp_key_t *key, char *owner, char *mail); #endif /* _HAVE_PCP_KEYPAIR_H */ diff --git a/libpcp/key.c b/libpcp/key.c index c16a94c..2b93c8d 100644 --- a/libpcp/key.c +++ b/libpcp/key.c @@ -144,6 +144,11 @@ byte * pcp_gennonce() { return nonce; } +void pcpkey_setowner(pcp_key_t *key, char *owner, char *mail) { + strcpy(key->owner, owner); + strcpy(key->mail, mail); +} + pcp_key_t *pcpkey_encrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase) { if(key->nonce[0] == 0) { byte *nonce = pcp_gennonce(); @@ -216,7 +221,6 @@ pcp_key_t *pcpkey_decrypt(PCPCTX *ptx, pcp_key_t *key, char *passphrase) { } pcp_pubkey_t *pcpkey_pub_from_secret(pcp_key_t *key) { - /* pcp_dumpkey(key); */ pcp_pubkey_t *pub = urmalloc(sizeof (pcp_pubkey_t)); memcpy(pub->masterpub, key->masterpub, 32); memcpy(pub->pub, key->pub, 32);