|
33 | 33 | #include <linux/ctype.h>
|
34 | 34 | #include <linux/random.h>
|
35 | 35 | #include <linux/highmem.h>
|
| 36 | +#include <crypto/skcipher.h> |
36 | 37 |
|
37 | 38 | static int
|
38 | 39 | cifs_crypto_shash_md5_allocate(struct TCP_Server_Info *server)
|
@@ -789,46 +790,55 @@ int
|
789 | 790 | calc_seckey(struct cifs_ses *ses)
|
790 | 791 | {
|
791 | 792 | int rc;
|
792 |
| - struct crypto_blkcipher *tfm_arc4; |
| 793 | + struct crypto_skcipher *tfm_arc4; |
793 | 794 | struct scatterlist sgin, sgout;
|
794 |
| - struct blkcipher_desc desc; |
| 795 | + struct skcipher_request *req; |
795 | 796 | unsigned char sec_key[CIFS_SESS_KEY_SIZE]; /* a nonce */
|
796 | 797 |
|
797 | 798 | get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE);
|
798 | 799 |
|
799 |
| - tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); |
| 800 | + tfm_arc4 = crypto_alloc_skcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); |
800 | 801 | if (IS_ERR(tfm_arc4)) {
|
801 | 802 | rc = PTR_ERR(tfm_arc4);
|
802 | 803 | cifs_dbg(VFS, "could not allocate crypto API arc4\n");
|
803 | 804 | return rc;
|
804 | 805 | }
|
805 | 806 |
|
806 |
| - desc.tfm = tfm_arc4; |
807 |
| - |
808 |
| - rc = crypto_blkcipher_setkey(tfm_arc4, ses->auth_key.response, |
| 807 | + rc = crypto_skcipher_setkey(tfm_arc4, ses->auth_key.response, |
809 | 808 | CIFS_SESS_KEY_SIZE);
|
810 | 809 | if (rc) {
|
811 | 810 | cifs_dbg(VFS, "%s: Could not set response as a key\n",
|
812 | 811 | __func__);
|
813 |
| - return rc; |
| 812 | + goto out_free_cipher; |
| 813 | + } |
| 814 | + |
| 815 | + req = skcipher_request_alloc(tfm_arc4, GFP_KERNEL); |
| 816 | + if (!req) { |
| 817 | + rc = -ENOMEM; |
| 818 | + cifs_dbg(VFS, "could not allocate crypto API arc4 request\n"); |
| 819 | + goto out_free_cipher; |
814 | 820 | }
|
815 | 821 |
|
816 | 822 | sg_init_one(&sgin, sec_key, CIFS_SESS_KEY_SIZE);
|
817 | 823 | sg_init_one(&sgout, ses->ntlmssp->ciphertext, CIFS_CPHTXT_SIZE);
|
818 | 824 |
|
819 |
| - rc = crypto_blkcipher_encrypt(&desc, &sgout, &sgin, CIFS_CPHTXT_SIZE); |
| 825 | + skcipher_request_set_callback(req, 0, NULL, NULL); |
| 826 | + skcipher_request_set_crypt(req, &sgin, &sgout, CIFS_CPHTXT_SIZE, NULL); |
| 827 | + |
| 828 | + rc = crypto_skcipher_encrypt(req); |
| 829 | + skcipher_request_free(req); |
820 | 830 | if (rc) {
|
821 | 831 | cifs_dbg(VFS, "could not encrypt session key rc: %d\n", rc);
|
822 |
| - crypto_free_blkcipher(tfm_arc4); |
823 |
| - return rc; |
| 832 | + goto out_free_cipher; |
824 | 833 | }
|
825 | 834 |
|
826 | 835 | /* make secondary_key/nonce as session key */
|
827 | 836 | memcpy(ses->auth_key.response, sec_key, CIFS_SESS_KEY_SIZE);
|
828 | 837 | /* and make len as that of session key only */
|
829 | 838 | ses->auth_key.len = CIFS_SESS_KEY_SIZE;
|
830 | 839 |
|
831 |
| - crypto_free_blkcipher(tfm_arc4); |
| 840 | +out_free_cipher: |
| 841 | + crypto_free_skcipher(tfm_arc4); |
832 | 842 |
|
833 | 843 | return rc;
|
834 | 844 | }
|
|
0 commit comments