X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=crypto%2Fkdf%2Ftls1_prf.c;h=49f7ecced90615be1928273661089e63622301f2;hp=f618362c0a2c6b4f6bb07dbe1021357d37d113eb;hb=cdb10bae3f773401e039c55965eb177a6f3fc160;hpb=e32b52a27e20a45f51f489e4efc04d1ca72b9609 diff --git a/crypto/kdf/tls1_prf.c b/crypto/kdf/tls1_prf.c index f618362c0a..49f7ecced9 100644 --- a/crypto/kdf/tls1_prf.c +++ b/crypto/kdf/tls1_prf.c @@ -1,5 +1,5 @@ /* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2016-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 @@ -37,9 +37,10 @@ static int pkey_tls1_prf_init(EVP_PKEY_CTX *ctx) { TLS1_PRF_PKEY_CTX *kctx; - kctx = OPENSSL_zalloc(sizeof(*kctx)); - if (kctx == NULL) + if ((kctx = OPENSSL_zalloc(sizeof(*kctx))) == NULL) { + KDFerr(KDF_F_PKEY_TLS1_PRF_INIT, ERR_R_MALLOC_FAILURE); return 0; + } ctx->data = kctx; return 1; @@ -193,7 +194,7 @@ static int tls1_prf_P_hash(const EVP_MD *md, if (ctx == NULL || ctx_tmp == NULL || ctx_init == NULL) goto err; EVP_MD_CTX_set_flags(ctx_init, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW); - mac_key = EVP_PKEY_new_private_key(EVP_PKEY_HMAC, NULL, sec, sec_len); + mac_key = EVP_PKEY_new_raw_private_key(EVP_PKEY_HMAC, NULL, sec, sec_len); if (mac_key == NULL) goto err; if (!EVP_DigestSignInit(ctx_init, NULL, md, NULL, mac_key)) @@ -256,9 +257,10 @@ static int tls1_prf_alg(const EVP_MD *md, seed, seed_len, out, olen)) return 0; - tmp = OPENSSL_malloc(olen); - if (tmp == NULL) + if ((tmp = OPENSSL_malloc(olen)) == NULL) { + KDFerr(KDF_F_TLS1_PRF_ALG, ERR_R_MALLOC_FAILURE); return 0; + } if (!tls1_prf_P_hash(EVP_sha1(), sec + slen/2, slen/2 + (slen & 1), seed, seed_len, tmp, olen)) { OPENSSL_clear_free(tmp, olen);