diff options
author | Doug Hogan <[email protected]> | 2018-12-20 02:14:19 -0800 |
---|---|---|
committer | Doug Hogan <[email protected]> | 2018-12-20 02:30:58 -0800 |
commit | 49663961687dbf3beda19d875f91730b719e9f6f (patch) | |
tree | 1cb5adc0a03bc03319ef3672394fee4549f5e192 /lib/crypto/c_src/fips.c | |
parent | 910700572a9ad3b8bda0ea79832d338e626f6a54 (diff) | |
download | otp-49663961687dbf3beda19d875f91730b719e9f6f.tar.gz otp-49663961687dbf3beda19d875f91730b719e9f6f.tar.bz2 otp-49663961687dbf3beda19d875f91730b719e9f6f.zip |
Move most FIPS functionality to a new file
Diffstat (limited to 'lib/crypto/c_src/fips.c')
-rw-r--r-- | lib/crypto/c_src/fips.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/crypto/c_src/fips.c b/lib/crypto/c_src/fips.c new file mode 100644 index 0000000000..5d6adb730c --- /dev/null +++ b/lib/crypto/c_src/fips.c @@ -0,0 +1,32 @@ +#include "fips.h" + +ERL_NIF_TERM info_fips(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ +#ifdef FIPS_SUPPORT + return FIPS_mode() ? atom_enabled : atom_not_enabled; +#else + return atom_not_supported; +#endif +} + +ERL_NIF_TERM enable_fips_mode(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{/* (Boolean) */ + if (argv[0] == atom_true) { +#ifdef FIPS_SUPPORT + if (FIPS_mode_set(1)) { + return atom_true; + } +#endif + PRINTF_ERR0("CRYPTO: Could not setup FIPS mode"); + return atom_false; + } else if (argv[0] == atom_false) { +#ifdef FIPS_SUPPORT + if (!FIPS_mode_set(0)) { + return atom_false; + } +#endif + return atom_true; + } else { + return enif_make_badarg(env); + } +} |