Issue reported by Apple Inc on 2025-03-26.
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27173)
|| (ret = OPENSSL_memdup(key, sizeof(*ret))) == NULL)
return NULL;
+ if (ret->propq != NULL
+ && (ret->propq = OPENSSL_strdup(ret->propq)) == NULL) {
+ OPENSSL_free(ret);
+ return NULL;
+ }
+
+ /* Absent key material, nothing left to do */
+ if (ret->mkey == NULL) {
+ if (ret->xkey == NULL)
+ return ret;
+ /* Fail if the source key is an inconsistent state */
+ OPENSSL_free(ret);
+ return NULL;
+ }
+
switch (selection & OSSL_KEYMGMT_SELECT_KEYPAIR) {
case 0:
ret->xkey = ret->mkey = NULL;