components/samba/samba/patches/rfc1321-libmd5.patch
changeset 912 d98bdeebbbb3
equal deleted inserted replaced
911:eec41ee6c6ad 912:d98bdeebbbb3
       
     1 Solaris has md5 implementation conforming to rfc-1321.
       
     2 There is a name clash got failing on T4 (sun4v) systems.
       
     3 
       
     4 
       
     5 --- samba-3.6.6/source3/Makefile.in	Sun Jun 24 10:21:16 2012
       
     6 +++ a/source3/Makefile.in	Tue Jul 10 06:46:18 2012
       
     7 @@ -430,7 +430,7 @@
       
     8  		   ../lib/util/blocking.o ../lib/util/rfc1738.o \
       
     9  		   ../lib/util/select.o ../lib/util/util_pw.o
       
    10  
       
    11 -CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
       
    12 +CRYPTO_OBJ = ../lib/crypto/crc32.o @CRYPTO_MD5_OBJ@ \
       
    13  			 ../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
       
    14  			 ../lib/crypto/md4.o \
       
    15  			 ../lib/crypto/sha256.o ../lib/crypto/hmacsha256.o \
       
    16 --- samba-3.6.6/source3/configure.in	Sun Jun 24 10:21:16 2012
       
    17 +++ a/source3/configure.in	Tue Jul 10 08:59:06 2012
       
    18 @@ -751,6 +751,25 @@
       
    19  AC_CHECK_HEADERS(netgroup.h)
       
    20  AC_CHECK_HEADERS(linux/falloc.h)
       
    21  
       
    22 +dnl check for OS implementation of md5 conformant to rfc1321
       
    23 +AC_CHECK_HEADERS(md5.h)
       
    24 +if test x"$ac_cv_header_md5_h" = x"yes"; then
       
    25 +	AC_DEFINE(HAVE_MD5_H, 1,
       
    26 +		[Whether md5.h is available.])
       
    27 +	AC_CHECK_LIB(md5, MD5Update,
       
    28 +	    [
       
    29 +		LIBS="${LIBS} -lmd5"
       
    30 +		CRYPTO_MD5_OBJ=
       
    31 +		AC_DEFINE(HAVE_LIBMD5, 1,
       
    32 +		    [Whether libmd5 conformant to rfc1321 is available.])],
       
    33 +	    [
       
    34 +		CRYPTO_MD5_OBJ="../lib/crypto/md5.o"])
       
    35 +else
       
    36 +	CRYPTO_MD5_OBJ="../lib/crypto/md5.o"
       
    37 +fi
       
    38 +AC_SUBST(CRYPTO_MD5_OBJ)
       
    39 +
       
    40 +
       
    41  AC_CHECK_HEADERS(rpcsvc/yp_prot.h,,,[[
       
    42  #if HAVE_RPC_RPC_H
       
    43  #include <rpc/rpc.h>
       
    44 --- samba-3.6.6/lib/crypto/md5.h	Sun Jun 24 10:21:16 2012
       
    45 +++ a/lib/crypto/md5.h	Tue Jul 10 11:33:09 2012
       
    46 @@ -5,11 +5,21 @@
       
    47  #define HEADER_MD5_H 
       
    48  #endif
       
    49  
       
    50 +#ifdef HAVE_MD5_H
       
    51 +/*
       
    52 + * Try to avoid clashes with Solaris MD5 implementation.
       
    53 + * ...where almost all implementations follows:
       
    54 + * "Schneier's Cryptography Classics Library"
       
    55 + */
       
    56 +#include <md5.h>
       
    57 +#else
       
    58 +
       
    59  struct MD5Context {
       
    60  	uint32_t buf[4];
       
    61  	uint32_t bits[2];
       
    62  	uint8_t in[64];
       
    63  };
       
    64 +typedef struct MD5Context MD5_CTX;
       
    65  
       
    66  void MD5Init(struct MD5Context *context);
       
    67  void MD5Update(struct MD5Context *context, const uint8_t *buf,
       
    68 @@ -16,4 +26,6 @@
       
    69  	       size_t len);
       
    70  void MD5Final(uint8_t digest[16], struct MD5Context *context);
       
    71  
       
    72 +#endif /* !HAVE_MD5_H */
       
    73 +
       
    74  #endif /* !MD5_H */
       
    75 --- samba-3.6.6/lib/crypto/hmacmd5.h	Sun Jun 24 10:21:16 2012
       
    76 +++ a/lib/crypto/hmacmd5.h	Tue Jul 10 12:20:30 2012
       
    77 @@ -25,7 +25,7 @@
       
    78  
       
    79  typedef struct 
       
    80  {
       
    81 -        struct MD5Context ctx;
       
    82 +	MD5_CTX ctx;
       
    83          uint8_t k_ipad[65];    
       
    84          uint8_t k_opad[65];
       
    85  
       
    86 --- samba-3.6.6/lib/crypto/hmacmd5.c	Sun Jun 24 10:21:16 2012
       
    87 +++ a/lib/crypto/hmacmd5.c	Tue Jul 10 10:02:50 2012
       
    88 @@ -36,7 +36,7 @@
       
    89          /* if key is longer than 64 bytes reset it to key=MD5(key) */
       
    90          if (key_len > 64)
       
    91  	{
       
    92 -                struct MD5Context tctx;
       
    93 +		MD5_CTX tctx;
       
    94  
       
    95                  MD5Init(&tctx);
       
    96                  MD5Update(&tctx, key, key_len);
       
    97 @@ -91,7 +91,7 @@
       
    98  ***********************************************************************/
       
    99  _PUBLIC_ void hmac_md5_final(uint8_t *digest, HMACMD5Context *ctx)
       
   100  {
       
   101 -        struct MD5Context ctx_o;
       
   102 +	MD5_CTX ctx_o;
       
   103  
       
   104          MD5Final(digest, &ctx->ctx);          
       
   105  
       
   106 --- samba-3.6.6/lib/crypto/md5test.c	Sun Jun 24 10:21:16 2012
       
   107 +++ a/lib/crypto/md5test.c	Tue Jul 10 12:24:05 2012
       
   108 @@ -63,7 +63,7 @@
       
   109  	};
       
   110  
       
   111  	for (i=0; i < ARRAY_SIZE(testarray); i++) {
       
   112 -		struct MD5Context ctx;
       
   113 +		MD5_CTX ctx;
       
   114  		uint8_t md5[16];
       
   115  		int e;
       
   116  
       
   117 --- samba-3.6.6/source3/modules/vfs_streams_xattr.c	Sun Jun 24 10:21:16 2012
       
   118 +++ a/source3/modules/vfs_streams_xattr.c	Tue Jul 10 12:25:37 2012
       
   119 @@ -39,7 +39,7 @@
       
   120  
       
   121  static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
       
   122  {
       
   123 -	struct MD5Context ctx;
       
   124 +	MD5_CTX ctx;
       
   125          unsigned char hash[16];
       
   126  	SMB_INO_T result;
       
   127  	char *upper_sname;
       
   128 --- samba-3.6.6/source3/libsmb/smb_signing.c	Sun Jun 24 10:21:16 2012
       
   129 +++ a/source3/libsmb/smb_signing.c	Tue Jul 10 12:26:27 2012
       
   130 @@ -137,7 +137,7 @@
       
   131  {
       
   132  	const size_t offset_end_of_sig = (smb_ss_field + 8);
       
   133  	uint8_t sequence_buf[8];
       
   134 -	struct MD5Context md5_ctx;
       
   135 +	MD5_CTX md5_ctx;
       
   136  
       
   137  	/*
       
   138  	 * Firstly put the sequence number into the first 4 bytes.
       
   139 --- samba-3.6.6/source3/libsmb/ntlmssp.c	Sun Jun 24 10:21:16 2012
       
   140 +++ a/source3/libsmb/ntlmssp.c	Tue Jul 10 12:27:10 2012
       
   141 @@ -612,7 +612,7 @@
       
   142  			return NT_STATUS_NO_MEMORY;
       
   143  		}
       
   144  	} else if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
       
   145 -		struct MD5Context md5_session_nonce_ctx;
       
   146 +		MD5_CTX md5_session_nonce_ctx;
       
   147  		uint8_t session_nonce[16];
       
   148  		uint8_t session_nonce_hash[16];
       
   149  		uint8_t user_session_key[16];
       
   150 --- samba-3.6.6/source3/web/swat.c	Sun Jun 24 10:21:16 2012
       
   151 +++ a/source3/web/swat.c	Tue Jul 10 12:27:44 2012
       
   152 @@ -151,7 +151,7 @@
       
   153  void get_xsrf_token(const char *username, const char *pass,
       
   154  		    const char *formname, time_t xsrf_time, char token_str[33])
       
   155  {
       
   156 -	struct MD5Context md5_ctx;
       
   157 +	MD5_CTX md5_ctx;
       
   158  	uint8_t token[16];
       
   159  	int i;
       
   160  
       
   161 --- samba-3.6.6/source3/rpc_client/init_samr.c	Sun Jun 24 10:21:16 2012
       
   162 +++ a/source3/rpc_client/init_samr.c	Tue Jul 10 12:28:25 2012
       
   163 @@ -34,7 +34,7 @@
       
   164  	/* samr_CryptPasswordEx */
       
   165  
       
   166  	uchar pwbuf[532];
       
   167 -	struct MD5Context md5_ctx;
       
   168 +	MD5_CTX md5_ctx;
       
   169  	uint8_t confounder[16];
       
   170  	DATA_BLOB confounded_session_key = data_blob(NULL, 16);
       
   171  
       
   172 --- samba-3.6.6/libcli/auth/smbencrypt.c	Sun Jun 24 10:21:16 2012
       
   173 +++ a/libcli/auth/smbencrypt.c	Tue Jul 10 12:33:08 2012
       
   174 @@ -99,7 +99,7 @@
       
   175  
       
   176  void E_md5hash(const uint8_t salt[16], const uint8_t nthash[16], uint8_t hash_out[16])
       
   177  {
       
   178 -	struct MD5Context tctx;
       
   179 +	MD5_CTX tctx;
       
   180  	MD5Init(&tctx);
       
   181  	MD5Update(&tctx, salt, 16);
       
   182  	MD5Update(&tctx, nthash, 16);
       
   183 @@ -623,7 +623,7 @@
       
   184  
       
   185  void encode_or_decode_arc4_passwd_buffer(unsigned char pw_buf[532], const DATA_BLOB *psession_key)
       
   186  {
       
   187 -	struct MD5Context tctx;
       
   188 +	MD5_CTX tctx;
       
   189  	unsigned char key_out[16];
       
   190  
       
   191  	/* Confounder is last 16 bytes. */
       
   192 @@ -703,7 +703,7 @@
       
   193  					struct wkssvc_PasswordBuffer **pwd_buf)
       
   194  {
       
   195  	uint8_t buffer[516];
       
   196 -	struct MD5Context ctx;
       
   197 +	MD5_CTX ctx;
       
   198  	struct wkssvc_PasswordBuffer *my_pwd_buf = NULL;
       
   199  	DATA_BLOB confounded_session_key;
       
   200  	int confounder_len = 8;
       
   201 @@ -741,7 +741,7 @@
       
   202  					  char **pwd)
       
   203  {
       
   204  	uint8_t buffer[516];
       
   205 -	struct MD5Context ctx;
       
   206 +	MD5_CTX ctx;
       
   207  	size_t pwd_len;
       
   208  
       
   209  	DATA_BLOB confounded_session_key;
       
   210 --- samba-3.6.6/libcli/auth/schannel_sign.c	Sun Jun 24 10:21:16 2012
       
   211 +++ a/libcli/auth/schannel_sign.c	Tue Jul 10 12:36:36 2012
       
   212 @@ -110,7 +110,7 @@
       
   213  {
       
   214  	uint8_t packet_digest[16];
       
   215  	static const uint8_t zeros[4];
       
   216 -	struct MD5Context ctx;
       
   217 +	MD5_CTX ctx;
       
   218  
       
   219  	MD5Init(&ctx);
       
   220  	MD5Update(&ctx, zeros, 4);
       
   221 --- samba-3.6.6/libcli/auth/ntlmssp_server.c	Sun Jun 24 10:21:16 2012
       
   222 +++ a/libcli/auth/ntlmssp_server.c	Tue Jul 10 12:38:03 2012
       
   223 @@ -359,7 +359,7 @@
       
   224  	*/
       
   225  	if (ntlmssp_state->neg_flags & NTLMSSP_NEGOTIATE_NTLM2) {
       
   226  		if (ntlmssp_state->nt_resp.length == 24 && ntlmssp_state->lm_resp.length == 24) {
       
   227 -			struct MD5Context md5_session_nonce_ctx;
       
   228 +			MD5_CTX md5_session_nonce_ctx;
       
   229  			state->doing_ntlm2 = true;
       
   230  
       
   231  			memcpy(state->session_nonce, ntlmssp_state->internal_chal.data, 8);
       
   232 --- samba-3.6.6/libcli/auth/ntlmssp_sign.c	Sun Jun 24 10:21:16 2012
       
   233 +++ a/libcli/auth/ntlmssp_sign.c	Tue Jul 10 12:39:59 2012
       
   234 @@ -51,7 +51,7 @@
       
   235  			    DATA_BLOB session_key,
       
   236  			    const char *constant)
       
   237  {
       
   238 -	struct MD5Context ctx3;
       
   239 +	MD5_CTX ctx3;
       
   240  	MD5Init(&ctx3);
       
   241  	MD5Update(&ctx3, session_key.data, session_key.length);
       
   242  	MD5Update(&ctx3, (const uint8_t *)constant, strlen(constant)+1);
       
   243 --- samba-3.6.6/libcli/auth/credentials.c	Sun Jun 24 10:21:16 2012
       
   244 +++ a/libcli/auth/credentials.c	Tue Jul 10 12:43:38 2012
       
   245 @@ -69,7 +69,7 @@
       
   246  {
       
   247  	unsigned char zero[4], tmp[16];
       
   248  	HMACMD5Context ctx;
       
   249 -	struct MD5Context md5;
       
   250 +	MD5_CTX md5;
       
   251  
       
   252  	ZERO_STRUCT(creds->session_key);
       
   253  
       
   254 --- samba-3.6.6/libcli/drsuapi/repl_decrypt.c	Sun Jun 24 10:21:16 2012
       
   255 +++ a/libcli/drsuapi/repl_decrypt.c	Tue Jul 10 12:45:40 2012
       
   256 @@ -39,7 +39,7 @@
       
   257  	DATA_BLOB confounder;
       
   258  	DATA_BLOB enc_buffer;
       
   259  
       
   260 -	struct MD5Context md5;
       
   261 +	MD5_CTX md5;
       
   262  	uint8_t _enc_key[16];
       
   263  	DATA_BLOB enc_key;
       
   264  
       
   265 @@ -198,7 +198,7 @@
       
   266  	DATA_BLOB rid_crypt_out = data_blob(NULL, 0);
       
   267  	DATA_BLOB confounder;
       
   268  
       
   269 -	struct MD5Context md5;
       
   270 +	MD5_CTX md5;
       
   271  	uint8_t _enc_key[16];
       
   272  	DATA_BLOB enc_key;
       
   273  
       
   274 --- samba-3.6.6/source4/libcli/raw/smb_signing.c	Sun Jun 24 10:21:16 2012
       
   275 +++ a/source4/libcli/raw/smb_signing.c	Tue Jul 10 13:27:44 2012
       
   276 @@ -103,7 +103,7 @@
       
   277  void sign_outgoing_message(struct smb_request_buffer *out, DATA_BLOB *mac_key, unsigned int seq_num) 
       
   278  {
       
   279  	uint8_t calc_md5_mac[16];
       
   280 -	struct MD5Context md5_ctx;
       
   281 +	MD5_CTX md5_ctx;
       
   282  
       
   283  	/*
       
   284  	 * Firstly put the sequence number into the first 4 bytes.
       
   285 @@ -138,7 +138,7 @@
       
   286  	uint8_t calc_md5_mac[16];
       
   287  	uint8_t *server_sent_mac;
       
   288  	uint8_t sequence_buf[8];
       
   289 -	struct MD5Context md5_ctx;
       
   290 +	MD5_CTX md5_ctx;
       
   291  	const size_t offset_end_of_sig = (HDR_SS_FIELD + 8);
       
   292  	int i;
       
   293  	const int sign_range = 0;
       
   294 --- samba-3.6.6/source4/ntp_signd/ntp_signd.c	Sun Jun 24 10:21:16 2012
       
   295 +++ a/source4/ntp_signd/ntp_signd.c	Tue Jul 10 13:29:16 2012
       
   296 @@ -107,7 +107,7 @@
       
   297  	enum ndr_err_code ndr_err;
       
   298  	struct ldb_result *res;
       
   299  	const char *attrs[] = { "unicodePwd", "userAccountControl", "cn", NULL };
       
   300 -	struct MD5Context ctx;
       
   301 +	MD5_CTX ctx;
       
   302  	struct samr_Password *nt_hash;
       
   303  	uint32_t user_account_control;
       
   304  	int ret;
       
   305 --- samba-3.6.6/source4/libnet/libnet_passwd.c	Sun Jun 24 10:21:16 2012
       
   306 +++ a/source4/libnet/libnet_passwd.c	Tue Jul 10 13:30:45 2012
       
   307 @@ -274,7 +274,7 @@
       
   308  	DATA_BLOB session_key;
       
   309  	DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);
       
   310  	uint8_t confounder[16];	
       
   311 -	struct MD5Context md5;
       
   312 +	MD5_CTX md5;
       
   313  
       
   314  	if (r->samr_handle.in.info21) {
       
   315  		return NT_STATUS_INVALID_PARAMETER_MIX;
       
   316 @@ -330,7 +330,7 @@
       
   317  	DATA_BLOB session_key;
       
   318  	DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16);
       
   319  	uint8_t confounder[16];	
       
   320 -	struct MD5Context md5;
       
   321 +	MD5_CTX md5;
       
   322  
       
   323  	if (!r->samr_handle.in.info21) {
       
   324  		return NT_STATUS_INVALID_PARAMETER_MIX;
       
   325 --- samba-3.6.6/source4/torture/ntp/ntp_signd.c	Sun Jun 24 10:21:16 2012
       
   326 +++ a/source4/torture/ntp/ntp_signd.c	Tue Jul 10 13:32:00 2012
       
   327 @@ -78,7 +78,7 @@
       
   328  	char *unix_address;
       
   329  	int sys_errno;
       
   330  
       
   331 -	struct MD5Context ctx;
       
   332 +	MD5_CTX ctx;
       
   333  	uint8_t sig[16];
       
   334  	enum ndr_err_code ndr_err;
       
   335  	bool ok;
       
   336 --- samba-3.6.6/source4/torture/rpc/samr.c	Sun Jun 24 10:21:16 2012
       
   337 +++ a/source4/torture/rpc/samr.c	Tue Jul 10 13:33:48 2012
       
   338 @@ -771,7 +771,7 @@
       
   339  	uint8_t confounder[16];
       
   340  	char *newpass;
       
   341  	struct dcerpc_binding_handle *b = p->binding_handle;
       
   342 -	struct MD5Context ctx;
       
   343 +	MD5_CTX ctx;
       
   344  	struct samr_GetUserPwInfo pwp;
       
   345  	struct samr_PwInfo info;
       
   346  	int policy_min_pw_len = 0;
       
   347 @@ -856,7 +856,7 @@
       
   348  	bool ret = true;
       
   349  	DATA_BLOB session_key;
       
   350  	DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16);
       
   351 -	struct MD5Context ctx;
       
   352 +	MD5_CTX ctx;
       
   353  	uint8_t confounder[16];
       
   354  	char *newpass;
       
   355  	struct dcerpc_binding_handle *b = p->binding_handle;
       
   356 @@ -1140,7 +1140,7 @@
       
   357  	bool ret = true;
       
   358  	DATA_BLOB session_key;
       
   359  	DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16);
       
   360 -	struct MD5Context ctx;
       
   361 +	MD5_CTX ctx;
       
   362  	uint8_t confounder[16];
       
   363  	char *newpass;
       
   364  	struct dcerpc_binding_handle *b = p->binding_handle;
       
   365 @@ -2458,7 +2458,7 @@
       
   366  	DATA_BLOB session_key;
       
   367  	DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16);
       
   368  	uint8_t confounder[16];
       
   369 -	struct MD5Context ctx;
       
   370 +	MD5_CTX ctx;
       
   371  
       
   372  	bool ret = true;
       
   373  	struct lsa_String server, account;
       
   374 --- samba-3.6.6/source4/torture/rpc/samba3rpc.c	Sun Jun 24 10:21:16 2012
       
   375 +++ a/source4/torture/rpc/samba3rpc.c	Tue Jul 10 13:34:47 2012
       
   376 @@ -774,7 +774,7 @@
       
   377  		DATA_BLOB session_key;
       
   378  		DATA_BLOB confounded_session_key = data_blob_talloc(
       
   379  			mem_ctx, NULL, 16);
       
   380 -		struct MD5Context ctx;
       
   381 +		MD5_CTX ctx;
       
   382  		uint8_t confounder[16];
       
   383  
       
   384  		ZERO_STRUCT(u_info);
       
   385 --- samba-3.6.6/source4/torture/rpc/samlogon.c	Sun Jun 24 10:21:16 2012
       
   386 +++ a/source4/torture/rpc/samlogon.c	Tue Jul 10 13:36:41 2012
       
   387 @@ -1075,7 +1075,7 @@
       
   388  	uint8_t session_nonce_hash[16];
       
   389  	uint8_t client_chall[8];
       
   390  
       
   391 -	struct MD5Context md5_session_nonce_ctx;
       
   392 +	MD5_CTX md5_session_nonce_ctx;
       
   393  	HMACMD5Context hmac_ctx;
       
   394  
       
   395  	ZERO_STRUCT(user_session_key);
       
   396 --- samba-3.6.6/source4/auth/credentials/credentials_ntlm.c	Sun Jun 24 10:21:16 2012
       
   397 +++ a/source4/auth/credentials/credentials_ntlm.c	Tue Jul 10 13:38:44 2012
       
   398 @@ -110,7 +110,7 @@
       
   399  		/* LM Key is incompatible... */
       
   400  		*flags &= ~CLI_CRED_LANMAN_AUTH;
       
   401  	} else if (*flags & CLI_CRED_NTLM2) {
       
   402 -		struct MD5Context md5_session_nonce_ctx;
       
   403 +		MD5_CTX md5_session_nonce_ctx;
       
   404  		uint8_t session_nonce[16];
       
   405  		uint8_t session_nonce_hash[16];
       
   406  		uint8_t user_session_key[16];
       
   407 --- samba-3.6.6/source4/dsdb/samdb/ldb_modules/password_hash.c	Sun Jun 24 10:21:16 2012
       
   408 +++ a/source4/dsdb/samdb/ldb_modules/password_hash.c	Tue Jul 10 13:40:01 2012
       
   409 @@ -1351,7 +1351,7 @@
       
   410  	}
       
   411  
       
   412  	for (i=0; i < ARRAY_SIZE(wdigest); i++) {
       
   413 -		struct MD5Context md5;
       
   414 +		MD5_CTX md5;
       
   415  		MD5Init(&md5);
       
   416  		if (wdigest[i].nt4dom) {
       
   417  			MD5Update(&md5, wdigest[i].nt4dom->data, wdigest[i].nt4dom->length);
       
   418 --- samba-3.6.6/source4/rpc_server/samr/samr_password.c	Sun Jun 24 10:21:16 2012
       
   419 +++ a/source4/rpc_server/samr/samr_password.c	Tue Jul 10 13:42:32 2012
       
   420 @@ -544,7 +544,7 @@
       
   421  	DATA_BLOB new_password;
       
   422  	DATA_BLOB co_session_key;
       
   423  	DATA_BLOB session_key = data_blob(NULL, 0);
       
   424 -	struct MD5Context ctx;
       
   425 +	MD5_CTX ctx;
       
   426  
       
   427  	nt_status = dcesrv_fetch_session_key(dce_call->conn, &session_key);
       
   428  	if (!NT_STATUS_IS_OK(nt_status)) {