From 91d9051bce2660dc3f7a6fd890e0ddb602848c22 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 19 Jul 2018 14:44:17 +0200 Subject: [PATCH 1/2] Nits --- src/libsodium/crypto_pwhash/argon2/argon2-core.c | 4 ++-- .../nosse/pwhash_scryptsalsa208sha256_nosse.c | 3 ++- .../crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libsodium/crypto_pwhash/argon2/argon2-core.c b/src/libsodium/crypto_pwhash/argon2/argon2-core.c index b52b04d3..530778e4 100644 --- a/src/libsodium/crypto_pwhash/argon2/argon2-core.c +++ b/src/libsodium/crypto_pwhash/argon2/argon2-core.c @@ -67,7 +67,7 @@ store_block(void *output, const block *src) * @param m_cost number of blocks to allocate in the memory * @return ARGON2_OK if @memory is a valid pointer and memory is allocated */ -static int allocate_memory(block_region **memory, uint32_t m_cost); +static int allocate_memory(block_region **region, uint32_t m_cost); static int allocate_memory(block_region **region, uint32_t m_cost) @@ -153,7 +153,7 @@ clear_memory(argon2_instance_t *instance, int clear) /* Deallocates memory * @param memory pointer to the blocks */ -static void free_memory(block_region *memory); +static void free_memory(block_region *region); static void free_memory(block_region *region) diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c index 9e31352d..40288590 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/nosse/pwhash_scryptsalsa208sha256_nosse.c @@ -163,8 +163,9 @@ salsa20_8(uint32_t B[16]) x[15] ^= R(x[14] + x[13], 18); #undef R } - for (i = 0; i < 16; i++) + for (i = 0; i < 16; i++) { B[i] += x[i]; + } } /** diff --git a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c index 139a7df2..cbd68aa1 100644 --- a/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c +++ b/src/libsodium/crypto_pwhash/scryptsalsa208sha256/scrypt_platform.c @@ -55,9 +55,9 @@ alloc_region(escrypt_region_t *region, size_t size) aligned = base; #else base = aligned = NULL; - if (size + 63 < size) + if (size + 63 < size) { errno = ENOMEM; - else if ((base = (uint8_t *) malloc(size + 63)) != NULL) { + } else if ((base = (uint8_t *) malloc(size + 63)) != NULL) { aligned = base + 63; aligned -= (uintptr_t) aligned & 63; } From d25d6ce7fbf940f2e20e668a2a30d066f66e39e2 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 21 Jul 2018 00:42:31 +0200 Subject: [PATCH 2/2] Invert (1-y) just before the multiplication by (1+y) for readability --- src/libsodium/crypto_sign/ed25519/ref10/keypair.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsodium/crypto_sign/ed25519/ref10/keypair.c b/src/libsodium/crypto_sign/ed25519/ref10/keypair.c index 8bf3cec8..4b9bf0dc 100644 --- a/src/libsodium/crypto_sign/ed25519/ref10/keypair.c +++ b/src/libsodium/crypto_sign/ed25519/ref10/keypair.c @@ -61,9 +61,9 @@ crypto_sign_ed25519_pk_to_curve25519(unsigned char *curve25519_pk, } fe25519_1(one_minus_y); fe25519_sub(one_minus_y, one_minus_y, A.Y); - fe25519_invert(one_minus_y, one_minus_y); fe25519_1(x); fe25519_add(x, x, A.Y); + fe25519_invert(one_minus_y, one_minus_y); fe25519_mul(x, x, one_minus_y); fe25519_tobytes(curve25519_pk, x);