From: Loup Vaillant Date: Sun, 1 Dec 2019 10:55:48 +0000 (+0100) Subject: Cosmetic (convert pointers directly) X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=684409b96dbf14b3a131d0be64d23f229c700505;p=Monocypher.git Cosmetic (convert pointers directly) --- diff --git a/src/monocypher.c b/src/monocypher.c index 29e27e0..c33ac7f 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -2014,13 +2014,12 @@ 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_abstract *ctx_ptr = (void*)&ctx; - crypto_sign_init_first_pass (ctx_ptr, secret_key, public_key); - crypto_sign_update (ctx_ptr, message, message_size); - crypto_sign_init_second_pass(ctx_ptr); - crypto_sign_update (ctx_ptr, message, message_size); - crypto_sign_final (ctx_ptr, signature); + crypto_sign_blake2b_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); + crypto_sign_update ((void*)&ctx, message, message_size); + crypto_sign_final ((void*)&ctx, signature); } void crypto_check_init_custom_hash(crypto_check_ctx_abstract *ctx, @@ -2081,10 +2080,9 @@ int crypto_check(const u8 signature[64], const u8 *message, size_t message_size) { crypto_check_blake2b_ctx ctx; - crypto_check_ctx_abstract *ctx_ptr = (void*)&ctx; - crypto_check_init(ctx_ptr, signature, public_key); - crypto_check_update(ctx_ptr, message, message_size); - return crypto_check_final(ctx_ptr); + 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/optional/ed25519.c b/src/optional/ed25519.c index b31a54e..39b47b1 100644 --- a/src/optional/ed25519.c +++ b/src/optional/ed25519.c @@ -260,13 +260,12 @@ void crypto_ed25519_sign(u8 signature [64], const u8 public_key[32], const u8 *message, size_t message_size) { - crypto_sign_sha512_ctx ctx; - crypto_sign_ctx_abstract *ctx_ptr = (void*)&ctx; - crypto_ed25519_sign_init_first_pass(ctx_ptr, secret_key, public_key); - crypto_sign_update (ctx_ptr, message, message_size); - crypto_sign_init_second_pass (ctx_ptr); - crypto_sign_update (ctx_ptr, message, message_size); - crypto_sign_final (ctx_ptr, signature); + crypto_sign_sha512_ctx ctx; + crypto_ed25519_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); + crypto_sign_update ((void*)&ctx, message, message_size); + crypto_sign_final ((void*)&ctx, signature); } @@ -274,10 +273,9 @@ int crypto_ed25519_check(const u8 signature [64], const u8 public_key[32], const u8 *message, size_t message_size) { - crypto_check_sha512_ctx ctx; - crypto_check_ctx_abstract *ctx_ptr = (void*)&ctx; - crypto_ed25519_check_init(ctx_ptr, signature, public_key); - crypto_check_update(ctx_ptr, message, message_size); - return crypto_check_final(ctx_ptr); + crypto_check_sha512_ctx ctx; + crypto_ed25519_check_init((void*)&ctx, signature, public_key); + crypto_check_update((void*)&ctx, message, message_size); + return crypto_check_final((void*)&ctx); } diff --git a/tests/test.c b/tests/test.c index 9b3b724..9cb61ba 100644 --- a/tests/test.c +++ b/tests/test.c @@ -577,31 +577,29 @@ static int p_eddsa_incremental() { int status = 0; FOR (i, 0, MESSAGE_SIZE) { - RANDOM_INPUT(message, MESSAGE_SIZE); + RANDOM_INPUT(msg, MESSAGE_SIZE); RANDOM_INPUT(sk, 32); u8 pk [32]; crypto_sign_public_key(pk, sk); - u8 sig_mono[64]; crypto_sign(sig_mono, sk, pk, message, MESSAGE_SIZE); + 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_abstract *ctx_ptr = (void*)&ctx; - crypto_sign_init_first_pass (ctx_ptr, sk, pk); - crypto_sign_update (ctx_ptr, message , i); - crypto_sign_update (ctx_ptr, message + i, MESSAGE_SIZE - i); - crypto_sign_init_second_pass(ctx_ptr); - crypto_sign_update (ctx_ptr, message , i); - crypto_sign_update (ctx_ptr, message + i, MESSAGE_SIZE - i); - crypto_sign_final (ctx_ptr, sig_incr); + crypto_sign_blake2b_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); + crypto_sign_init_second_pass((void*)&ctx); + crypto_sign_update ((void*)&ctx, msg , i); + crypto_sign_update ((void*)&ctx, msg+i, MESSAGE_SIZE-i); + crypto_sign_final ((void*)&ctx, sig_incr); } status |= memcmp(sig_mono, sig_incr, 64); - status |= crypto_check(sig_mono, pk, message, MESSAGE_SIZE); + status |= crypto_check(sig_mono, pk, msg, MESSAGE_SIZE); { - crypto_check_blake2b_ctx ctx; - crypto_check_ctx_abstract*ctx_ptr=(void*)&ctx; - crypto_check_init (ctx_ptr, sig_incr, pk); - crypto_check_update(ctx_ptr, message , i); - crypto_check_update(ctx_ptr, message + i, MESSAGE_SIZE - i); - status |= crypto_check_final(ctx_ptr); + crypto_check_blake2b_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); + status |= crypto_check_final((void*)&ctx); } } printf("%s: EdDSA (incremental)\n", status != 0 ? "FAILED" : "OK");