From: Loup Vaillant Date: Sun, 1 Dec 2019 11:01:15 +0000 (+0100) Subject: Renamed crypto_sign_blake2b_ctx back to crypto_sign_ctx X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=10dbba8069ae91e7f30c53e49f7e9a3c5213cb5a;p=Monocypher.git Renamed crypto_sign_blake2b_ctx back to crypto_sign_ctx 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*). --- diff --git a/src/monocypher.c b/src/monocypher.c index c33ac7f..d000608 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -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); diff --git a/src/monocypher.h b/src/monocypher.h index 322fd1d..f9ba177 100644 --- a/src/monocypher.h +++ b/src/monocypher.h @@ -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 /// diff --git a/tests/test.c b/tests/test.c index 9cb61ba..9a80085 100644 --- a/tests/test.c +++ b/tests/test.c @@ -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);