mirror of
https://github.com/libp2p/go-openssl.git
synced 2024-12-27 23:40:18 +08:00
ddb2b54e96
Based on a PR comment here: https://github.com/spacemonkeygo/openssl/pull/42
28 lines
452 B
Go
28 lines
452 B
Go
// +build cgo
|
|
|
|
package openssl
|
|
|
|
/*
|
|
#include <openssl/ssl.h>
|
|
*/
|
|
import "C"
|
|
import "runtime"
|
|
|
|
// FIPSModeSet enables a FIPS 140-2 validated mode of operation.
|
|
// https://wiki.openssl.org/index.php/FIPS_mode_set()
|
|
func FIPSModeSet(mode bool) error {
|
|
runtime.LockOSThread()
|
|
defer runtime.UnlockOSThread()
|
|
|
|
var r C.int
|
|
if mode {
|
|
r = C.FIPS_mode_set(1)
|
|
} else {
|
|
r = C.FIPS_mode_set(0)
|
|
}
|
|
if r != 1 {
|
|
return errorFromErrorQueue()
|
|
}
|
|
return nil
|
|
}
|