| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5f4b859 commit 478a719
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2793,15 +2793,24 @@ DataPointer argon2(const Buffer<const char>& pass, | |||
| 2793 | 2793 | return {}; | |
| 2794 | 2794 | } | |
| 2795 | 2795 | ||
| 2796 | - // creates a new library context to avoid locking when running concurrently | ||
| 2797 | - auto ctx = DeleteFnPtr<OSSL_LIB_CTX, OSSL_LIB_CTX_free>{OSSL_LIB_CTX_new()}; | ||
| 2798 | - if (!ctx) { | ||
| 2799 | - return {}; | ||
| 2800 | - } | ||
| 2796 | + // A new library context is only needed for OSSL_set_max_threads(), which is | ||
| 2797 | + // per-context. It inherits no configuration, so availability is checked | ||
| 2798 | + // against the default context, otherwise Argon2 works in FIPS mode. | ||
| 2799 | + DeleteFnPtr<OSSL_LIB_CTX, OSSL_LIB_CTX_free> ctx; | ||
| 2800 | + if (lanes > 1) { | ||
| 2801 | + if (!DeleteFnPtr<EVP_KDF, EVP_KDF_free>{ | ||
| 2802 | + EVP_KDF_fetch(nullptr, algorithm.data(), nullptr)}) { | ||
| 2803 | + return {}; | ||
| 2804 | + } | ||
| 2801 | 2805 | ||
| 2802 | - // required if threads > 1 | ||
| 2803 | - if (lanes > 1 && OSSL_set_max_threads(ctx.get(), lanes) != 1) { | ||
| 2804 | - return {}; | ||
| 2806 | + ctx.reset(OSSL_LIB_CTX_new()); | ||
| 2807 | + if (!ctx) { | ||
| 2808 | + return {}; | ||
| 2809 | + } | ||
| 2810 | + | ||
| 2811 | + if (OSSL_set_max_threads(ctx.get(), lanes) != 1) { | ||
| 2812 | + return {}; | ||
| 2813 | + } | ||
| 2805 | 2814 | } | |
| 2806 | 2815 | ||
| 2807 | 2816 | auto kdf = DeleteFnPtr<EVP_KDF, EVP_KDF_free>{ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments