From e2071542bf0d1ae40a399458b7afd6f6ba5e6124 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 29 Mar 2019 16:18:51 -0400 Subject: [PATCH] use 16 bytes iv for chacha20 --- libi2pd/Crypto.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libi2pd/Crypto.cpp b/libi2pd/Crypto.cpp index 68dc8f90..2145d773 100644 --- a/libi2pd/Crypto.cpp +++ b/libi2pd/Crypto.cpp @@ -1235,7 +1235,9 @@ namespace crypto { #if OPENSSL_AEAD_CHACHA20_POLY1305 EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new (); - EVP_EncryptInit_ex(ctx, EVP_chacha20 (), 0, key, nonce); + uint32_t iv[4]; + iv[0] = 1; memcpy (iv + 1, nonce, 12); // counter | nonce + EVP_EncryptInit_ex(ctx, EVP_chacha20 (), NULL, key, (const uint8_t *)iv); int outlen = 0; EVP_EncryptUpdate(ctx, out, &outlen, msg, msgLen); EVP_EncryptFinal_ex(ctx, NULL, &outlen);