diff options
author | Tyler Hicks <tyhicks@canonical.com> | 2013-04-15 19:37:27 -0400 |
---|---|---|
committer | Tyler Hicks <tyhicks@canonical.com> | 2013-06-07 20:28:24 -0400 |
commit | 28916d1ac1dd658773717e8eddc7c4ceeefc19b8 (patch) | |
tree | 968158a625f32de9737af3390e39897b56524a2d /fs/ecryptfs/crypto.c | |
parent | 24d15266bd86b7961f309a962fa3aa177a78c49f (diff) |
eCryptfs: Accept one offset parameter in page offset crypto functions
There is no longer a need to accept different offset values for the
source and destination pages when encrypting/decrypting an extent in an
eCryptfs page. The two offsets can be collapsed into a single parameter.
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Diffstat (limited to 'fs/ecryptfs/crypto.c')
-rw-r--r-- | fs/ecryptfs/crypto.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 3547708fb4e1..ec640ebcdea8 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -39,14 +39,12 @@ | |||
39 | 39 | ||
40 | static int | 40 | static int |
41 | ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, | 41 | ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, |
42 | struct page *dst_page, int dst_offset, | 42 | struct page *dst_page, struct page *src_page, |
43 | struct page *src_page, int src_offset, int size, | 43 | int offset, int size, unsigned char *iv); |
44 | unsigned char *iv); | ||
45 | static int | 44 | static int |
46 | ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, | 45 | ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, |
47 | struct page *dst_page, int dst_offset, | 46 | struct page *dst_page, struct page *src_page, |
48 | struct page *src_page, int src_offset, int size, | 47 | int offset, int size, unsigned char *iv); |
49 | unsigned char *iv); | ||
50 | 48 | ||
51 | /** | 49 | /** |
52 | * ecryptfs_to_hex | 50 | * ecryptfs_to_hex |
@@ -450,9 +448,7 @@ static int ecryptfs_encrypt_extent(struct page *enc_extent_page, | |||
450 | (unsigned long long)(extent_base + extent_offset), rc); | 448 | (unsigned long long)(extent_base + extent_offset), rc); |
451 | goto out; | 449 | goto out; |
452 | } | 450 | } |
453 | rc = ecryptfs_encrypt_page_offset(crypt_stat, enc_extent_page, | 451 | rc = ecryptfs_encrypt_page_offset(crypt_stat, enc_extent_page, page, |
454 | extent_offset * crypt_stat->extent_size, | ||
455 | page, | ||
456 | extent_offset * crypt_stat->extent_size, | 452 | extent_offset * crypt_stat->extent_size, |
457 | crypt_stat->extent_size, extent_iv); | 453 | crypt_stat->extent_size, extent_iv); |
458 | if (rc < 0) { | 454 | if (rc < 0) { |
@@ -555,9 +551,7 @@ static int ecryptfs_decrypt_extent(struct page *page, | |||
555 | (unsigned long long)(extent_base + extent_offset), rc); | 551 | (unsigned long long)(extent_base + extent_offset), rc); |
556 | goto out; | 552 | goto out; |
557 | } | 553 | } |
558 | rc = ecryptfs_decrypt_page_offset(crypt_stat, page, | 554 | rc = ecryptfs_decrypt_page_offset(crypt_stat, page, enc_extent_page, |
559 | extent_offset * crypt_stat->extent_size, | ||
560 | enc_extent_page, | ||
561 | extent_offset * crypt_stat->extent_size, | 555 | extent_offset * crypt_stat->extent_size, |
562 | crypt_stat->extent_size, extent_iv); | 556 | crypt_stat->extent_size, extent_iv); |
563 | if (rc < 0) { | 557 | if (rc < 0) { |
@@ -716,9 +710,8 @@ out: | |||
716 | * ecryptfs_encrypt_page_offset | 710 | * ecryptfs_encrypt_page_offset |
717 | * @crypt_stat: The cryptographic context | 711 | * @crypt_stat: The cryptographic context |
718 | * @dst_page: The page to encrypt into | 712 | * @dst_page: The page to encrypt into |
719 | * @dst_offset: The offset in the page to encrypt into | ||
720 | * @src_page: The page to encrypt from | 713 | * @src_page: The page to encrypt from |
721 | * @src_offset: The offset in the page to encrypt from | 714 | * @offset: The byte offset into the dst_page and src_page |
722 | * @size: The number of bytes to encrypt | 715 | * @size: The number of bytes to encrypt |
723 | * @iv: The initialization vector to use for the encryption | 716 | * @iv: The initialization vector to use for the encryption |
724 | * | 717 | * |
@@ -726,17 +719,16 @@ out: | |||
726 | */ | 719 | */ |
727 | static int | 720 | static int |
728 | ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, | 721 | ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, |
729 | struct page *dst_page, int dst_offset, | 722 | struct page *dst_page, struct page *src_page, |
730 | struct page *src_page, int src_offset, int size, | 723 | int offset, int size, unsigned char *iv) |
731 | unsigned char *iv) | ||
732 | { | 724 | { |
733 | struct scatterlist src_sg, dst_sg; | 725 | struct scatterlist src_sg, dst_sg; |
734 | 726 | ||
735 | sg_init_table(&src_sg, 1); | 727 | sg_init_table(&src_sg, 1); |
736 | sg_init_table(&dst_sg, 1); | 728 | sg_init_table(&dst_sg, 1); |
737 | 729 | ||
738 | sg_set_page(&src_sg, src_page, size, src_offset); | 730 | sg_set_page(&src_sg, src_page, size, offset); |
739 | sg_set_page(&dst_sg, dst_page, size, dst_offset); | 731 | sg_set_page(&dst_sg, dst_page, size, offset); |
740 | return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); | 732 | return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); |
741 | } | 733 | } |
742 | 734 | ||
@@ -744,9 +736,8 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, | |||
744 | * ecryptfs_decrypt_page_offset | 736 | * ecryptfs_decrypt_page_offset |
745 | * @crypt_stat: The cryptographic context | 737 | * @crypt_stat: The cryptographic context |
746 | * @dst_page: The page to decrypt into | 738 | * @dst_page: The page to decrypt into |
747 | * @dst_offset: The offset in the page to decrypt into | ||
748 | * @src_page: The page to decrypt from | 739 | * @src_page: The page to decrypt from |
749 | * @src_offset: The offset in the page to decrypt from | 740 | * @offset: The byte offset into the dst_page and src_page |
750 | * @size: The number of bytes to decrypt | 741 | * @size: The number of bytes to decrypt |
751 | * @iv: The initialization vector to use for the decryption | 742 | * @iv: The initialization vector to use for the decryption |
752 | * | 743 | * |
@@ -754,17 +745,16 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, | |||
754 | */ | 745 | */ |
755 | static int | 746 | static int |
756 | ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, | 747 | ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, |
757 | struct page *dst_page, int dst_offset, | 748 | struct page *dst_page, struct page *src_page, |
758 | struct page *src_page, int src_offset, int size, | 749 | int offset, int size, unsigned char *iv) |
759 | unsigned char *iv) | ||
760 | { | 750 | { |
761 | struct scatterlist src_sg, dst_sg; | 751 | struct scatterlist src_sg, dst_sg; |
762 | 752 | ||
763 | sg_init_table(&src_sg, 1); | 753 | sg_init_table(&src_sg, 1); |
764 | sg_set_page(&src_sg, src_page, size, src_offset); | 754 | sg_set_page(&src_sg, src_page, size, offset); |
765 | 755 | ||
766 | sg_init_table(&dst_sg, 1); | 756 | sg_init_table(&dst_sg, 1); |
767 | sg_set_page(&dst_sg, dst_page, size, dst_offset); | 757 | sg_set_page(&dst_sg, dst_page, size, offset); |
768 | 758 | ||
769 | return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); | 759 | return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); |
770 | } | 760 | } |