Skip to content

Commit

Permalink
simplify supportsSHAKE
Browse files Browse the repository at this point in the history
  • Loading branch information
qmuntal committed Jan 7, 2025
1 parent 1592b8e commit 278fbd4
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions cshake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 278fbd4

Please sign in to comment.