]> git.codecow.com Git - Monocypher.git/commitdiff
No intermediate buffer for HChacha20
authorLoup Vaillant <loup@loup-vaillant.fr>
Tue, 23 Oct 2018 19:06:47 +0000 (21:06 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Tue, 23 Oct 2018 19:06:47 +0000 (21:06 +0200)
That buffer wasn't really needed, so I optimised it away

src/monocypher.c

index fd402d37b61d2f219b9fc1e6e6f24cf3be32663c..40bb999a6a260d6402806206ed203e2e8a41a075 100644 (file)
@@ -1964,11 +1964,8 @@ int crypto_key_exchange(u8       shared_key[32],
                         const u8 your_secret_key [32],
                         const u8 their_public_key[32])
 {
-    u8 raw_shared_secret[32];
-    int status = crypto_x25519(raw_shared_secret,
-                               your_secret_key, their_public_key);
-    crypto_chacha20_H(shared_key, raw_shared_secret, zero);
-    WIPE_BUFFER(raw_shared_secret);
+    int status = crypto_x25519(shared_key, your_secret_key, their_public_key);
+    crypto_chacha20_H(shared_key, shared_key, zero);
     return status;
 }