]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Better name for public keys
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 5 Feb 2016 15:55:48 +0000 (15:55 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 5 Feb 2016 15:55:48 +0000 (15:55 +0000)
src/libcryptobox/keypair.h
src/libcryptobox/keypair_private.h
src/libcryptobox/keypairs_cache.c
src/libcryptobox/keypairs_cache.h

index 49f4e2be0e5e4650dc43b76b8eca4ba022c0201c..fb4aa9d9cc6f4b8943fe7a8cb802465499ee9e24 100644 (file)
@@ -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
index 78aed7279f5d3afd33274a9775cb14f1849c3a92..6528087db7bff53f6bc427633030c6cc440c52b6 100644 (file)
@@ -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_ */
index 4b755fbd61dd6e57ed70ef5dd495cebc87173508..6e1d056e7a184f152a36b0638de63508ac3c4b7f 100644 (file)
@@ -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);
 
index e04a5914bfe1ffe56c581aff4060fd00475f325c..3ee7c0d51917f4df42f81a2d36731ba30bd17666 100644 (file)
@@ -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