Adapt libcrypto functionality to specify the desired input structure
authorRichard Levitte <levitte@openssl.org>
Mon, 26 Oct 2020 12:58:30 +0000 (13:58 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 11 Nov 2020 10:42:06 +0000 (11:42 +0100)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13248)

crypto/cms/cms_ec.c
crypto/store/store_result.c

index 9a602bb81d2d6b13b190adce2707d920b53dc4e6..5dac7f06834ece37a214cd5d096fbce3decdcf9f 100644 (file)
@@ -24,23 +24,16 @@ static EVP_PKEY *pkey_type2param(int ptype, const void *pval,
     if (ptype == V_ASN1_SEQUENCE) {
         const ASN1_STRING *pstr = pval;
         const unsigned char *pm = pstr->data;
-        int pmlen = pstr->length;
+        size_t pmlen = (size_t)pstr->length;
         OSSL_DECODER_CTX *ctx = NULL;
-        BIO *membio = NULL;
+        int selection = OSSL_KEYMGMT_SELECT_ALL_PARAMETERS;
 
-        /* TODO(3.0): Need to be able to specify here that only params will do */
-        ctx = OSSL_DECODER_CTX_new_by_EVP_PKEY(&pkey, "DER", "EC", libctx,
-                                               propq);
+        ctx = OSSL_DECODER_CTX_new_by_EVP_PKEY(&pkey, "DER", NULL, "EC",
+                                               selection, libctx, propq);
         if (ctx == NULL)
             goto err;
 
-        membio = BIO_new_mem_buf(pm, pmlen);
-        if (membio == NULL) {
-            OSSL_DECODER_CTX_free(ctx);
-            goto err;
-        }
-        OSSL_DECODER_from_bio(ctx, membio);
-        BIO_free(membio);
+        OSSL_DECODER_from_data(ctx, &pm, &pmlen);
         OSSL_DECODER_CTX_free(ctx);
     } else if (ptype == V_ASN1_OBJECT) {
         const ASN1_OBJECT *poid = pval;
index 5848761a5e31341d5becd8ad4754c20a26b015c7..96df9d8e14121056c79fdbd0210c347aa5d7efbc 100644 (file)
@@ -255,7 +255,8 @@ static EVP_PKEY *try_key_value(struct extracted_param_data_st *data,
     size_t pdatalen = data->octet_data_size;
 
     decoderctx =
-        OSSL_DECODER_CTX_new_by_EVP_PKEY(&pk, "DER", NULL, libctx, propq);
+        OSSL_DECODER_CTX_new_by_EVP_PKEY(&pk, NULL, NULL, NULL, 0,
+                                         libctx, propq);
     (void)OSSL_DECODER_CTX_set_passphrase_cb(decoderctx, cb, cbarg);
 
     /* No error if this couldn't be decoded */