From b31ba9bc4c9c48ca1c16f20053699ef573ee0ced Mon Sep 17 00:00:00 2001 From: miod Date: Mon, 4 Aug 2014 04:16:11 +0000 Subject: [PATCH] In chacha_init(), allow for a NULL iv. Reported by znz on github. ok guenther@ jsing@ --- lib/libcrypto/evp/e_chacha.c | 5 +++-- lib/libssl/src/crypto/evp/e_chacha.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/libcrypto/evp/e_chacha.c b/lib/libcrypto/evp/e_chacha.c index 0a5ab98cdbe..b63f586bba8 100644 --- a/lib/libcrypto/evp/e_chacha.c +++ b/lib/libcrypto/evp/e_chacha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_chacha.c,v 1.4 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: e_chacha.c,v 1.5 2014/08/04 04:16:11 miod Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -53,7 +53,8 @@ chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, { ChaCha_set_key((ChaCha_ctx *)ctx->cipher_data, key, EVP_CIPHER_CTX_key_length(ctx) * 8); - ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, NULL); + if (iv != NULL) + ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, NULL); return 1; } diff --git a/lib/libssl/src/crypto/evp/e_chacha.c b/lib/libssl/src/crypto/evp/e_chacha.c index 0a5ab98cdbe..b63f586bba8 100644 --- a/lib/libssl/src/crypto/evp/e_chacha.c +++ b/lib/libssl/src/crypto/evp/e_chacha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: e_chacha.c,v 1.4 2014/07/10 22:45:57 jsing Exp $ */ +/* $OpenBSD: e_chacha.c,v 1.5 2014/08/04 04:16:11 miod Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -53,7 +53,8 @@ chacha_init(EVP_CIPHER_CTX *ctx, const unsigned char *key, { ChaCha_set_key((ChaCha_ctx *)ctx->cipher_data, key, EVP_CIPHER_CTX_key_length(ctx) * 8); - ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, NULL); + if (iv != NULL) + ChaCha_set_iv((ChaCha_ctx *)ctx->cipher_data, iv, NULL); return 1; } -- 2.20.1