signature-params: Properly handle MGF1 algorithm identifier without parameters
authorTobias Brunner <tobias@strongswan.org>
Mon, 4 Dec 2017 09:51:47 +0000 (10:51 +0100)
committerTobias Brunner <tobias@strongswan.org>
Mon, 19 Feb 2018 09:29:32 +0000 (10:29 +0100)
Credit to OSS-Fuzz.

Fixes: CVE-2018-6459

src/libstrongswan/credentials/keys/signature_params.c

index 6b4d22e..8f42fb9 100644 (file)
@@ -280,13 +280,17 @@ bool rsa_pss_params_parse(chunk_t asn1, int level0, rsa_pss_params_t *params)
                        case RSASSA_PSS_PARAMS_MGF_ALG:
                                if (object.len)
                                {
-                                       chunk_t hash;
+                                       chunk_t hash = chunk_empty;
 
                                        alg = asn1_parse_algorithmIdentifier(object, level, &hash);
                                        if (alg != OID_MGF1)
                                        {
                                                goto end;
                                        }
+                                       if (!hash.len)
+                                       {
+                                               goto end;
+                                       }
                                        alg = asn1_parse_algorithmIdentifier(hash, level+1, NULL);
                                        params->mgf1_hash = hasher_algorithm_from_oid(alg);
                                        if (params->mgf1_hash == HASH_UNKNOWN)