]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:crypto: Add py binding for set_relax/strict fips mode
authorIsaac Boukris <iboukris@gmail.com>
Thu, 20 Aug 2020 10:45:49 +0000 (12:45 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 29 Oct 2020 14:19:36 +0000 (14:19 +0000)
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
lib/crypto/py_crypto.c

index 32b946eee8f7bd24a17660a7c50e36060d8d0dbe..ad18d3ada0f97fdbf39b7786f970f289b734760e 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
+#include "lib/crypto/gnutls_helpers.h"
 
 static PyObject *py_crypto_arcfour_crypt_blob(PyObject *module, PyObject *args)
 {
@@ -85,12 +86,27 @@ static PyObject *py_crypto_arcfour_crypt_blob(PyObject *module, PyObject *args)
        return result;
 }
 
+static PyObject *py_crypto_set_relax_mode(PyObject *module)
+{
+       GNUTLS_FIPS140_SET_LAX_MODE();
+
+       Py_RETURN_NONE;
+}
+
+static PyObject *py_crypto_set_strict_mode(PyObject *module)
+{
+       GNUTLS_FIPS140_SET_STRICT_MODE();
+
+       Py_RETURN_NONE;
+}
 
 static const char py_crypto_arcfour_crypt_blob_doc[] = "arcfour_crypt_blob(data, key)\n"
                                         "Encrypt the data with RC4 algorithm using the key";
 
 static PyMethodDef py_crypto_methods[] = {
        { "arcfour_crypt_blob", (PyCFunction)py_crypto_arcfour_crypt_blob, METH_VARARGS, py_crypto_arcfour_crypt_blob_doc },
+       { "set_relax_mode", (PyCFunction)py_crypto_set_relax_mode, METH_NOARGS, "Set fips to relax mode" },
+       { "set_strict_mode", (PyCFunction)py_crypto_set_strict_mode, METH_NOARGS, "Set fips to strict mode" },
        {0},
 };