]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbdes: convert E_P16() to use gnutls
authorIsaac Boukris <iboukris@gmail.com>
Thu, 7 Nov 2019 15:16:26 +0000 (16:16 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 10 Dec 2019 00:30:30 +0000 (00:30 +0000)
Signed-off-by: Isaac Boukris <iboukris@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/auth/proto.h
libcli/auth/smbdes.c
libcli/auth/smbencrypt.c
libcli/auth/tests/test_gnutls.c

index 7dad549fc43c8e8873fee054dc29284237424ce5..9ae62efca31dd0583ab207288efdce7038d315ce 100644 (file)
@@ -223,7 +223,7 @@ WERROR decode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx,
 void des_crypt56(uint8_t out[8], const uint8_t in[8], const uint8_t key[7], int forw);
 int des_crypt56_gnutls(uint8_t out[8], const uint8_t in[8], const uint8_t key[7],
                       enum samba_gnutls_direction encrypt);
-void E_P16(const uint8_t *p14,uint8_t *p16);
+int E_P16(const uint8_t *p14,uint8_t *p16);
 void E_P24(const uint8_t *p21, const uint8_t *c8, uint8_t *p24);
 void D_P16(const uint8_t *p14, const uint8_t *in, uint8_t *out);
 void E_old_pw_hash( uint8_t *p14, const uint8_t *in, uint8_t *out);
index fe397592fbb34e7e8db5d4d0f680c48c346c6067..c0d1027817911a7f558c97b812854ce691394b68 100644 (file)
@@ -361,11 +361,17 @@ void des_crypt56(uint8_t out[8], const uint8_t in[8], const uint8_t key[7], int
        }
 }
 
-void E_P16(const uint8_t *p14,uint8_t *p16)
+int E_P16(const uint8_t *p14,uint8_t *p16)
 {
        const uint8_t sp8[8] = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
-       des_crypt56(p16, sp8, p14, 1);
-       des_crypt56(p16+8, sp8, p14+7, 1);
+       int ret;
+
+       ret = des_crypt56_gnutls(p16, sp8, p14, SAMBA_GNUTLS_ENCRYPT);
+       if (ret != 0) {
+               return ret;
+       }
+
+       return des_crypt56_gnutls(p16+8, sp8, p14+7, SAMBA_GNUTLS_ENCRYPT);
 }
 
 void E_P24(const uint8_t *p21, const uint8_t *c8, uint8_t *p24)
index b1d4f985ecfcd4f1caa3c6f7d09a8d942ac295a9..f2f446eda97c6889aa7ab7b8364f2748869f0566 100644 (file)
@@ -105,6 +105,7 @@ bool E_md4hash(const char *passwd, uint8_t p16[16])
 bool E_deshash(const char *passwd, uint8_t p16[16])
 {
        bool ret;
+       int rc;
        uint8_t dospwd[14];
        TALLOC_CTX *frame = talloc_stackframe();
 
@@ -133,7 +134,10 @@ bool E_deshash(const char *passwd, uint8_t p16[16])
         * case to avoid returning a fixed 'password' buffer, but
         * callers should not use it when E_deshash returns false */
 
-       E_P16((const uint8_t *)dospwd, p16);
+       rc = E_P16((const uint8_t *)dospwd, p16);
+       if (rc != 0) {
+               ret = false;
+       }
 
        ZERO_STRUCT(dospwd);
 
index f603fa819e8a721033fee7a63337d575d03094e6..a6e8fd5b352f3738f8f2f30eced4c39ba7a78db3 100644 (file)
@@ -274,7 +274,10 @@ static void torture_gnutls_E_P16(void **state)
                0x1D, 0xEA, 0xD9, 0xFF, 0xB0, 0xA9, 0xA4, 0x05
        };
 
-       E_P16(key, buffer);
+       int rc;
+
+       rc = E_P16(key, buffer);
+       assert_int_equal(rc, 0);
        assert_memory_equal(buffer, crypt_expected, 16);
 }