]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - providers/implementations/kdfs/scrypt.c
Fix bug in scrypt KDF provider dup method
[thirdparty/openssl.git] / providers / implementations / kdfs / scrypt.c
index 744f87847b8a156bdd944967942e6e80a4e06208..c070c7b059d019502b070c005c48134acd9af22a 100644 (file)
@@ -56,7 +56,7 @@ typedef struct {
 
 static void kdf_scrypt_init(KDF_SCRYPT *ctx);
 
-static void *kdf_scrypt_new(void *provctx)
+static void *kdf_scrypt_new_inner(OSSL_LIB_CTX *libctx)
 {
     KDF_SCRYPT *ctx;
 
@@ -68,11 +68,16 @@ static void *kdf_scrypt_new(void *provctx)
         ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
         return NULL;
     }
-    ctx->libctx = PROV_LIBCTX_OF(provctx);
+    ctx->libctx = libctx;
     kdf_scrypt_init(ctx);
     return ctx;
 }
 
+static void *kdf_scrypt_new(void *provctx)
+{
+    return kdf_scrypt_new_inner(PROV_LIBCTX_OF(provctx));
+}
+
 static void kdf_scrypt_free(void *vctx)
 {
     KDF_SCRYPT *ctx = (KDF_SCRYPT *)vctx;
@@ -99,7 +104,7 @@ static void *kdf_scrypt_dup(void *vctx)
     const KDF_SCRYPT *src = (const KDF_SCRYPT *)vctx;
     KDF_SCRYPT *dest;
 
-    dest = kdf_scrypt_new(src->libctx);
+    dest = kdf_scrypt_new_inner(src->libctx);
     if (dest != NULL) {
         if (src->sha256 != NULL && !EVP_MD_up_ref(src->sha256))
             goto err;