]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Fix bug #9037 - Name clash in MD5 cause...
authorJura Sasek <jiri.sasek@oracle.com>
Tue, 24 Jul 2012 18:58:58 +0000 (20:58 +0200)
committerKarolin Seeger <kseeger@samba.org>
Tue, 24 Jul 2012 18:58:58 +0000 (20:58 +0200)
... the "net ads join" fails on T4 (sun4v) systems on Solaris 10.

27 files changed:
lib/crypto/hmacmd5.c
lib/crypto/hmacmd5.h
lib/crypto/md5.h
lib/crypto/md5test.c
libcli/auth/credentials.c
libcli/auth/ntlmssp_server.c
libcli/auth/ntlmssp_sign.c
libcli/auth/schannel_sign.c
libcli/auth/smbencrypt.c
libcli/drsuapi/repl_decrypt.c
source3/Makefile.in
source3/configure.in
source3/libsmb/ntlmssp.c
source3/libsmb/smb_signing.c
source3/modules/vfs_streams_xattr.c
source3/rpc_client/init_samr.c
source3/web/swat.c
source4/auth/credentials/credentials_ntlm.c
source4/dsdb/samdb/ldb_modules/password_hash.c
source4/libcli/raw/smb_signing.c
source4/libnet/libnet_passwd.c
source4/ntp_signd/ntp_signd.c
source4/rpc_server/samr/samr_password.c
source4/torture/ntp/ntp_signd.c
source4/torture/rpc/samba3rpc.c
source4/torture/rpc/samlogon.c
source4/torture/rpc/samr.c

