libcli:auth: Use GnuTLS MD5 HMAC in SMBOWFencrypt_ntv2()
authorAndreas Schneider <asn@samba.org>
Wed, 15 May 2019 06:05:38 +0000 (08:05 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 21 May 2019 00:03:20 +0000 (00:03 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/auth/smbencrypt.c

index 59f08b21dd8d5eaf88596fa688f4e4f45e66a170..1c9c7f82270b95bc1a93a5361875622c686769b2 100644 (file)
@@ -339,12 +339,28 @@ void SMBOWFencrypt_ntv2(const uint8_t kr[16],
                        const DATA_BLOB *smbcli_chal,
                        uint8_t resp_buf[16])
 {
-       HMACMD5Context ctx;
+       gnutls_hmac_hd_t hmac_hnd = NULL;
+       int rc;
 
-       hmac_md5_init_limK_to_64(kr, 16, &ctx);
-       hmac_md5_update(srv_chal->data, srv_chal->length, &ctx);
-       hmac_md5_update(smbcli_chal->data, smbcli_chal->length, &ctx);
-       hmac_md5_final(resp_buf, &ctx);
+       rc = gnutls_hmac_init(&hmac_hnd,
+                             GNUTLS_MAC_MD5,
+                             kr,
+                             16);
+       if (rc < 0) {
+               return;
+       }
+
+       rc = gnutls_hmac(hmac_hnd, srv_chal->data, srv_chal->length);
+       if (rc < 0) {
+               return;
+       }
+       rc = gnutls_hmac(hmac_hnd, smbcli_chal->data, smbcli_chal->length);
+       if (rc < 0) {
+               gnutls_hmac_deinit(hmac_hnd, NULL);
+               return;
+       }
+
+       gnutls_hmac_deinit(hmac_hnd, resp_buf);
 
 #ifdef DEBUG_PASSWORD
        DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, smbcli_chal, resp_buf\n"));