wolfssl: Reject EC keys with explicitly encoded parameters

These are not allowed in X.509 certificates according to RFC 5480 and
some newer validations apparently explicitly check for this.

Note that WolfSSL rejects such keys, by default.  Only when compiled with
WOLFSSL_NO_ASN_STRICT are they accepted.
This commit is contained in:
Tobias Brunner
2023-10-13 09:10:46 +02:00
parent 6f0cd19fd6
commit a69184fb9d
2 changed files with 3 additions and 2 deletions
@@ -449,7 +449,8 @@ wolfssl_ec_private_key_t *wolfssl_ec_private_key_load(key_type_t type,
}
idx = 0;
if (wc_EccPrivateKeyDecode(key.ptr, &idx, &this->ec, key.len) < 0)
if (wc_EccPrivateKeyDecode(key.ptr, &idx, &this->ec, key.len) < 0 ||
this->ec.idx == -1)
{
destroy(this);
return NULL;
@@ -378,7 +378,7 @@ wolfssl_ec_public_key_t *wolfssl_ec_public_key_load(key_type_t type,
idx = 0;
ret = wc_EccPublicKeyDecode(blob.ptr, &idx, &this->ec, blob.len);
if (ret < 0)
if (ret < 0 || this->ec.idx == -1)
{
destroy(this);
return NULL;