From 278fbd4892fafb5acf26f0ec3876a6ea23b9a9f1 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Tue, 7 Jan 2025 17:48:00 +0100 Subject: [PATCH] simplify supportsSHAKE --- cshake.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/cshake.go b/cshake.go index d08e219..578882a 100644 --- a/cshake.go +++ b/cshake.go @@ -74,19 +74,7 @@ func supportsSHAKE(size int) bool { if v, ok := cacheSHAKESupported.Load(size); ok { return v.(bool) } - alg := loadShake(size) - if alg == nil { - cacheSHAKESupported.Store(size, false) - return false - } - // EVP_MD objects can be non-nil even when they can't be used - // in a EVP_MD_CTX, e.g. MD5 in FIPS mode. We need to prove - // if they can be used by passing them to a EVP_MD_CTX. - var supported bool - if ctx := C.go_openssl_EVP_MD_CTX_new(); ctx != nil { - supported = C.go_openssl_EVP_DigestInit_ex(ctx, alg.md, nil) == 1 - C.go_openssl_EVP_MD_CTX_free(ctx) - } + supported := loadShake(size) != nil cacheSHAKESupported.Store(size, supported) return supported }