]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
wolfssl: Reject EC keys with explicitly encoded parameters
authorTobias Brunner <tobias@strongswan.org>
Mon, 17 Jul 2023 09:43:47 +0000 (11:43 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 13 Oct 2023 07:10:46 +0000 (09:10 +0200)
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.

src/libstrongswan/plugins/wolfssl/wolfssl_ec_private_key.c
src/libstrongswan/plugins/wolfssl/wolfssl_ec_public_key.c

index a08cc17e39be109732eb822acd4b64eb4d942c24..addd3bda2a8dcd083e8ab54aff24cdd3e03d331f 100644 (file)
@@ -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;
index 97abe950b91f5f01d574d5f35a7c79e41b4be99f..58fd6edede17e90d619377bc96db669c5e20c4eb 100644 (file)
@@ -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;