summaryrefslogtreecommitdiffstats
path: root/crypto/kdf
diff options
context:
space:
mode:
authorFdaSilvaYY <fdasilvayy@gmail.com>2018-03-29 20:59:58 +0200
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2018-03-29 22:46:10 +0200
commit3484236d8d7afedd3e5c7771bd49d3385340e3bf (patch)
tree15f0816c0636545ac6aa9e68aba5faa4e233491a /crypto/kdf
parent88b8d83e9e8869c60c556a86bee09f92c56c5a64 (diff)
EVP,KDF: Add more error code along some return 0 in ...
methods : - EVP_PBE_scrypt - EVP_PKEY_meth_add0 - EVP_PKEY_meth_new - EVP_PKEY_CTX_dup Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> (Merged from https://github.com/openssl/openssl/pull/5783)
Diffstat (limited to 'crypto/kdf')
-rw-r--r--crypto/kdf/kdf_err.c5
-rw-r--r--crypto/kdf/scrypt.c8
2 files changed, 10 insertions, 3 deletions
diff --git a/crypto/kdf/kdf_err.c b/crypto/kdf/kdf_err.c
index c7b84b0f51..52ebd036e0 100644
--- a/crypto/kdf/kdf_err.c
+++ b/crypto/kdf/kdf_err.c
@@ -1,6 +1,6 @@
/*
* Generated by util/mkerr.pl DO NOT EDIT
- * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -21,6 +21,9 @@ static const ERR_STRING_DATA KDF_str_functs[] = {
{ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_SCRYPT_CTRL_UINT64, 0),
"pkey_scrypt_ctrl_uint64"},
{ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_SCRYPT_DERIVE, 0), "pkey_scrypt_derive"},
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_SCRYPT_INIT, 0), "pkey_scrypt_init"},
+ {ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_SCRYPT_SET_MEMBUF, 0),
+ "pkey_scrypt_set_membuf"},
{ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_TLS1_PRF_CTRL_STR, 0),
"pkey_tls1_prf_ctrl_str"},
{ERR_PACK(ERR_LIB_KDF, KDF_F_PKEY_TLS1_PRF_DERIVE, 0),
diff --git a/crypto/kdf/scrypt.c b/crypto/kdf/scrypt.c
index 3f4cf385db..0a5e3c5f39 100644
--- a/crypto/kdf/scrypt.c
+++ b/crypto/kdf/scrypt.c
@@ -58,8 +58,10 @@ static int pkey_scrypt_init(EVP_PKEY_CTX *ctx)
SCRYPT_PKEY_CTX *kctx;
kctx = OPENSSL_zalloc(sizeof(*kctx));
- if (kctx == NULL)
+ if (kctx == NULL) {
+ KDFerr(KDF_F_PKEY_SCRYPT_INIT, ERR_R_MALLOC_FAILURE);
return 0;
+ }
/* Default values are the most conservative recommendation given in the
* original paper of C. Percival. Derivation uses roughly 1 GiB of memory
@@ -102,8 +104,10 @@ static int pkey_scrypt_set_membuf(unsigned char **buffer, size_t *buflen,
} else {
*buffer = OPENSSL_malloc(1);
}
- if (*buffer == NULL)
+ if (*buffer == NULL) {
+ KDFerr(KDF_F_PKEY_SCRYPT_SET_MEMBUF, ERR_R_MALLOC_FAILURE);
return 0;
+ }
*buflen = new_buflen;
return 1;