From 2f7882244f364f6f8e254945c147c3bf61fd50ce Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 4 Feb 2017 12:45:13 +0800 Subject: [PATCH] Refine IV in stream cipher --- src/stream.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/stream.c b/src/stream.c index f80d5732..7efd315a 100644 --- a/src/stream.c +++ b/src/stream.c @@ -260,10 +260,6 @@ cipher_ctx_set_nonce(cipher_ctx_t *cipher_ctx, uint8_t *nonce, size_t nonce_len, return; } - if (!enc) { - memcpy(cipher_ctx->nonce, nonce, cipher->nonce_len); - } - if (cipher->method >= SALSA20) { return; } @@ -504,7 +500,7 @@ stream_decrypt(buffer_t *ciphertext, cipher_ctx_t *cipher_ctx, size_t capacity) if (plaintext->len <= nonce_len) return CRYPTO_ERROR; - uint8_t nonce[MAX_NONCE_LENGTH]; + uint8_t *nonce = cipher_ctx->nonce; nonce_len = cipher->nonce_len; plaintext->len -= nonce_len;