]> git.ipfire.org Git - people/ms/strongswan.git/commitdiff
pubkey: Don't assume blobs are only ASN.1 DER
authorTobias Brunner <tobias@strongswan.org>
Mon, 21 Jun 2021 09:44:51 +0000 (11:44 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 23 Aug 2021 15:59:39 +0000 (17:59 +0200)
Also forward the blob's type when parsing pubkeys.

src/libstrongswan/plugins/pubkey/pubkey_cert.c

index a7bf87e5bad3658dcea22838c22dae545480784f..68866d2ad5f8f22fc3186ea28045c90441694363 100644 (file)
@@ -264,15 +264,20 @@ pubkey_cert_t *pubkey_cert_wrap(certificate_type_t type, va_list args)
 {
        public_key_t *key = NULL;
        chunk_t blob = chunk_empty;
+       builder_part_t part, blob_type = BUILD_END;
        identification_t *subject = NULL;
        time_t notBefore = UNDEFINED_TIME, notAfter = UNDEFINED_TIME;
 
        while (TRUE)
        {
-               switch (va_arg(args, builder_part_t))
+               part = va_arg(args, builder_part_t);
+               switch (part)
                {
+                       case BUILD_BLOB:
+                       case BUILD_BLOB_PEM:
                        case BUILD_BLOB_ASN1_DER:
                                blob = va_arg(args, chunk_t);
+                               blob_type = part;
                                continue;
                        case BUILD_PUBLIC_KEY:
                                key = va_arg(args, public_key_t*);
@@ -300,7 +305,7 @@ pubkey_cert_t *pubkey_cert_wrap(certificate_type_t type, va_list args)
        else if (blob.ptr)
        {
                key = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_ANY,
-                                                                BUILD_BLOB_ASN1_DER, blob, BUILD_END);
+                                                                blob_type, blob, BUILD_END);
        }
        if (key)
        {