diff options
author | Pavel Shilovsky <pshilovsky@samba.org> | 2012-09-18 19:20:30 -0400 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-09-24 22:46:28 -0400 |
commit | 3c1bf7e48e9e463b65b1b90da4500a93dd2b27a7 (patch) | |
tree | c16caed7a01a5b1438b5acd8aa45929889da10ad /fs/cifs/cifsencrypt.c | |
parent | 009d344398bb3e844b31eb9e6a7860748c6f6dd3 (diff) |
CIFS: Enable signing in SMB2
Use hmac-sha256 and rather than hmac-md5 that is used for CIFS/SMB.
Signature field in SMB2 header is 16 bytes instead of 8 bytes.
Automatically enable signing by client when requested by the server
when signing ability is available to the client.
Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
Signed-off-by: Pavel Shilovsky <piastryyy@gmail.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/cifsencrypt.c')
-rw-r--r-- | fs/cifs/cifsencrypt.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index 6a0d741159f0..724738c1a560 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -686,12 +686,17 @@ calc_seckey(struct cifs_ses *ses) | |||
686 | void | 686 | void |
687 | cifs_crypto_shash_release(struct TCP_Server_Info *server) | 687 | cifs_crypto_shash_release(struct TCP_Server_Info *server) |
688 | { | 688 | { |
689 | if (server->secmech.hmacsha256) | ||
690 | crypto_free_shash(server->secmech.hmacsha256); | ||
691 | |||
689 | if (server->secmech.md5) | 692 | if (server->secmech.md5) |
690 | crypto_free_shash(server->secmech.md5); | 693 | crypto_free_shash(server->secmech.md5); |
691 | 694 | ||
692 | if (server->secmech.hmacmd5) | 695 | if (server->secmech.hmacmd5) |
693 | crypto_free_shash(server->secmech.hmacmd5); | 696 | crypto_free_shash(server->secmech.hmacmd5); |
694 | 697 | ||
698 | kfree(server->secmech.sdeschmacsha256); | ||
699 | |||
695 | kfree(server->secmech.sdeschmacmd5); | 700 | kfree(server->secmech.sdeschmacmd5); |
696 | 701 | ||
697 | kfree(server->secmech.sdescmd5); | 702 | kfree(server->secmech.sdescmd5); |
@@ -716,6 +721,13 @@ cifs_crypto_shash_allocate(struct TCP_Server_Info *server) | |||
716 | goto crypto_allocate_md5_fail; | 721 | goto crypto_allocate_md5_fail; |
717 | } | 722 | } |
718 | 723 | ||
724 | server->secmech.hmacsha256 = crypto_alloc_shash("hmac(sha256)", 0, 0); | ||
725 | if (IS_ERR(server->secmech.hmacsha256)) { | ||
726 | cERROR(1, "could not allocate crypto hmacsha256\n"); | ||
727 | rc = PTR_ERR(server->secmech.hmacsha256); | ||
728 | goto crypto_allocate_hmacsha256_fail; | ||
729 | } | ||
730 | |||
719 | size = sizeof(struct shash_desc) + | 731 | size = sizeof(struct shash_desc) + |
720 | crypto_shash_descsize(server->secmech.hmacmd5); | 732 | crypto_shash_descsize(server->secmech.hmacmd5); |
721 | server->secmech.sdeschmacmd5 = kmalloc(size, GFP_KERNEL); | 733 | server->secmech.sdeschmacmd5 = kmalloc(size, GFP_KERNEL); |
@@ -727,7 +739,6 @@ cifs_crypto_shash_allocate(struct TCP_Server_Info *server) | |||
727 | server->secmech.sdeschmacmd5->shash.tfm = server->secmech.hmacmd5; | 739 | server->secmech.sdeschmacmd5->shash.tfm = server->secmech.hmacmd5; |
728 | server->secmech.sdeschmacmd5->shash.flags = 0x0; | 740 | server->secmech.sdeschmacmd5->shash.flags = 0x0; |
729 | 741 | ||
730 | |||
731 | size = sizeof(struct shash_desc) + | 742 | size = sizeof(struct shash_desc) + |
732 | crypto_shash_descsize(server->secmech.md5); | 743 | crypto_shash_descsize(server->secmech.md5); |
733 | server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL); | 744 | server->secmech.sdescmd5 = kmalloc(size, GFP_KERNEL); |
@@ -739,12 +750,29 @@ cifs_crypto_shash_allocate(struct TCP_Server_Info *server) | |||
739 | server->secmech.sdescmd5->shash.tfm = server->secmech.md5; | 750 | server->secmech.sdescmd5->shash.tfm = server->secmech.md5; |
740 | server->secmech.sdescmd5->shash.flags = 0x0; | 751 | server->secmech.sdescmd5->shash.flags = 0x0; |
741 | 752 | ||
753 | size = sizeof(struct shash_desc) + | ||
754 | crypto_shash_descsize(server->secmech.hmacsha256); | ||
755 | server->secmech.sdeschmacsha256 = kmalloc(size, GFP_KERNEL); | ||
756 | if (!server->secmech.sdeschmacsha256) { | ||
757 | cERROR(1, "%s: Can't alloc hmacsha256\n", __func__); | ||
758 | rc = -ENOMEM; | ||
759 | goto crypto_allocate_hmacsha256_sdesc_fail; | ||
760 | } | ||
761 | server->secmech.sdeschmacsha256->shash.tfm = server->secmech.hmacsha256; | ||
762 | server->secmech.sdeschmacsha256->shash.flags = 0x0; | ||
763 | |||
742 | return 0; | 764 | return 0; |
743 | 765 | ||
766 | crypto_allocate_hmacsha256_sdesc_fail: | ||
767 | kfree(server->secmech.sdescmd5); | ||
768 | |||
744 | crypto_allocate_md5_sdesc_fail: | 769 | crypto_allocate_md5_sdesc_fail: |
745 | kfree(server->secmech.sdeschmacmd5); | 770 | kfree(server->secmech.sdeschmacmd5); |
746 | 771 | ||
747 | crypto_allocate_hmacmd5_sdesc_fail: | 772 | crypto_allocate_hmacmd5_sdesc_fail: |
773 | crypto_free_shash(server->secmech.hmacsha256); | ||
774 | |||
775 | crypto_allocate_hmacsha256_fail: | ||
748 | crypto_free_shash(server->secmech.md5); | 776 | crypto_free_shash(server->secmech.md5); |
749 | 777 | ||
750 | crypto_allocate_md5_fail: | 778 | crypto_allocate_md5_fail: |