diff options
-rw-r--r-- | src/libcryptobox/keypair.h | 2 | ||||
-rw-r--r-- | src/libcryptobox/keypair_private.h | 27 | ||||
-rw-r--r-- | src/libcryptobox/keypairs_cache.c | 10 | ||||
-rw-r--r-- | src/libcryptobox/keypairs_cache.h | 2 |
4 files changed, 21 insertions, 20 deletions
diff --git a/src/libcryptobox/keypair.h b/src/libcryptobox/keypair.h index 49f4e2be0..fb4aa9d9c 100644 --- a/src/libcryptobox/keypair.h +++ b/src/libcryptobox/keypair.h @@ -35,7 +35,7 @@ struct rspamd_cryptobox_keypair; /** * Opaque structure for public only keypair */ -struct rspamd_cryptobox_keypair_public; +struct rspamd_cryptobox_pubkey; /** * Creates new full keypair diff --git a/src/libcryptobox/keypair_private.h b/src/libcryptobox/keypair_private.h index 78aed7279..6528087db 100644 --- a/src/libcryptobox/keypair_private.h +++ b/src/libcryptobox/keypair_private.h @@ -81,7 +81,7 @@ struct RSPAMD_ALIGNED(32) rspamd_cryptobox_keypair_sig_25519 { /* * Public component of the keypair */ -struct RSPAMD_ALIGNED(32) rspamd_cryptobox_keypair_public { +struct RSPAMD_ALIGNED(32) rspamd_cryptobox_pubkey { guchar id[rspamd_cryptobox_HASHBYTES]; struct rspamd_cryptobox_nm *nm; enum rspamd_cryptobox_keypair_type type; @@ -92,39 +92,40 @@ struct RSPAMD_ALIGNED(32) rspamd_cryptobox_keypair_public { /* * Public p256 ecdh */ -#define RSPAMD_CRYPTOBOX_KEYPAIR_PUBLIC_NIST(x) ((struct rspamd_cryptobox_keypair_public_nist *)(x)) -struct RSPAMD_ALIGNED(32) rspamd_cryptobox_keypair_public_nist { - struct rspamd_cryptobox_keypair_public parent; +#define RSPAMD_CRYPTOBOX_PUBKEY_NIST(x) ((struct rspamd_cryptobox_pubkey_nist *)(x)) +struct RSPAMD_ALIGNED(32) rspamd_cryptobox_pubkey_nist { + struct rspamd_cryptobox_pubkey parent; guchar RSPAMD_ALIGNED(32) pk[65]; }; /* * Public curve25519 ecdh */ -#define RSPAMD_CRYPTOBOX_KEYPAIR_PUBLIC_25519(x) ((struct rspamd_cryptobox_keypair_public_25519 *)(x)) -struct RSPAMD_ALIGNED(32) rspamd_cryptobox_keypair_public_25519 { - struct rspamd_cryptobox_keypair_public parent; +#define RSPAMD_CRYPTOBOX_PUBKEY_25519(x) ((struct rspamd_cryptobox_pubkey_25519 *)(x)) +struct RSPAMD_ALIGNED(32) rspamd_cryptobox_pubkey_25519 { + struct rspamd_cryptobox_pubkey parent; guchar RSPAMD_ALIGNED(32) pk[32]; }; /* * Public p256 ecdsa */ -#define RSPAMD_CRYPTOBOX_KEYPAIR_SIG_PUBLIC_NIST(x) ((struct rspamd_cryptobox_keypair_sig_public_nist *)(x)) -struct RSPAMD_ALIGNED(32) rspamd_cryptobox_keypair_sig_public_nist { - struct rspamd_cryptobox_keypair_public parent; +#define RSPAMD_CRYPTOBOX_PUBKEY_SIG_NIST(x) ((struct rspamd_cryptobox_pubkey_sig_nist *)(x)) +struct RSPAMD_ALIGNED(32) rspamd_cryptobox_pubkey_sig_nist { + struct rspamd_cryptobox_pubkey parent; guchar RSPAMD_ALIGNED(32) pk[65]; }; /* * Public ed25519 */ -#define RSPAMD_CRYPTOBOX_KEYPAIR_SIG_PUBLIC_25519(x) ((struct rspamd_cryptobox_keypair_sig_public_25519 *)(x)) -struct RSPAMD_ALIGNED(32) rspamd_cryptobox_keypair_sig_public_25519 { - struct rspamd_cryptobox_keypair_public parent; +#define RSPAMD_CRYPTOBOX_PUBKEY_SIG_25519(x) ((struct rspamd_cryptobox_pubkey_sig_25519 *)(x)) +struct RSPAMD_ALIGNED(32) rspamd_cryptobox_pubkey_sig_25519 { + struct rspamd_cryptobox_pubkey parent; guchar RSPAMD_ALIGNED(32) pk[32]; }; void rspamd_cryptobox_nm_dtor (struct rspamd_cryptobox_nm *nm); +void rspamd_cryptobox_keypair_dtor (struct rspamd_cryptobox_keypair *kp); #endif /* KEYPAIR_PRIVATE_H_ */ diff --git a/src/libcryptobox/keypairs_cache.c b/src/libcryptobox/keypairs_cache.c index 4b755fbd6..6e1d056e7 100644 --- a/src/libcryptobox/keypairs_cache.c +++ b/src/libcryptobox/keypairs_cache.c @@ -72,7 +72,7 @@ rspamd_keypair_cache_new (guint max_items) void rspamd_keypair_cache_process (struct rspamd_keypair_cache *c, struct rspamd_cryptobox_keypair *lk, - struct rspamd_cryptobox_keypair_public *rk) + struct rspamd_cryptobox_pubkey *rk) { struct rspamd_keypair_elt search, *new; @@ -103,16 +103,16 @@ rspamd_keypair_cache_process (struct rspamd_keypair_cache *c, rspamd_cryptobox_HASHBYTES); if (rk->alg == RSPAMD_CRYPTOBOX_MODE_25519) { - struct rspamd_cryptobox_keypair_public_25519 *rk_25519 = - RSPAMD_CRYPTOBOX_KEYPAIR_PUBLIC_25519(rk); + struct rspamd_cryptobox_pubkey_25519 *rk_25519 = + RSPAMD_CRYPTOBOX_PUBKEY_25519(rk); struct rspamd_cryptobox_keypair_25519 *sk_25519 = RSPAMD_CRYPTOBOX_KEYPAIR_25519(lk); rspamd_cryptobox_nm (new->nm->nm, rk_25519->pk, sk_25519->sk, rk->alg); } else { - struct rspamd_cryptobox_keypair_public_nist *rk_nist = - RSPAMD_CRYPTOBOX_KEYPAIR_PUBLIC_NIST(rk); + struct rspamd_cryptobox_pubkey_nist *rk_nist = + RSPAMD_CRYPTOBOX_PUBKEY_NIST(rk); struct rspamd_cryptobox_keypair_nist *sk_nist = RSPAMD_CRYPTOBOX_KEYPAIR_NIST(lk); diff --git a/src/libcryptobox/keypairs_cache.h b/src/libcryptobox/keypairs_cache.h index e04a5914b..3ee7c0d51 100644 --- a/src/libcryptobox/keypairs_cache.h +++ b/src/libcryptobox/keypairs_cache.h @@ -37,7 +37,7 @@ struct rspamd_keypair_cache * rspamd_keypair_cache_new (guint max_items); */ void rspamd_keypair_cache_process (struct rspamd_keypair_cache *c, struct rspamd_cryptobox_keypair *lk, - struct rspamd_cryptobox_keypair_public *rk); + struct rspamd_cryptobox_pubkey *rk); /** * Destroy old keypair cache |