forked from spacemonkeygo/openssl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request spacemonkeygo#67 from diffeo/master
FIPS Mode capability
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |