When exporting/importing decoded keys do not use 0 as selection
[openssl.git] / providers / implementations / encode_decode / decode_pvk2key.c
index 819014231cd8ad530aa5667db0706d72a095c4c7..cae1d9897a2ba84a563c3ee1d8fd12b90ed0f089 100644 (file)
@@ -190,10 +190,14 @@ static int pvk2key_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;
 }