Merge pull request #67 from diffeo/master

FIPS Mode capability
This commit is contained in:
JT Olds 2016-11-28 18:02:28 -07:00 committed by GitHub
commit d63025916b

27
fips.go Normal file
View File

@ -0,0 +1,27 @@
// +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
}