]> git.codecow.com Git - Monocypher.git/commitdiff
Fixed XChacha20 bug (wrong key)
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 24 Nov 2019 21:39:22 +0000 (22:39 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 24 Nov 2019 21:39:22 +0000 (22:39 +0100)
src/monocypher.c

index 6b2f50a73a0517e1315dcbceb62eeee240d5f2b7..a1fc4a0db167d9c177c8b085634260dc68937639 100644 (file)
@@ -255,7 +255,9 @@ void crypto_xchacha20_ctr(u8 *cipher_text, const u8 *plain_text,
 {
     u8 sub_key[32];
     crypto_hchacha20(sub_key, key, nonce);
-    crypto_chacha20_ctr(cipher_text, plain_text, text_size, key, nonce+16, ctr);
+    crypto_chacha20_ctr(cipher_text, plain_text, text_size,
+                        sub_key, nonce+16, ctr);
+    WIPE_BUFFER(sub_key);
 }
 
 void crypto_chacha20(u8 *cipher_text, const u8 *plain_text, size_t text_size,