Skip to content

Commit

Permalink
dh_cms_set_peerkey: Pad the public key to p size
Browse files Browse the repository at this point in the history
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #13958)
  • Loading branch information
t8m committed Feb 2, 2021
1 parent af403db commit 6a1a649
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crypto/cms/cms_dh.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ static int dh_cms_set_peerkey(EVP_PKEY_CTX *pctx,

if ((public_key = d2i_ASN1_INTEGER(NULL, &p, plen)) == NULL)
goto err;
plen = ASN1_STRING_length((ASN1_STRING *)public_key);
/*
* Pad to full p parameter size as that is checked by
* EVP_PKEY_set1_encoded_public_key()
*/
plen = EVP_PKEY_size(pk);
if ((bnpub = ASN1_INTEGER_to_BN(public_key, NULL)) == NULL)
goto err;
if ((buf = OPENSSL_malloc(plen)) == NULL)
Expand Down

0 comments on commit 6a1a649

Please sign in to comment.