]> git.codecow.com Git - Monocypher.git/commitdiff
Moved trim_scalar() and scalar_bits() up a slot
authorLoup Vaillant <loup@loup-vaillant.fr>
Mon, 29 Jul 2019 22:30:22 +0000 (00:30 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Mon, 29 Jul 2019 22:30:22 +0000 (00:30 +0200)
Those functions are used for both X25519 and EdDSA. Moving them up one
section makes it easier for user to delete the X-25519 section without
affecting EdDSA.

(Overall, Monocypher should let users delete the code they don't
need. This wasn't an explicit goal initially, but the code naturally
turned out that way.  Supporting this use case cost us nothing.)

src/monocypher.c

index ee36c779d24b286d80825ca5606d89dc8a682764..c44e2ef329f7867170b8e7654392938a502cf899 100644 (file)
@@ -1276,10 +1276,6 @@ static int fe_isnonzero(const fe f)
     return isnonzero;
 }
 
-///////////////
-/// X-25519 /// Taken from Supercop's ref10 implementation.
-///////////////
-
 static void trim_scalar(u8 s[32])
 {
     s[ 0] &= 248;
@@ -1289,6 +1285,10 @@ static void trim_scalar(u8 s[32])
 
 static int scalar_bit(const u8 s[32], size_t i) {return (s[i>>3] >> (i&7)) & 1;}
 
+///////////////
+/// X-25519 /// Taken from Supercop's ref10 implementation.
+///////////////
+
 int crypto_x25519(u8       raw_shared_secret[32],
                   const u8 your_secret_key  [32],
                   const u8 their_public_key [32])