Skip to content
This repository was archived by the owner on Aug 24, 2025. It is now read-only.

Commit 29cbeb9

Browse files
committed
Make EVP_PKEY_asn1_new() stricter with its input
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Tim Hudson <tjh@openssl.org> (Merged from openssl#6880) (cherry picked from commit 38eca7f)
1 parent 831a2b0 commit 29cbeb9

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGES

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
Changes between 1.1.0h and 1.1.0i [xx XXX xxxx]
1111

12+
*) Make EVP_PKEY_asn1_new() a bit stricter about its input. A NULL pem_str
13+
parameter is no longer accepted, as it leads to a corrupt table. NULL
14+
pem_str is reserved for alias entries only.
15+
[Richard Levitte]
16+
1217
*) Revert blinding in ECDSA sign and instead make problematic addition
1318
length-invariant. Switch even to fixed-length Montgomery multiplication.
1419
[Andy Polyakov]

crypto/asn1/ameth_lib.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,18 @@ EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
255255
goto err;
256256
}
257257

258+
/*
259+
* One of the following must be true:
260+
*
261+
* pem_str == NULL AND ASN1_PKEY_ALIAS is set
262+
* pem_str != NULL AND ASN1_PKEY_ALIAS is clear
263+
*
264+
* Anything else is an error and may lead to a corrupt ASN1 method table
265+
*/
266+
if (!((pem_str == NULL && (flags & ASN1_PKEY_ALIAS) != 0)
267+
|| (pem_str != NULL && (flags & ASN1_PKEY_ALIAS) == 0)))
268+
goto err;
269+
258270
if (pem_str) {
259271
ameth->pem_str = OPENSSL_strdup(pem_str);
260272
if (!ameth->pem_str)

0 commit comments

Comments
 (0)