cifs: Use ecb des kernel crypto APIs instead of local cifs functions (try #4)
Subsystems (2)
PATCH 1/1 cifs: Use ecb des kernel crypto APIs instead of local cifs functions (try #4)
From: Shirish Pargaonkar <[email protected]>
Using kernel crypto APIs for DES encryption during LM and NT hash generation instead of local functions within cifs.
Source file smbdes.c is deleted sans five functions, one of which uses ecb des functionality provided by kernel crypto APIs.
Remove function SMBOWFencrypt.
Add return codes to various functions such as calc_lanman_hash, SMBencrypt, and SMBNTencrypt.
Signed-off-by Shirish Pargaonkar <[email protected]>
--- fs/cifs/Kconfig | 1 + fs/cifs/Makefile | 2 +- fs/cifs/cifsencrypt.c | 10 +- fs/cifs/cifsproto.h | 7 +- fs/cifs/sess.c | 2 +- fs/cifs/smbdes.c | 421 ------------------------------------------------- fs/cifs/smbencrypt.c | 127 ++++++++++++--- 7 files changed, 112 insertions(+), 458 deletions(-) delete mode 100644 fs/cifs/smbdes.c
fs/cifs/Kconfig +1 -0
@@ -7,6 +7,7 @@ config CIFS select CRYPTO_MD5 select CRYPTO_HMAC select CRYPTO_ARC4 + select CRYPTO_DES help This is the client VFS module for the Common Internet File System (CIFS) protocol which is the successor to the Server Message Block
fs/cifs/Makefile +1 -1
@@ -4,7 +4,7 @@ obj-$(CONFIG_CIFS) += cifs.o cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \ - link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o \ + link.o misc.o netmisc.o smbencrypt.o transport.o asn1.o \ cifs_unicode.o nterr.o xattr.o cifsencrypt.o \ readdir.o ioctl.o sess.o export.o
fs/cifs/cifsencrypt.c +5 -5
@@ -265,10 +265,11 @@ int setup_ntlm_response(struct cifsSesInfo *ses) }#ifdef CONFIG_CIFS_WEAK_PW_HASH -void calc_lanman_hash (const char *password,const char *cryptkey,bool encrypt, +int calc_lanman_hash (const char *password,const char *cryptkey,bool encrypt,char *lnm_session_key) {int i; +int rc;char password_with_pad[CIFS_ENCPWD_SIZE ];memset (password_with_pad,0 ,CIFS_ENCPWD_SIZE );
@@ -279,7 +280,7 @@ void calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,memset (lnm_session_key,0 ,CIFS_SESS_KEY_SIZE );memcpy (lnm_session_key, password_with_pad,CIFS_ENCPWD_SIZE ); -return ; +return 0 ; }/* calculate old style session key */
@@ -296,10 +297,9 @@ void calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,for (i =0 ; i <CIFS_ENCPWD_SIZE ; i++) password_with_pad[i] =toupper (password_with_pad[i]); -SMBencrypt (password_with_pad, cryptkey, lnm_session_key); + rc =SMBencrypt (password_with_pad, cryptkey, lnm_session_key); -/* clear password before we return/free memory */ - memset(password_with_pad, 0, CIFS_ENCPWD_SIZE); + return rc; }#endif /* CIFS_WEAK_PW_HASH */
fs/cifs/cifsproto.h +2 -5
@@ -383,7 +383,7 @@ extern void cifs_crypto_shash_release(struct TCP_Server_Info *);extern int calc_seckey (struct cifsSesInfo *);#ifdef CONFIG_CIFS_WEAK_PW_HASH -extern void calc_lanman_hash (const char *password,const char *cryptkey, +extern int calc_lanman_hash (const char *password,const char *cryptkey,bool encrypt,char *lnm_session_key);#endif /* CIFS_WEAK_PW_HASH */ extern int CIFSSMBCopy(int xid,
@@ -427,9 +427,6 @@ extern int CIFSCheckMFSymlink(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb, int xid);extern int mdfour (unsigned char *,unsigned char *,int );extern int E_md4hash (const unsigned char *passwd,unsigned char *p16); -extern void SMBencrypt (unsigned char *passwd,const unsigned char *c8, -unsigned char *p24); -extern void E_P16 (unsigned char *p14,unsigned char *p16); -extern void E_P24 (unsigned char *p21,const unsigned char *c8, +extern int SMBencrypt (unsigned char *passwd,const unsigned char *c8,unsigned char *p24);#endif /* _CIFSPROTO_H */
fs/cifs/sess.c +1 -1
@@ -670,7 +670,7 @@ ssetup_ntlmssp_authenticate:* to use challenge/response method (i.e. Password bit is 1). */ -calc_lanman_hash (ses->password, ses->server->cryptkey, + rc =calc_lanman_hash (ses->password, ses->server->cryptkey, ses->server->secMode &SECMODE_PW_ENCRYPT ? true : false, lnm_session_key);
fs/cifs/smbdes.c deleted +0 -421
421 lines not on this page · raw message
fs/cifs/smbencrypt.c +102 -25
164 lines not on this page · raw message
Signature · 1 line
1.6.0.2