]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli:auth: Return NTSTATUS for SMBOWFencrypt_ntv2()
authorAndreas Schneider <asn@samba.org>
Wed, 13 Nov 2019 11:48:18 +0000 (12:48 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 14 Nov 2019 08:01:43 +0000 (08:01 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14195

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/auth/proto.h
libcli/auth/smbencrypt.c

index 4c20783124bdd4df20df565797fe2feb01afcf45..52a33d8d4578f07cf6314abe844ab29008d5cf87 100644 (file)
@@ -135,10 +135,10 @@ bool ntv2_owf_gen(const uint8_t owf[16],
 void SMBOWFencrypt(const uint8_t passwd[16], const uint8_t *c8, uint8_t p24[24]);
 void SMBNTencrypt_hash(const uint8_t nt_hash[16], const uint8_t *c8, uint8_t *p24);
 void SMBNTencrypt(const char *passwd, const uint8_t *c8, uint8_t *p24);
-void SMBOWFencrypt_ntv2(const uint8_t kr[16],
-                       const DATA_BLOB *srv_chal,
-                       const DATA_BLOB *smbcli_chal,
-                       uint8_t resp_buf[16]);
+NTSTATUS SMBOWFencrypt_ntv2(const uint8_t kr[16],
+                           const DATA_BLOB *srv_chal,
+                           const DATA_BLOB *smbcli_chal,
+                           uint8_t resp_buf[16]);
 NTSTATUS SMBsesskeygen_ntv2(const uint8_t kr[16],
                            const uint8_t *nt_resp,
                            uint8_t sess_key[16]);
index 1412274dd21e65ee456893906415fa168298a4b9..e7ed0630cdc5d7f9c9adc5684bcc7c70fad84d88 100644 (file)
@@ -334,12 +334,13 @@ void SMBNTencrypt(const char *passwd, const uint8_t *c8, uint8_t *p24)
 
 
 /* Does the md5 encryption from the Key Response for NTLMv2. */
-void SMBOWFencrypt_ntv2(const uint8_t kr[16],
-                       const DATA_BLOB *srv_chal,
-                       const DATA_BLOB *smbcli_chal,
-                       uint8_t resp_buf[16])
+NTSTATUS SMBOWFencrypt_ntv2(const uint8_t kr[16],
+                           const DATA_BLOB *srv_chal,
+                           const DATA_BLOB *smbcli_chal,
+                           uint8_t resp_buf[16])
 {
        gnutls_hmac_hd_t hmac_hnd = NULL;
+       NTSTATUS status;
        int rc;
 
        rc = gnutls_hmac_init(&hmac_hnd,
@@ -347,27 +348,31 @@ void SMBOWFencrypt_ntv2(const uint8_t kr[16],
                              kr,
                              16);
        if (rc < 0) {
-               return;
+               return gnutls_error_to_ntstatus(rc, NT_STATUS_HMAC_NOT_SUPPORTED);
        }
 
        rc = gnutls_hmac(hmac_hnd, srv_chal->data, srv_chal->length);
        if (rc < 0) {
-               return;
+               status = gnutls_error_to_ntstatus(rc, NT_STATUS_HMAC_NOT_SUPPORTED);
+               goto out;
        }
        rc = gnutls_hmac(hmac_hnd, smbcli_chal->data, smbcli_chal->length);
        if (rc < 0) {
-               gnutls_hmac_deinit(hmac_hnd, NULL);
-               return;
+               status = gnutls_error_to_ntstatus(rc, NT_STATUS_HMAC_NOT_SUPPORTED);
+               goto out;
        }
 
-       gnutls_hmac_deinit(hmac_hnd, resp_buf);
-
 #ifdef DEBUG_PASSWORD
        DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, smbcli_chal, resp_buf\n"));
        dump_data(100, srv_chal->data, srv_chal->length);
        dump_data(100, smbcli_chal->data, smbcli_chal->length);
        dump_data(100, resp_buf, 16);
 #endif
+
+       status = NT_STATUS_OK;
+out:
+       gnutls_hmac_deinit(hmac_hnd, resp_buf);
+       return status;
 }
 
 NTSTATUS SMBsesskeygen_ntv2(const uint8_t kr[16],