When exporting/importing decoded keys do not use 0 as selection
[openssl.git] / providers / implementations / encode_decode / decode_msblob2key.c
index 3bf4cf453726ecc55b227827f44f2e8e5ea9efd4..7c4f993b899eb161d95e88d215e78912dc7ef865 100644 (file)
@@ -221,10 +221,14 @@ msblob2key_export_object(void *vctx,
     void *keydata;
 
     if (reference_sz == sizeof(keydata) && export != NULL) {
+        int selection = ctx->selection;
+
+        if (selection == 0)
+            selection = OSSL_KEYMGMT_SELECT_ALL;
         /* The contents of the reference is the address to our object */
         keydata = *(void **)reference;
 
-        return export(keydata, ctx->selection, export_cb, export_cbarg);
+        return export(keydata, selection, export_cb, export_cbarg);
     }
     return 0;
 }