2016-11-29 05:39:24 +08:00
|
|
|
package openssl
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include <openssl/ssl.h>
|
|
|
|
*/
|
|
|
|
import "C"
|
2016-11-29 08:36:21 +08:00
|
|
|
import "runtime"
|
2016-11-29 05:39:24 +08:00
|
|
|
|
2016-11-29 05:49:19 +08:00
|
|
|
// FIPSModeSet enables a FIPS 140-2 validated mode of operation.
|
|
|
|
// https://wiki.openssl.org/index.php/FIPS_mode_set()
|
2016-11-29 05:39:24 +08:00
|
|
|
func FIPSModeSet(mode bool) error {
|
2016-11-29 08:36:21 +08:00
|
|
|
runtime.LockOSThread()
|
|
|
|
defer runtime.UnlockOSThread()
|
|
|
|
|
2016-11-29 05:39:24 +08:00
|
|
|
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
|
2016-11-29 05:49:19 +08:00
|
|
|
}
|