]> git.codecow.com Git - Monocypher.git/commitdiff
Renamed crypto_hash_vtable into crypto_sign_vtable
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 1 Dec 2019 12:57:17 +0000 (13:57 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 1 Dec 2019 12:57:17 +0000 (13:57 +0100)
The vtable holds hash functions, but it's really a vtable for
crypto_sign_ctx_abstract (and its check typedef). It's more tied to
EdDSA than to the hash itself.

src/monocypher.c
src/monocypher.h
src/optional/ed25519.c
src/optional/ed25519.h

index d000608a5eddffa7d46c1f305e8835b7ef480037..96b380f6f9ce0c1f50d9178ddd7807f4135d96e7 100644 (file)
@@ -647,7 +647,7 @@ static void blake2b_vtable_final(void *ctx, u8 *h)
     crypto_blake2b_final(&((crypto_sign_ctx*)ctx)->hash, h);
 }
 
-const crypto_hash_vtable crypto_blake2b_vtable = {
+const crypto_sign_vtable crypto_blake2b_vtable = {
     crypto_blake2b,
     blake2b_vtable_init,
     blake2b_vtable_update,
@@ -1914,7 +1914,7 @@ static void ge_scalarmult_base(ge *p, const u8 scalar[32])
 
 void crypto_sign_public_key_custom_hash(u8       public_key[32],
                                         const u8 secret_key[32],
-                                        const crypto_hash_vtable *hash)
+                                        const crypto_sign_vtable *hash)
 {
     u8 a[64];
     hash->hash(a, secret_key, 32);
@@ -1935,7 +1935,7 @@ void crypto_sign_public_key(u8 public_key[32], const u8 secret_key[32])
 void crypto_sign_init_first_pass_custom_hash(crypto_sign_ctx_abstract *ctx,
                                              const u8 secret_key[32],
                                              const u8 public_key[32],
-                                             const crypto_hash_vtable *hash)
+                                             const crypto_sign_vtable *hash)
 {
     ctx->hash  = hash; // set vtable
     u8 *a      = ctx->buf;
@@ -2025,7 +2025,7 @@ void crypto_sign(u8        signature[64],
 void crypto_check_init_custom_hash(crypto_check_ctx_abstract *ctx,
                                    const u8 signature[64],
                                    const u8 public_key[32],
-                                   const crypto_hash_vtable  *hash)
+                                   const crypto_sign_vtable *hash)
 {
     ctx->hash = hash; // set vtable
     FOR (i, 0, 64) { ctx->buf[i] = signature [i]; }
index f60366b6bc039422f86667e875ea18d27184be84..0d99b0497beb379bb32a91e736cc86f5d9e64e41 100644 (file)
@@ -19,7 +19,7 @@ typedef struct {
     void (*update)(void *ctx, const uint8_t *message, size_t message_size);
     void (*final )(void *ctx, uint8_t *hash);
     size_t ctx_size;
-} crypto_hash_vtable;
+} crypto_sign_vtable;
 
 // Do not rely on the size or contents of any of the types below,
 // they may change without notice.
@@ -44,7 +44,7 @@ typedef struct {
 
 // Signatures (EdDSA)
 typedef struct {
-    const crypto_hash_vtable *hash;
+    const crypto_sign_vtable *hash;
     uint8_t buf[96];
     uint8_t pk [32];
 } crypto_sign_ctx_abstract;
@@ -126,7 +126,7 @@ void crypto_blake2b_general_init(crypto_blake2b_ctx *ctx, size_t hash_size,
                                  const uint8_t      *key, size_t key_size);
 
 // vtable for signatures
-extern const crypto_hash_vtable crypto_blake2b_vtable;
+extern const crypto_sign_vtable crypto_blake2b_vtable;
 
 
 // Password key derivation (Argon2 i)
@@ -191,15 +191,15 @@ int crypto_check_final  (crypto_check_ctx_abstract *ctx);
 // Custom hash interface
 void crypto_sign_public_key_custom_hash(uint8_t       public_key[32],
                                         const uint8_t secret_key[32],
-                                        const crypto_hash_vtable *hash);
+                                        const crypto_sign_vtable *hash);
 void crypto_sign_init_first_pass_custom_hash(crypto_sign_ctx_abstract *ctx,
                                              const uint8_t secret_key[32],
                                              const uint8_t public_key[32],
-                                             const crypto_hash_vtable *hash);
+                                             const crypto_sign_vtable *hash);
 void crypto_check_init_custom_hash(crypto_check_ctx_abstract *ctx,
                                    const uint8_t signature[64],
                                    const uint8_t public_key[32],
-                                   const crypto_hash_vtable *hash);
+                                   const crypto_sign_vtable *hash);
 
 ////////////////////////////
 /// Low level primitives ///
index 3782994ba5ca4049295dda1787a3d69d5f61612f..5279c2ee5fe8ff9518e37435fcc241a95b2ac5d4 100644 (file)
@@ -220,7 +220,7 @@ static void sha512_vtable_final(void *ctx, u8 *h)
     crypto_sha512_final(&((crypto_sign_sha512_ctx*)ctx)->hash, h);
 }
 
-const crypto_hash_vtable crypto_sha512_vtable = {
+const crypto_sign_vtable crypto_sha512_vtable = {
     crypto_sha512,
     sha512_vtable_init,
     sha512_vtable_update,
index 3753c210d0a6b24c6618ce33778189285a11ddb7..981140e48bb0a0dc5f2443726ed51fdf17b2cd8f 100644 (file)
@@ -34,7 +34,7 @@ void crypto_sha512_final (crypto_sha512_ctx *ctx, uint8_t hash[64]);
 void crypto_sha512(uint8_t *out,const uint8_t *message, size_t message_size);
 
 // vtable for signatures
-extern const crypto_hash_vtable crypto_sha512_vtable;
+extern const crypto_sign_vtable crypto_sha512_vtable;
 
 
 // Ed25519