index cfbd428014baa8ae791e49517570dae077ab1045..2419bdb1ef1d8c7929c32b9aa3da016c167e2734 100644 (file)
@@ -36,7 +36,7 @@ _PUBLIC_ void hmac_md5_init_rfc2104(const uint8_t *key, int key_len, HMACMD5Cont
         /* if key is longer than 64 bytes reset it to key=MD5(key) */
         if (key_len > 64)
        {
-                struct MD5Context tctx;
+               MD5_CTX tctx;
 
                 MD5Init(&tctx);
                 MD5Update(&tctx, key, key_len);
@@ -91,7 +91,7 @@ _PUBLIC_ void hmac_md5_update(const uint8_t *text, int text_len, HMACMD5Context
 ***********************************************************************/
 _PUBLIC_ void hmac_md5_final(uint8_t *digest, HMACMD5Context *ctx)
 {
-        struct MD5Context ctx_o;
+       MD5_CTX ctx_o;
 
         MD5Final(digest, &ctx->ctx);          
 
index 91b8ca586c840cd3a07dc8f311b0c1ef845de4eb..1fc275016f1bdcbd9a202cab2f841e7175b12dde 100644 (file)
@@ -25,7 +25,7 @@
 
 typedef struct 
 {
-        struct MD5Context ctx;
+       MD5_CTX ctx;
         uint8_t k_ipad[65];    
         uint8_t k_opad[65];
 
index 4064d6f00396e82aae362978fcea68a01fd7f470..edddbac8f200765c6fb96e77fbed517f8a66b456 100644 (file)
@@ -5,15 +5,27 @@
 #define HEADER_MD5_H 
 #endif
 
+#ifdef HAVE_MD5_H
+/*
+ * Try to avoid clashes with Solaris MD5 implementation.
+ * ...where almost all implementations follows:
+ * "Schneier's Cryptography Classics Library"
+ */
+#include <md5.h>
+#else
+
 struct MD5Context {
        uint32_t buf[4];
        uint32_t bits[2];
        uint8_t in[64];
 };
+typedef struct MD5Context MD5_CTX;
 
 void MD5Init(struct MD5Context *context);
 void MD5Update(struct MD5Context *context, const uint8_t *buf,
               size_t len);
 void MD5Final(uint8_t digest[16], struct MD5Context *context);
 
+#endif /* !HAVE_MD5_H */
+
 #endif /* !MD5_H */
index 0457d4d4ea4b18e947cd6db75760ba6a76e4049e..256ddfa66ca3ecbeac70638331926d674ba8e301 100644 (file)
@@ -63,7 +63,7 @@ bool torture_local_crypto_md5(struct torture_context *torture)
        };
 
        for (i=0; i < ARRAY_SIZE(testarray); i++) {
-               struct MD5Context ctx;
+               MD5_CTX ctx;
                uint8_t md5[16];
                int e;
 
index 81304764a8c5a49aaa8f6bb43b242df0969ddc0b..35158cac2e71e1c0a0df05e354255db688f3b9fb 100644 (file)
@@ -69,7 +69,7 @@ static void netlogon_creds_init_128bit(struct netlogon_creds_CredentialState *cr
 {
        unsigned char zero[4], tmp[16];
        HMACMD5Context ctx;
-       struct MD5Context md5;
+       MD5_CTX md5;
 
        ZERO_STRUCT(creds->session_key);
 
index 802ac402b4969fb861117db53c0b182661b47ad0..0a759a89c1f04c670c4dc1ef5462f4204c220830 100644 (file)
@@ -359,7 +359,7 @@ static NTSTATUS ntlmssp_server_preauth(struct ntlmssp_state *ntlmssp_state,
        */
        if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
                if (ntlmssp_state->nt_resp.length == 24 && ntlmssp_state->lm_resp.length == 24) {
-                       struct MD5Context md5_session_nonce_ctx;
+                       MD5_CTX md5_session_nonce_ctx;
                        state->doing_ntlm2 = true;
 
                        memcpy(state->session_nonce, ntlmssp_state->internal_chal.data, 8);
index 42b459c6d47a0f0ee5b5d71b1d65e4e537f65794..454c448f09b2b36a4cef27309f1542cfb961330b 100644 (file)
@@ -51,7 +51,7 @@ static void calc_ntlmv2_key(uint8_t subkey[16],
                            DATA_BLOB session_key,
                            const char *constant)
 {
-       struct MD5Context ctx3;
+       MD5_CTX ctx3;
        MD5Init(&ctx3);
        MD5Update(&ctx3, session_key.data, session_key.length);
        MD5Update(&ctx3, (const uint8_t *)constant, strlen(constant)+1);
index eb605f4b07afaeee338aeeb4c445daaca7dd3e51..2d92283172e9de16a1aedc884475dba57ee9bdd8 100644 (file)
@@ -110,7 +110,7 @@ static void netsec_do_sign(struct schannel_state *state,
 {
        uint8_t packet_digest[16];
        static const uint8_t zeros[4];
-       struct MD5Context ctx;
+       MD5_CTX ctx;
 
        MD5Init(&ctx);
        MD5Update(&ctx, zeros, 4);
index f1451eaa1c0595811ae2da3f042b322970016839..ed1172b0478683590239a67ac4eb043992085999 100644 (file)
@@ -99,7 +99,7 @@ bool E_md4hash(const char *passwd, uint8_t p16[16])
 
 void E_md5hash(const uint8_t salt[16], const uint8_t nthash[16], uint8_t hash_out[16])
 {
-       struct MD5Context tctx;
+       MD5_CTX tctx;
        MD5Init(&tctx);
        MD5Update(&tctx, salt, 16);
        MD5Update(&tctx, nthash, 16);
@@ -623,7 +623,7 @@ bool decode_pw_buffer(TALLOC_CTX *ctx,
 
 void encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532], const DATA_BLOB *psession_key)
 {
-       struct MD5Context tctx;
+       MD5_CTX tctx;
        unsigned char key_out[16];
 
        /* Confounder is last 16 bytes. */
@@ -703,7 +703,7 @@ void encode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx,
                                        struct wkssvc_PasswordBuffer **pwd_buf)
 {
        uint8_t buffer[516];
-       struct MD5Context ctx;
+       MD5_CTX ctx;
        struct wkssvc_PasswordBuffer *my_pwd_buf = NULL;
        DATA_BLOB confounded_session_key;
        int confounder_len = 8;
@@ -741,7 +741,7 @@ WERROR decode_wkssvc_join_password_buffer(TALLOC_CTX *mem_ctx,
                                          char **pwd)
 {
        uint8_t buffer[516];
-       struct MD5Context ctx;
+       MD5_CTX ctx;
        size_t pwd_len;
 
        DATA_BLOB confounded_session_key;
index 6fff2fe5b1b2fadc88ee7e4a2cae47c5d2641f4b..00b8db8abc00c4fe15a5aa2b69cc3ff841da60a2 100644 (file)
@@ -39,7 +39,7 @@ WERROR drsuapi_decrypt_attribute_value(TALLOC_CTX *mem_ctx,
        DATA_BLOB confounder;
        DATA_BLOB enc_buffer;
 
-       struct MD5Context md5;
+       MD5_CTX md5;
        uint8_t _enc_key[16];
        DATA_BLOB enc_key;
 
@@ -198,7 +198,7 @@ static WERROR drsuapi_encrypt_attribute_value(TALLOC_CTX *mem_ctx,
        DATA_BLOB rid_crypt_out = data_blob(NULL, 0);
        DATA_BLOB confounder;
 
-       struct MD5Context md5;
+       MD5_CTX md5;
        uint8_t _enc_key[16];
        DATA_BLOB enc_key;
 
index 1a7ad8a30691a6f1739da23415de0c04574db781..f4e857970f012ddc3e2e65dbddc235fa792a7515 100644 (file)
@@ -430,7 +430,7 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
                   ../lib/util/blocking.o ../lib/util/rfc1738.o \
                   ../lib/util/select.o ../lib/util/util_pw.o
 
-CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
+CRYPTO_OBJ = ../lib/crypto/crc32.o @CRYPTO_MD5_OBJ@ \
                         ../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
                         ../lib/crypto/md4.o \
                         ../lib/crypto/sha256.o ../lib/crypto/hmacsha256.o \
index d8d3a1fd850a22cf09613dfa3fe343d5a5aebb98..373396a3707fca9b59d081a3d00dbf1e11aa028d 100644 (file)
@@ -751,6 +751,25 @@ AC_CHECK_HEADERS(xfs/libxfs.h)
 AC_CHECK_HEADERS(netgroup.h)
 AC_CHECK_HEADERS(linux/falloc.h)
 
+dnl check for OS implementation of md5 conformant to rfc1321
+AC_CHECK_HEADERS(md5.h)
+if test x"$ac_cv_header_md5_h" = x"yes"; then
+       AC_DEFINE(HAVE_MD5_H, 1,
+               [Whether md5.h is available.])
+       AC_CHECK_LIB(md5, MD5Update,
+           [
+               LIBS="${LIBS} -lmd5"
+               CRYPTO_MD5_OBJ=
+               AC_DEFINE(HAVE_LIBMD5, 1,
+                   [Whether libmd5 conformant to rfc1321 is available.])],
+           [
+               CRYPTO_MD5_OBJ="../lib/crypto/md5.o"])
+else
+       CRYPTO_MD5_OBJ="../lib/crypto/md5.o"
+fi
+AC_SUBST(CRYPTO_MD5_OBJ)
+
+
 AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
 #if HAVE_RPC_RPC_H
 #include <rpc/rpc.h>
index d000ed59c0348321ad8a9888607bdff877147a09..1de61897e0d589e6e09456f5c6ca665c349523e8 100644 (file)
@@ -612,7 +612,7 @@ noccache:
                        return NT_STATUS_NO_MEMORY;
                }
        } else if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
-               struct MD5Context md5_session_nonce_ctx;
+               MD5_CTX md5_session_nonce_ctx;
                uint8_t session_nonce[16];
                uint8_t session_nonce_hash[16];
                uint8_t user_session_key[16];
index c926b48e72504bf7c26ccd8ae73fe8d9a2c0dc82..3b89418673e203b7903c49a20e36eb66f9fbe145 100644 (file)
@@ -137,7 +137,7 @@ static void smb_signing_md5(const DATA_BLOB *mac_key,
 {
        const size_t offset_end_of_sig = (smb_ss_field + 8);
        uint8_t sequence_buf[8];
-       struct MD5Context md5_ctx;
+       MD5_CTX md5_ctx;
 
        /*
         * Firstly put the sequence number into the first 4 bytes.
index 08d8d14cbdf6511b066510c1c2903266ceeeb4fa..731c813f4d704678343268c2aa9df0e91379f587 100644 (file)
@@ -39,7 +39,7 @@ struct stream_io {
 
 static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
 {
-       struct MD5Context ctx;
+       MD5_CTX ctx;
         unsigned char hash[16];
        SMB_INO_T result;
        char *upper_sname;
index e3bb3015c26194176a0a3b847ca9c61ad11b090e..7f1a22908baac403eaa25691d866b6d43d29fafe 100644 (file)
@@ -34,7 +34,7 @@ void init_samr_CryptPasswordEx(const char *pwd,
        /* samr_CryptPasswordEx */
 
        uchar pwbuf[532];
-       struct MD5Context md5_ctx;
+       MD5_CTX md5_ctx;
        uint8_t confounder[16];
        DATA_BLOB confounded_session_key = data_blob(NULL, 16);
 
index e7c0378697ab9ae82b01df4dfd0473243fbc0a5b..1f6eb6c4d42bb85a6da64f372db93f85db58fa20 100644 (file)
@@ -151,7 +151,7 @@ static char *make_parm_name(const char *label)
 void get_xsrf_token(const char *username, const char *pass,
                    const char *formname, time_t xsrf_time, char token_str[33])
 {
-       struct MD5Context md5_ctx;
+       MD5_CTX md5_ctx;
        uint8_t token[16];
        int i;
 
index 7f4af4f08cd8183b829e5bf6b9f6aefe47e30cf4..78de8cd006ece6ca712950aeb7263d3ac203d5ef 100644 (file)
@@ -110,7 +110,7 @@ _PUBLIC_ NTSTATUS cli_credentials_get_ntlm_response(struct cli_credentials *cred
                /* LM Key is incompatible... */
                *flags &= ~CLI_CRED_LANMAN_AUTH;
        } else if (*flags & CLI_CRED_NTLM2) {
-               struct MD5Context md5_session_nonce_ctx;
+               MD5_CTX md5_session_nonce_ctx;
                uint8_t session_nonce[16];
                uint8_t session_nonce_hash[16];
                uint8_t user_session_key[16];
index 53d12d96df39ac0604b09dbe79c9d7225f2fb202..8d584a59e9aaa07dbf27a49899dc710cc07e3135 100644 (file)
@@ -1351,7 +1351,7 @@ static int setup_primary_wdigest(struct setup_password_fields_io *io,
        }
 
        for (i=0; i < ARRAY_SIZE(wdigest); i++) {
-               struct MD5Context md5;
+               MD5_CTX md5;
                MD5Init(&md5);
                if (wdigest[i].nt4dom) {
                        MD5Update(&md5, wdigest[i].nt4dom->data, wdigest[i].nt4dom->length);
index d6d53db32972d139e3f1001d13749776b195e900..baa64d431bdca16532ab89bbaf58e67aa1f795e6 100644 (file)
@@ -103,7 +103,7 @@ bool signing_good(struct smb_signing_context *sign_info,
 void sign_outgoing_message(struct smb_request_buffer *out, DATA_BLOB *mac_key, unsigned int seq_num) 
 {
        uint8_t calc_md5_mac[16];
-       struct MD5Context md5_ctx;
+       MD5_CTX md5_ctx;
 
        /*
         * Firstly put the sequence number into the first 4 bytes.
@@ -138,7 +138,7 @@ bool check_signed_incoming_message(struct smb_request_buffer *in, DATA_BLOB *mac
        uint8_t calc_md5_mac[16];
        uint8_t *server_sent_mac;
        uint8_t sequence_buf[8];
-       struct MD5Context md5_ctx;
+       MD5_CTX md5_ctx;
        const size_t offset_end_of_sig = (HDR_SS_FIELD + 8);
        int i;
        const int sign_range = 0;
index e1094f20571c3a9a8c57a9793db5158105472b79..861d746fd118c8db2ce1a2be6f4285c765856c2d 100644 (file)
@@ -274,7 +274,7 @@ static NTSTATUS libnet_SetPassword_samr_handle_26(struct libnet_context *ctx, TA
        DATA_BLOB session_key;
        DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);
        uint8_t confounder[16]; 
-       struct MD5Context md5;
+       MD5_CTX md5;
 
        if (r->samr_handle.in.info21) {
                return NT_STATUS_INVALID_PARAMETER_MIX;
@@ -330,7 +330,7 @@ static NTSTATUS libnet_SetPassword_samr_handle_25(struct libnet_context *ctx, TA
        DATA_BLOB session_key;
        DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);
        uint8_t confounder[16]; 
-       struct MD5Context md5;
+       MD5_CTX md5;
 
        if (!r->samr_handle.in.info21) {
                return NT_STATUS_INVALID_PARAMETER_MIX;
index 969d698a16f51777e4af3ead95c6917895df65d4..55e17672fd34567e4e7f6deb16d35faf7f363c7a 100644 (file)
@@ -107,7 +107,7 @@ static NTSTATUS ntp_signd_process(struct ntp_signd_connection *ntp_signd_conn,
        enum ndr_err_code ndr_err;
        struct ldb_result *res;
        const char *attrs[] = { "unicodePwd", "userAccountControl", "cn", NULL };
-       struct MD5Context ctx;
+       MD5_CTX ctx;
        struct samr_Password *nt_hash;
        uint32_t user_account_control;
        int ret;
index f2dcd05d8973e45eae3372707751c31b223b64a5..ee13a11dc9ea2973366297b01b57eb0f5e694ae1 100644 (file)
@@ -544,7 +544,7 @@ NTSTATUS samr_set_password_ex(struct dcesrv_call_state *dce_call,
        DATA_BLOB new_password;
        DATA_BLOB co_session_key;
        DATA_BLOB session_key = data_blob(NULL, 0);
-       struct MD5Context ctx;
+       MD5_CTX ctx;
 
        nt_status = dcesrv_fetch_session_key(dce_call->conn, &session_key);
        if (!NT_STATUS_IS_OK(nt_status)) {
index ce49d4fb852857a1f478358d3697e8c922ba4499..89eb1a0022a643075057a06800c1e734a301e65c 100644 (file)
@@ -78,7 +78,7 @@ static bool test_ntp_signd(struct torture_context *tctx,
        char *unix_address;
        int sys_errno;
 
-       struct MD5Context ctx;
+       MD5_CTX ctx;
        uint8_t sig[16];
        enum ndr_err_code ndr_err;
        bool ok;
index d0de30966c2af63fa32ea65a2f2543decce35264..26bed195122cd0fcbeb693c299f2f2f8d7ff051a 100644 (file)
@@ -774,7 +774,7 @@ static bool join3(struct torture_context *tctx,
                DATA_BLOB session_key;
                DATA_BLOB confounded_session_key = data_blob_talloc(
                        mem_ctx, NULL, 16);
-               struct MD5Context ctx;
+               MD5_CTX ctx;
                uint8_t confounder[16];
 
                ZERO_STRUCT(u_info);
index 0ba0d2633f04403a3ca07943535feccfb5e6c6ec..0b3dcd45fa0152173b04cce992f0783ad54be703 100644 (file)
@@ -1075,7 +1075,7 @@ static bool test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin
        uint8_t session_nonce_hash[16];
        uint8_t client_chall[8];
 
-       struct MD5Context md5_session_nonce_ctx;
+       MD5_CTX md5_session_nonce_ctx;
        HMACMD5Context hmac_ctx;
 
        ZERO_STRUCT(user_session_key);
index 53cb10abf28071435b5e7c6e55c9adce7c685764..7d9a1e2c44f31d9e091323c5a27f3935919c616f 100644 (file)
@@ -771,7 +771,7 @@ static bool test_SetUserPassEx(struct dcerpc_pipe *p, struct torture_context *tc
        uint8_t confounder[16];
        char *newpass;
        struct dcerpc_binding_handle *b = p->binding_handle;
-       struct MD5Context ctx;
+       MD5_CTX ctx;
        struct samr_GetUserPwInfo pwp;
        struct samr_PwInfo info;
        int policy_min_pw_len = 0;
@@ -856,7 +856,7 @@ static bool test_SetUserPass_25(struct dcerpc_pipe *p, struct torture_context *t
        bool ret = true;
        DATA_BLOB session_key;
        DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16);
-       struct MD5Context ctx;
+       MD5_CTX ctx;
        uint8_t confounder[16];
        char *newpass;
        struct dcerpc_binding_handle *b = p->binding_handle;
@@ -1140,7 +1140,7 @@ static bool test_SetUserPass_level_ex(struct dcerpc_pipe *p,
        bool ret = true;
        DATA_BLOB session_key;
        DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16);
-       struct MD5Context ctx;
+       MD5_CTX ctx;
        uint8_t confounder[16];
        char *newpass;
        struct dcerpc_binding_handle *b = p->binding_handle;
@@ -2458,7 +2458,7 @@ bool test_ChangePasswordRandomBytes(struct dcerpc_pipe *p, struct torture_contex
        DATA_BLOB session_key;
        DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16);
        uint8_t confounder[16];
-       struct MD5Context ctx;
+       MD5_CTX ctx;
 
        bool ret = true;
        struct lsa_String server, account;