aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto/c_src/fips.c
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2019-01-02 15:21:32 +0100
committerGitHub <[email protected]>2019-01-02 15:21:32 +0100
commitd3f7bb27b1c495935c8c56aeba95cd83dce4298b (patch)
tree840ffb7d9129b40a762b1f541d9b74358db34ca1 /lib/crypto/c_src/fips.c
parentadf89a61d31938386e052027775a71e49fcd905d (diff)
parent69deab0db3d114928dde2fd9f86bcd3b507fe3ab (diff)
downloadotp-d3f7bb27b1c495935c8c56aeba95cd83dce4298b.tar.gz
otp-d3f7bb27b1c495935c8c56aeba95cd83dce4298b.tar.bz2
otp-d3f7bb27b1c495935c8c56aeba95cd83dce4298b.zip
Merge pull request #2068 from hogand/crypto/split-c-files
crypto: Split up crypto.c into multiple files OTP-14732
Diffstat (limited to 'lib/crypto/c_src/fips.c')
-rw-r--r--lib/crypto/c_src/fips.c52
1 files changed, 52 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..b2d892d00b
--- /dev/null
+++ b/lib/crypto/c_src/fips.c
@@ -0,0 +1,52 @@
+/*
+ * %CopyrightBegin%
+ *
+ * Copyright Ericsson AB 2010-2018. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * %CopyrightEnd%
+ */
+
+#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);
+ }
+}