Fix encryption labels and lengths for SMB3.1.1

SMB3.1.1 is most secure and recent dialect. Fixup labels and lengths
for sMB3.1.1 signing and encryption.

Signed-off-by: Steve French <smfrench@gmail.com>
CC: Stable <stable@vger.kernel.org>

+20 -14
+6 -2
fs/cifs/cifsglob.h
··· 661 #endif 662 unsigned int max_read; 663 unsigned int max_write; 664 - __u8 preauth_hash[512]; 665 struct delayed_work reconnect; /* reconnect workqueue job */ 666 struct mutex reconnect_mutex; /* prevent simultaneous reconnects */ 667 unsigned long echo_interval; ··· 851 __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE]; 852 __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE]; 853 __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE]; 854 - __u8 preauth_hash[512]; 855 }; 856 857 static inline bool
··· 661 #endif 662 unsigned int max_read; 663 unsigned int max_write; 664 + #ifdef CONFIG_CIFS_SMB311 665 + __u8 preauth_sha_hash[64]; /* save initital negprot hash */ 666 + #endif /* 3.1.1 */ 667 struct delayed_work reconnect; /* reconnect workqueue job */ 668 struct mutex reconnect_mutex; /* prevent simultaneous reconnects */ 669 unsigned long echo_interval; ··· 849 __u8 smb3signingkey[SMB3_SIGN_KEY_SIZE]; 850 __u8 smb3encryptionkey[SMB3_SIGN_KEY_SIZE]; 851 __u8 smb3decryptionkey[SMB3_SIGN_KEY_SIZE]; 852 + #ifdef CONFIG_CIFS_SMB311 853 + __u8 preauth_sha_hash[64]; 854 + #endif /* 3.1.1 */ 855 }; 856 857 static inline bool
+14 -12
fs/cifs/smb2transport.c
··· 390 return generate_smb3signingkey(ses, &triplet); 391 } 392 393 int 394 generate_smb311signingkey(struct cifs_ses *ses) 395 ··· 399 struct derivation *d; 400 401 d = &triplet.signing; 402 - d->label.iov_base = "SMB2AESCMAC"; 403 - d->label.iov_len = 12; 404 - d->context.iov_base = "SmbSign"; 405 - d->context.iov_len = 8; 406 407 d = &triplet.encryption; 408 - d->label.iov_base = "SMB2AESCCM"; 409 - d->label.iov_len = 11; 410 - d->context.iov_base = "ServerIn "; 411 - d->context.iov_len = 10; 412 413 d = &triplet.decryption; 414 - d->label.iov_base = "SMB2AESCCM"; 415 - d->label.iov_len = 11; 416 - d->context.iov_base = "ServerOut"; 417 - d->context.iov_len = 10; 418 419 return generate_smb3signingkey(ses, &triplet); 420 } 421 422 int 423 smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)
··· 390 return generate_smb3signingkey(ses, &triplet); 391 } 392 393 + #ifdef CONFIG_CIFS_SMB311 394 int 395 generate_smb311signingkey(struct cifs_ses *ses) 396 ··· 398 struct derivation *d; 399 400 d = &triplet.signing; 401 + d->label.iov_base = "SMBSigningKey"; 402 + d->label.iov_len = 14; 403 + d->context.iov_base = ses->preauth_sha_hash; 404 + d->context.iov_len = 64; 405 406 d = &triplet.encryption; 407 + d->label.iov_base = "SMBC2SCipherKey"; 408 + d->label.iov_len = 16; 409 + d->context.iov_base = ses->preauth_sha_hash; 410 + d->context.iov_len = 64; 411 412 d = &triplet.decryption; 413 + d->label.iov_base = "SMBS2CCipherKey"; 414 + d->label.iov_len = 16; 415 + d->context.iov_base = ses->preauth_sha_hash; 416 + d->context.iov_len = 64; 417 418 return generate_smb3signingkey(ses, &triplet); 419 } 420 + #endif /* 311 */ 421 422 int 423 smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)