66 lines
2.0 KiB
Diff
66 lines
2.0 KiB
Diff
From fe1f6278c7a5c54d948f6ca031686745ad653a94 Mon Sep 17 00:00:00 2001
|
|
From: Andreas Schneider <asn@samba.org>
|
|
Date: Tue, 9 Jul 2019 13:06:49 +0200
|
|
Subject: [PATCH 018/187] libcli:auth: Add test for encode_rc4_passwd_buffer()
|
|
|
|
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14031
|
|
|
|
Signed-off-by: Andreas Schneider <asn@samba.org>
|
|
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
|
|
(cherry picked from commit fe00b3735a7e8ae16fb6443965769f1e947a6aa6)
|
|
---
|
|
libcli/auth/tests/test_rc4_passwd_buffer.c | 31 ++++++++++++++++++++++
|
|
1 file changed, 31 insertions(+)
|
|
|
|
diff --git a/libcli/auth/tests/test_rc4_passwd_buffer.c b/libcli/auth/tests/test_rc4_passwd_buffer.c
|
|
index 3bf371c5dd5..db6ca3f3f4c 100644
|
|
--- a/libcli/auth/tests/test_rc4_passwd_buffer.c
|
|
+++ b/libcli/auth/tests/test_rc4_passwd_buffer.c
|
|
@@ -157,12 +157,43 @@ static void torture_rc4_passwd_buffer(void **state)
|
|
talloc_free(password_decoded);
|
|
}
|
|
|
|
+static void torture_endode_decode_rc4_passwd_buffer(void **state)
|
|
+{
|
|
+ char *password_decoded = NULL;
|
|
+ size_t password_decoded_len = 0;
|
|
+ DATA_BLOB session_key = data_blob_const("SystemLibraryDTC", 16);
|
|
+ struct samr_CryptPasswordEx out_pwd_buf = {
|
|
+ .data = {0},
|
|
+ };
|
|
+ NTSTATUS status;
|
|
+ bool ok;
|
|
+
|
|
+ status = encode_rc4_passwd_buffer(PASSWORD,
|
|
+ &session_key,
|
|
+ &out_pwd_buf);
|
|
+ assert_true(NT_STATUS_IS_OK(status));
|
|
+
|
|
+ status = decode_rc4_passwd_buffer(&session_key, &out_pwd_buf);
|
|
+ assert_true(NT_STATUS_IS_OK(status));
|
|
+
|
|
+ ok = decode_pw_buffer(NULL,
|
|
+ out_pwd_buf.data,
|
|
+ &password_decoded,
|
|
+ &password_decoded_len,
|
|
+ CH_UTF16);
|
|
+ assert_true(ok);
|
|
+ assert_int_equal(password_decoded_len, strlen(PASSWORD));
|
|
+ assert_string_equal(password_decoded, PASSWORD);
|
|
+ talloc_free(password_decoded);
|
|
+}
|
|
+
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int rc;
|
|
const struct CMUnitTest tests[] = {
|
|
cmocka_unit_test(torture_decode_rc4_passwd_buffer),
|
|
cmocka_unit_test(torture_rc4_passwd_buffer),
|
|
+ cmocka_unit_test(torture_endode_decode_rc4_passwd_buffer),
|
|
};
|
|
|
|
if (argc == 2) {
|
|
--
|
|
2.23.0
|
|
|