]> git.codecow.com Git - Monocypher.git/commitdiff
Renamed crypto_sign_blake2b_ctx back to crypto_sign_ctx
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 1 Dec 2019 11:01:15 +0000 (12:01 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 1 Dec 2019 11:01:15 +0000 (12:01 +0100)
Also renamed crypto_check_blake2b_ctx back to crypto_check_ctx.

This serves two purposes: avoid breaking the API when users upgrade from
Monocypher 2.x, and keep the idea that Blake2b is the default hash (the
default settings are implied and need not be named).

Note that although old code is not broken, it will still have warnings.
Those are easily silenced by casting to (void*).

src/monocypher.c
src/monocypher.h
tests/test.c

index c33ac7f89c0a6c789cf6beabc616db2a96d90e16..d000608a5eddffa7d46c1f305e8835b7ef480037 100644 (file)
@@ -634,17 +634,17 @@ void crypto_blake2b(u8 hash[64], const u8 *message, size_t message_size)
 
 static void blake2b_vtable_init(void *ctx)
 {
-    crypto_blake2b_init(&((crypto_sign_blake2b_ctx*)ctx)->hash);
+    crypto_blake2b_init(&((crypto_sign_ctx*)ctx)->hash);
 }
 
 static void blake2b_vtable_update(void *ctx, const u8 *m, size_t s)
 {
-    crypto_blake2b_update(&((crypto_sign_blake2b_ctx*)ctx)->hash, m, s);
+    crypto_blake2b_update(&((crypto_sign_ctx*)ctx)->hash, m, s);
 }
 
 static void blake2b_vtable_final(void *ctx, u8 *h)
 {
-    crypto_blake2b_final(&((crypto_sign_blake2b_ctx*)ctx)->hash, h);
+    crypto_blake2b_final(&((crypto_sign_ctx*)ctx)->hash, h);
 }
 
 const crypto_hash_vtable crypto_blake2b_vtable = {
@@ -652,7 +652,7 @@ const crypto_hash_vtable crypto_blake2b_vtable = {
     blake2b_vtable_init,
     blake2b_vtable_update,
     blake2b_vtable_final,
-    sizeof (crypto_sign_blake2b_ctx),
+    sizeof(crypto_sign_ctx),
 };
 
 ////////////////
@@ -2014,7 +2014,7 @@ void crypto_sign(u8        signature[64],
                  const u8  public_key[32],
                  const u8 *message, size_t message_size)
 {
-    crypto_sign_blake2b_ctx ctx;
+    crypto_sign_ctx ctx;
     crypto_sign_init_first_pass ((void*)&ctx, secret_key, public_key);
     crypto_sign_update          ((void*)&ctx, message, message_size);
     crypto_sign_init_second_pass((void*)&ctx);
@@ -2079,7 +2079,7 @@ int crypto_check(const u8  signature[64],
                  const u8  public_key[32],
                  const u8 *message, size_t message_size)
 {
-    crypto_check_blake2b_ctx   ctx;
+    crypto_check_ctx   ctx;
     crypto_check_init((void*)&ctx, signature, public_key);
     crypto_check_update((void*)&ctx, message, message_size);
     return crypto_check_final((void*)&ctx);
index 322fd1db1be39025b65fa7b56c14c65b08af1106..f9ba177ddf20e3d2d87c0bcba028c3dd85589659 100644 (file)
@@ -50,8 +50,8 @@ typedef crypto_sign_ctx_abstract crypto_check_ctx_abstract;
 typedef struct {
     crypto_sign_ctx_abstract ctx;
     crypto_blake2b_ctx       hash;
-} crypto_sign_blake2b_ctx;
-typedef crypto_sign_blake2b_ctx crypto_check_blake2b_ctx;
+} crypto_sign_ctx;
+typedef crypto_sign_ctx crypto_check_ctx;
 
 ////////////////////////////
 /// High level interface ///
index 9cb61ba9934bbc853a4e5aa0e273d9e1ec56da71..9a80085e511184dfbd8a9605f601f944c2c25c53 100644 (file)
@@ -583,7 +583,7 @@ static int p_eddsa_incremental()
         u8 sig_mono[64];  crypto_sign(sig_mono, sk, pk, msg, MESSAGE_SIZE);
         u8 sig_incr[64];
         {
-            crypto_sign_blake2b_ctx ctx;
+            crypto_sign_ctx ctx;
             crypto_sign_init_first_pass ((void*)&ctx, sk, pk);
             crypto_sign_update          ((void*)&ctx, msg  , i);
             crypto_sign_update          ((void*)&ctx, msg+i, MESSAGE_SIZE-i);
@@ -595,7 +595,7 @@ static int p_eddsa_incremental()
         status |= memcmp(sig_mono, sig_incr, 64);
         status |= crypto_check(sig_mono, pk, msg, MESSAGE_SIZE);
         {
-            crypto_check_blake2b_ctx ctx;
+            crypto_check_ctx ctx;
             crypto_check_init  ((void*)&ctx, sig_incr, pk);
             crypto_check_update((void*)&ctx, msg  , i);
             crypto_check_update((void*)&ctx, msg+i, MESSAGE_SIZE-i);