b6b438
From 620713d0e16e07f44fb4c086290161da81d37f1f Mon Sep 17 00:00:00 2001
b6b438
From: Isaac Boukris <iboukris@gmail.com>
b6b438
Date: Tue, 19 Nov 2019 19:10:18 +0100
b6b438
Subject: [PATCH 169/187] selftest: test des_crypt128
b6b438
b6b438
Signed-off-by: Isaac Boukris <iboukris@samba.org>
b6b438
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
b6b438
(cherry picked from commit e2f8f686d1e3fce91f10aadb9667854cf2a1219a)
b6b438
---
b6b438
 libcli/auth/tests/test_gnutls.c | 20 ++++++++++++++++++++
b6b438
 1 file changed, 20 insertions(+)
b6b438
b6b438
diff --git a/libcli/auth/tests/test_gnutls.c b/libcli/auth/tests/test_gnutls.c
b6b438
index 1e6f8dd5b5b..b1129db14c9 100644
b6b438
--- a/libcli/auth/tests/test_gnutls.c
b6b438
+++ b/libcli/auth/tests/test_gnutls.c
b6b438
@@ -332,6 +332,25 @@ static void torture_gnutls_E_old_pw_hash(void **state)
b6b438
 	assert_memory_equal(crypt, crypt_expected, 16);
b6b438
 }
b6b438
 
b6b438
+static void torture_gnutls_des_crypt128(void **state)
b6b438
+{
b6b438
+	static uint8_t key[16] = {
b6b438
+		0x98, 0xFD, 0xCB, 0x3A, 0xF7, 0xB5, 0x1C, 0xF8,
b6b438
+		0xA9, 0x69, 0x88, 0x96, 0x8E, 0xB5, 0x3A, 0x24
b6b438
+	};
b6b438
+	static const uint8_t clear[8] = {
b6b438
+		0x3F, 0x49, 0x5B, 0x20, 0xA7, 0x84, 0xC2, 0x34
b6b438
+	};
b6b438
+	static const uint8_t crypt_expected[8] = {
b6b438
+		0x4C, 0xB4, 0x4B, 0xD3, 0xC8, 0xC1, 0xA5, 0x50
b6b438
+	};
b6b438
+
b6b438
+	uint8_t crypt[8];
b6b438
+
b6b438
+	des_crypt128(crypt, clear, key);
b6b438
+	assert_memory_equal(crypt, crypt_expected, 8);
b6b438
+}
b6b438
+
b6b438
 static void torture_gnutls_sam_rid_crypt(void **state)
b6b438
 {
b6b438
 	static const uint8_t clear[16] = {
b6b438
@@ -364,6 +383,7 @@ int main(int argc, char *argv[])
b6b438
 		cmocka_unit_test(torture_gnutls_E_P24),
b6b438
 		cmocka_unit_test(torture_gnutls_SMBOWFencrypt),
b6b438
 		cmocka_unit_test(torture_gnutls_E_old_pw_hash),
b6b438
+		cmocka_unit_test(torture_gnutls_des_crypt128),
b6b438
 		cmocka_unit_test(torture_gnutls_sam_rid_crypt),
b6b438
 	};
b6b438
 
b6b438
-- 
b6b438
2.23.0
b6b438