|
22 | 22 | #include <linux/random.h> |
23 | 23 | #include <linux/highmem.h> |
24 | 24 | #include <linux/fips.h> |
25 | | -#include <crypto/arc4.h> |
| 25 | +#include "../cifs_common/arc4.h" |
26 | 26 | #include <crypto/aead.h> |
27 | 27 |
|
28 | 28 | int __cifs_calc_signature(struct smb_rqst *rqst, |
@@ -250,87 +250,6 @@ int cifs_verify_signature(struct smb_rqst *rqst, |
250 | 250 |
|
251 | 251 | } |
252 | 252 |
|
253 | | -/* first calculate 24 bytes ntlm response and then 16 byte session key */ |
254 | | -int setup_ntlm_response(struct cifs_ses *ses, const struct nls_table *nls_cp) |
255 | | -{ |
256 | | - int rc = 0; |
257 | | - unsigned int temp_len = CIFS_SESS_KEY_SIZE + CIFS_AUTH_RESP_SIZE; |
258 | | - char temp_key[CIFS_SESS_KEY_SIZE]; |
259 | | - |
260 | | - if (!ses) |
261 | | - return -EINVAL; |
262 | | - |
263 | | - ses->auth_key.response = kmalloc(temp_len, GFP_KERNEL); |
264 | | - if (!ses->auth_key.response) |
265 | | - return -ENOMEM; |
266 | | - |
267 | | - ses->auth_key.len = temp_len; |
268 | | - |
269 | | - rc = SMBNTencrypt(ses->password, ses->server->cryptkey, |
270 | | - ses->auth_key.response + CIFS_SESS_KEY_SIZE, nls_cp); |
271 | | - if (rc) { |
272 | | - cifs_dbg(FYI, "%s Can't generate NTLM response, error: %d\n", |
273 | | - __func__, rc); |
274 | | - return rc; |
275 | | - } |
276 | | - |
277 | | - rc = E_md4hash(ses->password, temp_key, nls_cp); |
278 | | - if (rc) { |
279 | | - cifs_dbg(FYI, "%s Can't generate NT hash, error: %d\n", |
280 | | - __func__, rc); |
281 | | - return rc; |
282 | | - } |
283 | | - |
284 | | - rc = mdfour(ses->auth_key.response, temp_key, CIFS_SESS_KEY_SIZE); |
285 | | - if (rc) |
286 | | - cifs_dbg(FYI, "%s Can't generate NTLM session key, error: %d\n", |
287 | | - __func__, rc); |
288 | | - |
289 | | - return rc; |
290 | | -} |
291 | | - |
292 | | -#ifdef CONFIG_CIFS_WEAK_PW_HASH |
293 | | -int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt, |
294 | | - char *lnm_session_key) |
295 | | -{ |
296 | | - int i, len; |
297 | | - int rc; |
298 | | - char password_with_pad[CIFS_ENCPWD_SIZE] = {0}; |
299 | | - |
300 | | - if (password) { |
301 | | - for (len = 0; len < CIFS_ENCPWD_SIZE; len++) |
302 | | - if (!password[len]) |
303 | | - break; |
304 | | - |
305 | | - memcpy(password_with_pad, password, len); |
306 | | - } |
307 | | - |
308 | | - if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) { |
309 | | - memcpy(lnm_session_key, password_with_pad, |
310 | | - CIFS_ENCPWD_SIZE); |
311 | | - return 0; |
312 | | - } |
313 | | - |
314 | | - /* calculate old style session key */ |
315 | | - /* calling toupper is less broken than repeatedly |
316 | | - calling nls_toupper would be since that will never |
317 | | - work for UTF8, but neither handles multibyte code pages |
318 | | - but the only alternative would be converting to UCS-16 (Unicode) |
319 | | - (using a routine something like UniStrupr) then |
320 | | - uppercasing and then converting back from Unicode - which |
321 | | - would only worth doing it if we knew it were utf8. Basically |
322 | | - utf8 and other multibyte codepages each need their own strupper |
323 | | - function since a byte at a time will ont work. */ |
324 | | - |
325 | | - for (i = 0; i < CIFS_ENCPWD_SIZE; i++) |
326 | | - password_with_pad[i] = toupper(password_with_pad[i]); |
327 | | - |
328 | | - rc = SMBencrypt(password_with_pad, cryptkey, lnm_session_key); |
329 | | - |
330 | | - return rc; |
331 | | -} |
332 | | -#endif /* CIFS_WEAK_PW_HASH */ |
333 | | - |
334 | 253 | /* Build a proper attribute value/target info pairs blob. |
335 | 254 | * Fill in netbios and dns domain name and workstation name |
336 | 255 | * and client time (total five av pairs and + one end of fields indicator. |
@@ -780,9 +699,9 @@ calc_seckey(struct cifs_ses *ses) |
780 | 699 | return -ENOMEM; |
781 | 700 | } |
782 | 701 |
|
783 | | - arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE); |
784 | | - arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key, |
785 | | - CIFS_CPHTXT_SIZE); |
| 702 | + cifs_arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE); |
| 703 | + cifs_arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key, |
| 704 | + CIFS_CPHTXT_SIZE); |
786 | 705 |
|
787 | 706 | /* make secondary_key/nonce as session key */ |
788 | 707 | memcpy(ses->auth_key.response, sec_key, CIFS_SESS_KEY_SIZE); |
|
0 commit comments