CVE-2020-1472(ZeroLogon): libcli/auth: add netlogon_creds_random_challenge()
authorStefan Metzmacher <metze@samba.org>
Wed, 16 Sep 2020 14:04:57 +0000 (16:04 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 18 Sep 2020 11:27:15 +0000 (13:27 +0200)
It's good to have just a single isolated function that will generate
random challenges, in future we can add some logic in order to
avoid weak values, which are likely to be rejected by a server.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14497

Signed-off-by: Stefan Metzmacher <metze@samba.org>
libcli/auth/credentials.c
libcli/auth/proto.h

index c541eeff47037034a69dcd4daabadfa2929fa323..46259f39306c69e3edb0e898c26282e31fdf0bb2 100644 (file)
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
 
+void netlogon_creds_random_challenge(struct netr_Credential *challenge)
+{
+       ZERO_STRUCTP(challenge);
+       generate_random_buffer(challenge->data, sizeof(challenge->data));
+}
+
 static NTSTATUS netlogon_creds_step_crypt(struct netlogon_creds_CredentialState *creds,
                                          const struct netr_Credential *in,
                                          struct netr_Credential *out)
index 88f4a7c6c505544ecb31f860044e76f7d88794e7..396484a54370aca313b31f773669b808dccc470a 100644 (file)
@@ -13,6 +13,8 @@
 
 /* The following definitions come from /home/jeremy/src/samba/git/master/source3/../source4/../libcli/auth/credentials.c  */
 
+void netlogon_creds_random_challenge(struct netr_Credential *challenge);
+
 NTSTATUS netlogon_creds_des_encrypt_LMKey(struct netlogon_creds_CredentialState *creds,
                                          struct netr_LMSessionKey *key);
 NTSTATUS netlogon_creds_des_decrypt_LMKey(struct netlogon_creds_CredentialState *creds,