|
|
1524bc |
From c1258172d502955442704264ec1c7ea926784b35 Mon Sep 17 00:00:00 2001
|
|
|
1524bc |
From: Isaac Boukris <iboukris@gmail.com>
|
|
|
1524bc |
Date: Sat, 9 Nov 2019 17:47:33 +0100
|
|
|
1524bc |
Subject: [PATCH 164/187] libcli/auth: test des_crypt56() and add test_gnutls
|
|
|
1524bc |
to selftest
|
|
|
1524bc |
|
|
|
1524bc |
Signed-off-by: Isaac Boukris <iboukris@samba.org>
|
|
|
1524bc |
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
|
|
1524bc |
(cherry picked from commit 07b4606f893fabd50c2685307d58e86f55defae5)
|
|
|
1524bc |
---
|
|
|
1524bc |
libcli/auth/tests/test_gnutls.c | 24 ++++++++++++++++++++++++
|
|
|
1524bc |
libcli/auth/wscript_build | 1 +
|
|
|
1524bc |
selftest/tests.py | 2 ++
|
|
|
1524bc |
3 files changed, 27 insertions(+)
|
|
|
1524bc |
|
|
|
1524bc |
diff --git a/libcli/auth/tests/test_gnutls.c b/libcli/auth/tests/test_gnutls.c
|
|
|
1524bc |
index 412a454b762..7847d01a4dc 100644
|
|
|
1524bc |
--- a/libcli/auth/tests/test_gnutls.c
|
|
|
1524bc |
+++ b/libcli/auth/tests/test_gnutls.c
|
|
|
1524bc |
@@ -24,6 +24,7 @@
|
|
|
1524bc |
#include <cmocka.h>
|
|
|
1524bc |
|
|
|
1524bc |
#include "includes.h"
|
|
|
1524bc |
+#include "libcli/auth/libcli_auth.h"
|
|
|
1524bc |
|
|
|
1524bc |
#include "lib/crypto/gnutls_helpers.h"
|
|
|
1524bc |
#include <gnutls/gnutls.h>
|
|
|
1524bc |
@@ -227,11 +228,34 @@ static void torture_gnutls_aes_128_cfb(void **state)
|
|
|
1524bc |
#endif
|
|
|
1524bc |
}
|
|
|
1524bc |
|
|
|
1524bc |
+static void torture_gnutls_des_crypt56(void **state)
|
|
|
1524bc |
+{
|
|
|
1524bc |
+ static const uint8_t key[7] = {
|
|
|
1524bc |
+ 0x69, 0x88, 0x96, 0x8E, 0xB5, 0x3A, 0x24
|
|
|
1524bc |
+ };
|
|
|
1524bc |
+ static const uint8_t clear[8] = {
|
|
|
1524bc |
+ 0x3F, 0x49, 0x5B, 0x20, 0xA7, 0x84, 0xC2, 0x34
|
|
|
1524bc |
+ };
|
|
|
1524bc |
+ static const uint8_t crypt_expected[8] = {
|
|
|
1524bc |
+ 0x54, 0x86, 0xCF, 0x51, 0x49, 0x3A, 0x53, 0x5B
|
|
|
1524bc |
+ };
|
|
|
1524bc |
+
|
|
|
1524bc |
+ uint8_t crypt[8];
|
|
|
1524bc |
+ uint8_t decrypt[8];
|
|
|
1524bc |
+
|
|
|
1524bc |
+ des_crypt56(crypt, clear, key, 1);
|
|
|
1524bc |
+ assert_memory_equal(crypt, crypt_expected, 8);
|
|
|
1524bc |
+
|
|
|
1524bc |
+ des_crypt56(decrypt, crypt, key, 0);
|
|
|
1524bc |
+ assert_memory_equal(decrypt, clear, 8);
|
|
|
1524bc |
+}
|
|
|
1524bc |
+
|
|
|
1524bc |
int main(int argc, char *argv[])
|
|
|
1524bc |
{
|
|
|
1524bc |
int rc;
|
|
|
1524bc |
const struct CMUnitTest tests[] = {
|
|
|
1524bc |
cmocka_unit_test(torture_gnutls_aes_128_cfb),
|
|
|
1524bc |
+ cmocka_unit_test(torture_gnutls_des_crypt56),
|
|
|
1524bc |
};
|
|
|
1524bc |
|
|
|
1524bc |
if (argc == 2) {
|
|
|
1524bc |
diff --git a/libcli/auth/wscript_build b/libcli/auth/wscript_build
|
|
|
1524bc |
index 7b765cd9e43..8e856d07ddf 100644
|
|
|
1524bc |
--- a/libcli/auth/wscript_build
|
|
|
1524bc |
+++ b/libcli/auth/wscript_build
|
|
|
1524bc |
@@ -76,6 +76,7 @@ bld.SAMBA_BINARY('test_gnutls',
|
|
|
1524bc |
source='tests/test_gnutls.c',
|
|
|
1524bc |
deps='''
|
|
|
1524bc |
gnutls
|
|
|
1524bc |
+ LIBCLI_AUTH
|
|
|
1524bc |
cmocka
|
|
|
1524bc |
samba-util
|
|
|
1524bc |
''',
|
|
|
1524bc |
diff --git a/selftest/tests.py b/selftest/tests.py
|
|
|
1524bc |
index c91d9b445fe..20809678104 100644
|
|
|
1524bc |
--- a/selftest/tests.py
|
|
|
1524bc |
+++ b/selftest/tests.py
|
|
|
1524bc |
@@ -390,6 +390,8 @@ plantestsuite("samba.unittests.byteorder", "none",
|
|
|
1524bc |
[os.path.join(bindir(), "default/lib/util/test_byteorder")])
|
|
|
1524bc |
plantestsuite("samba.unittests.ntlm_check", "none",
|
|
|
1524bc |
[os.path.join(bindir(), "default/libcli/auth/test_ntlm_check")])
|
|
|
1524bc |
+plantestsuite("samba.unittests.gnutls", "none",
|
|
|
1524bc |
+ [os.path.join(bindir(), "default/libcli/auth/test_gnutls")])
|
|
|
1524bc |
plantestsuite("samba.unittests.schannel", "none",
|
|
|
1524bc |
[os.path.join(bindir(), "default/libcli/auth/test_schannel")])
|
|
|
1524bc |
plantestsuite("samba.unittests.rc4_passwd_buffer", "none",
|
|
|
1524bc |
--
|
|
|
1524bc |
2.23.0
|
|
|
1524bc |
|