@@ -68,125 +68,6 @@ void ksmbd_copy_gss_neg_header(void *buf)
68
68
memcpy (buf , NEGOTIATE_GSS_HEADER , AUTH_GSS_LENGTH );
69
69
}
70
70
71
- static void
72
- str_to_key (unsigned char * str , unsigned char * key )
73
- {
74
- int i ;
75
-
76
- key [0 ] = str [0 ] >> 1 ;
77
- key [1 ] = ((str [0 ] & 0x01 ) << 6 ) | (str [1 ] >> 2 );
78
- key [2 ] = ((str [1 ] & 0x03 ) << 5 ) | (str [2 ] >> 3 );
79
- key [3 ] = ((str [2 ] & 0x07 ) << 4 ) | (str [3 ] >> 4 );
80
- key [4 ] = ((str [3 ] & 0x0F ) << 3 ) | (str [4 ] >> 5 );
81
- key [5 ] = ((str [4 ] & 0x1F ) << 2 ) | (str [5 ] >> 6 );
82
- key [6 ] = ((str [5 ] & 0x3F ) << 1 ) | (str [6 ] >> 7 );
83
- key [7 ] = str [6 ] & 0x7F ;
84
- for (i = 0 ; i < 8 ; i ++ )
85
- key [i ] = (key [i ] << 1 );
86
- }
87
-
88
- static int
89
- smbhash (unsigned char * out , const unsigned char * in , unsigned char * key )
90
- {
91
- unsigned char key2 [8 ];
92
- struct des_ctx ctx ;
93
-
94
- if (fips_enabled ) {
95
- ksmbd_debug (AUTH , "FIPS compliance enabled: DES not permitted\n" );
96
- return - ENOENT ;
97
- }
98
-
99
- str_to_key (key , key2 );
100
- des_expand_key (& ctx , key2 , DES_KEY_SIZE );
101
- des_encrypt (& ctx , out , in );
102
- memzero_explicit (& ctx , sizeof (ctx ));
103
- return 0 ;
104
- }
105
-
106
- static int ksmbd_enc_p24 (unsigned char * p21 , const unsigned char * c8 , unsigned char * p24 )
107
- {
108
- int rc ;
109
-
110
- rc = smbhash (p24 , c8 , p21 );
111
- if (rc )
112
- return rc ;
113
- rc = smbhash (p24 + 8 , c8 , p21 + 7 );
114
- if (rc )
115
- return rc ;
116
- return smbhash (p24 + 16 , c8 , p21 + 14 );
117
- }
118
-
119
- /* produce a md4 message digest from data of length n bytes */
120
- static int ksmbd_enc_md4 (unsigned char * md4_hash , unsigned char * link_str ,
121
- int link_len )
122
- {
123
- int rc ;
124
- struct ksmbd_crypto_ctx * ctx ;
125
-
126
- ctx = ksmbd_crypto_ctx_find_md4 ();
127
- if (!ctx ) {
128
- ksmbd_debug (AUTH , "Crypto md4 allocation error\n" );
129
- return - ENOMEM ;
130
- }
131
-
132
- rc = crypto_shash_init (CRYPTO_MD4 (ctx ));
133
- if (rc ) {
134
- ksmbd_debug (AUTH , "Could not init md4 shash\n" );
135
- goto out ;
136
- }
137
-
138
- rc = crypto_shash_update (CRYPTO_MD4 (ctx ), link_str , link_len );
139
- if (rc ) {
140
- ksmbd_debug (AUTH , "Could not update with link_str\n" );
141
- goto out ;
142
- }
143
-
144
- rc = crypto_shash_final (CRYPTO_MD4 (ctx ), md4_hash );
145
- if (rc )
146
- ksmbd_debug (AUTH , "Could not generate md4 hash\n" );
147
- out :
148
- ksmbd_release_crypto_ctx (ctx );
149
- return rc ;
150
- }
151
-
152
- static int ksmbd_enc_update_sess_key (unsigned char * md5_hash , char * nonce ,
153
- char * server_challenge , int len )
154
- {
155
- int rc ;
156
- struct ksmbd_crypto_ctx * ctx ;
157
-
158
- ctx = ksmbd_crypto_ctx_find_md5 ();
159
- if (!ctx ) {
160
- ksmbd_debug (AUTH , "Crypto md5 allocation error\n" );
161
- return - ENOMEM ;
162
- }
163
-
164
- rc = crypto_shash_init (CRYPTO_MD5 (ctx ));
165
- if (rc ) {
166
- ksmbd_debug (AUTH , "Could not init md5 shash\n" );
167
- goto out ;
168
- }
169
-
170
- rc = crypto_shash_update (CRYPTO_MD5 (ctx ), server_challenge , len );
171
- if (rc ) {
172
- ksmbd_debug (AUTH , "Could not update with challenge\n" );
173
- goto out ;
174
- }
175
-
176
- rc = crypto_shash_update (CRYPTO_MD5 (ctx ), nonce , len );
177
- if (rc ) {
178
- ksmbd_debug (AUTH , "Could not update with nonce\n" );
179
- goto out ;
180
- }
181
-
182
- rc = crypto_shash_final (CRYPTO_MD5 (ctx ), md5_hash );
183
- if (rc )
184
- ksmbd_debug (AUTH , "Could not generate md5 hash\n" );
185
- out :
186
- ksmbd_release_crypto_ctx (ctx );
187
- return rc ;
188
- }
189
-
190
71
/**
191
72
* ksmbd_gen_sess_key() - function to generate session key
192
73
* @sess: session of connection
@@ -324,43 +205,6 @@ static int calc_ntlmv2_hash(struct ksmbd_session *sess, char *ntlmv2_hash,
324
205
return ret ;
325
206
}
326
207
327
- /**
328
- * ksmbd_auth_ntlm() - NTLM authentication handler
329
- * @sess: session of connection
330
- * @pw_buf: NTLM challenge response
331
- * @passkey: user password
332
- *
333
- * Return: 0 on success, error number on error
334
- */
335
- int ksmbd_auth_ntlm (struct ksmbd_session * sess , char * pw_buf )
336
- {
337
- int rc ;
338
- unsigned char p21 [21 ];
339
- char key [CIFS_AUTH_RESP_SIZE ];
340
-
341
- memset (p21 , '\0' , 21 );
342
- memcpy (p21 , user_passkey (sess -> user ), CIFS_NTHASH_SIZE );
343
- rc = ksmbd_enc_p24 (p21 , sess -> ntlmssp .cryptkey , key );
344
- if (rc ) {
345
- pr_err ("password processing failed\n" );
346
- return rc ;
347
- }
348
-
349
- ksmbd_enc_md4 (sess -> sess_key , user_passkey (sess -> user ),
350
- CIFS_SMB1_SESSKEY_SIZE );
351
- memcpy (sess -> sess_key + CIFS_SMB1_SESSKEY_SIZE , key ,
352
- CIFS_AUTH_RESP_SIZE );
353
- sess -> sequence_number = 1 ;
354
-
355
- if (strncmp (pw_buf , key , CIFS_AUTH_RESP_SIZE ) != 0 ) {
356
- ksmbd_debug (AUTH , "ntlmv1 authentication failed\n" );
357
- return - EINVAL ;
358
- }
359
-
360
- ksmbd_debug (AUTH , "ntlmv1 authentication pass\n" );
361
- return 0 ;
362
- }
363
-
364
208
/**
365
209
* ksmbd_auth_ntlmv2() - NTLMv2 authentication handler
366
210
* @sess: session of connection
@@ -441,44 +285,6 @@ int ksmbd_auth_ntlmv2(struct ksmbd_session *sess, struct ntlmv2_resp *ntlmv2,
441
285
return rc ;
442
286
}
443
287
444
- /**
445
- * __ksmbd_auth_ntlmv2() - NTLM2(extended security) authentication handler
446
- * @sess: session of connection
447
- * @client_nonce: client nonce from LM response.
448
- * @ntlm_resp: ntlm response data from client.
449
- *
450
- * Return: 0 on success, error number on error
451
- */
452
- static int __ksmbd_auth_ntlmv2 (struct ksmbd_session * sess , char * client_nonce ,
453
- char * ntlm_resp )
454
- {
455
- char sess_key [CIFS_SMB1_SESSKEY_SIZE ] = {0 };
456
- int rc ;
457
- unsigned char p21 [21 ];
458
- char key [CIFS_AUTH_RESP_SIZE ];
459
-
460
- rc = ksmbd_enc_update_sess_key (sess_key ,
461
- client_nonce ,
462
- (char * )sess -> ntlmssp .cryptkey , 8 );
463
- if (rc ) {
464
- pr_err ("password processing failed\n" );
465
- goto out ;
466
- }
467
-
468
- memset (p21 , '\0' , 21 );
469
- memcpy (p21 , user_passkey (sess -> user ), CIFS_NTHASH_SIZE );
470
- rc = ksmbd_enc_p24 (p21 , sess_key , key );
471
- if (rc ) {
472
- pr_err ("password processing failed\n" );
473
- goto out ;
474
- }
475
-
476
- if (memcmp (ntlm_resp , key , CIFS_AUTH_RESP_SIZE ) != 0 )
477
- rc = - EINVAL ;
478
- out :
479
- return rc ;
480
- }
481
-
482
288
/**
483
289
* ksmbd_decode_ntlmssp_auth_blob() - helper function to construct
484
290
* authenticate blob
@@ -512,17 +318,6 @@ int ksmbd_decode_ntlmssp_auth_blob(struct authenticate_message *authblob,
512
318
nt_off = le32_to_cpu (authblob -> NtChallengeResponse .BufferOffset );
513
319
nt_len = le16_to_cpu (authblob -> NtChallengeResponse .Length );
514
320
515
- /* process NTLM authentication */
516
- if (nt_len == CIFS_AUTH_RESP_SIZE ) {
517
- if (le32_to_cpu (authblob -> NegotiateFlags ) &
518
- NTLMSSP_NEGOTIATE_EXTENDED_SEC )
519
- return __ksmbd_auth_ntlmv2 (sess , (char * )authblob +
520
- lm_off , (char * )authblob + nt_off );
521
- else
522
- return ksmbd_auth_ntlm (sess , (char * )authblob +
523
- nt_off );
524
- }
525
-
526
321
/* TODO : use domain name that imported from configuration file */
527
322
domain_name = smb_strndup_from_utf16 ((const char * )authblob +
528
323
le32_to_cpu (authblob -> DomainName .BufferOffset ),
0 commit comments