diff options
Diffstat (limited to 'fs/cifs/smbencrypt.c')
-rw-r--r-- | fs/cifs/smbencrypt.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/fs/cifs/smbencrypt.c b/fs/cifs/smbencrypt.c index a4232ec4f2ba..699b7868108f 100644 --- a/fs/cifs/smbencrypt.c +++ b/fs/cifs/smbencrypt.c | |||
@@ -23,6 +23,7 @@ | |||
23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 23 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <crypto/skcipher.h> | ||
26 | #include <linux/module.h> | 27 | #include <linux/module.h> |
27 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
28 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
@@ -70,31 +71,42 @@ smbhash(unsigned char *out, const unsigned char *in, unsigned char *key) | |||
70 | { | 71 | { |
71 | int rc; | 72 | int rc; |
72 | unsigned char key2[8]; | 73 | unsigned char key2[8]; |
73 | struct crypto_blkcipher *tfm_des; | 74 | struct crypto_skcipher *tfm_des; |
74 | struct scatterlist sgin, sgout; | 75 | struct scatterlist sgin, sgout; |
75 | struct blkcipher_desc desc; | 76 | struct skcipher_request *req; |
76 | 77 | ||
77 | str_to_key(key, key2); | 78 | str_to_key(key, key2); |
78 | 79 | ||
79 | tfm_des = crypto_alloc_blkcipher("ecb(des)", 0, CRYPTO_ALG_ASYNC); | 80 | tfm_des = crypto_alloc_skcipher("ecb(des)", 0, CRYPTO_ALG_ASYNC); |
80 | if (IS_ERR(tfm_des)) { | 81 | if (IS_ERR(tfm_des)) { |
81 | rc = PTR_ERR(tfm_des); | 82 | rc = PTR_ERR(tfm_des); |
82 | cifs_dbg(VFS, "could not allocate des crypto API\n"); | 83 | cifs_dbg(VFS, "could not allocate des crypto API\n"); |
83 | goto smbhash_err; | 84 | goto smbhash_err; |
84 | } | 85 | } |
85 | 86 | ||
86 | desc.tfm = tfm_des; | 87 | req = skcipher_request_alloc(tfm_des, GFP_KERNEL); |
88 | if (!req) { | ||
89 | rc = -ENOMEM; | ||
90 | cifs_dbg(VFS, "could not allocate des crypto API\n"); | ||
91 | goto smbhash_free_skcipher; | ||
92 | } | ||
87 | 93 | ||
88 | crypto_blkcipher_setkey(tfm_des, key2, 8); | 94 | crypto_skcipher_setkey(tfm_des, key2, 8); |
89 | 95 | ||
90 | sg_init_one(&sgin, in, 8); | 96 | sg_init_one(&sgin, in, 8); |
91 | sg_init_one(&sgout, out, 8); | 97 | sg_init_one(&sgout, out, 8); |
92 | 98 | ||
93 | rc = crypto_blkcipher_encrypt(&desc, &sgout, &sgin, 8); | 99 | skcipher_request_set_callback(req, 0, NULL, NULL); |
100 | skcipher_request_set_crypt(req, &sgin, &sgout, 8, NULL); | ||
101 | |||
102 | rc = crypto_skcipher_encrypt(req); | ||
94 | if (rc) | 103 | if (rc) |
95 | cifs_dbg(VFS, "could not encrypt crypt key rc: %d\n", rc); | 104 | cifs_dbg(VFS, "could not encrypt crypt key rc: %d\n", rc); |
96 | 105 | ||
97 | crypto_free_blkcipher(tfm_des); | 106 | skcipher_request_free(req); |
107 | |||
108 | smbhash_free_skcipher: | ||
109 | crypto_free_skcipher(tfm_des); | ||
98 | smbhash_err: | 110 | smbhash_err: |
99 | return rc; | 111 | return rc; |
100 | } | 112 | } |