public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] eCryptfs: Load each file decryption key only once
@ 2007-12-22  2:05 Trevor Highland
  2008-01-08 21:17 ` Michael Halcrow
  0 siblings, 1 reply; 5+ messages in thread
From: Trevor Highland @ 2007-12-22  2:05 UTC (permalink / raw)
  To: akpm, linux-kernel, ecryptfs-devel, mhalcrow

eCryptfs: Load each file decryption key only once

There is no need to keep re-setting the same key for any given
eCryptfs inode. This patch optimizes the use of the crypto API and
helps performance a bit.

Signed-off-by: Trevor Highland <trevor.highland@gmail.com>
---
 fs/ecryptfs/crypto.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 70f7aab..949fe44 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -353,7 +353,6 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
 		ecryptfs_dump_hex(crypt_stat->key,
 				  crypt_stat->key_size);
 	}
-	/* Consider doing this once, when the file is opened */
 	mutex_lock(&crypt_stat->cs_tfm_mutex);
 	if (!(crypt_stat->flags & ECRYPTFS_KEY_SET)) {
 		rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
@@ -687,10 +686,12 @@ static int decrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
 	};
 	int rc = 0;
 
-	/* Consider doing this once, when the file is opened */
 	mutex_lock(&crypt_stat->cs_tfm_mutex);
-	rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
-				     crypt_stat->key_size);
+	if (!(crypt_stat->flags & ECRYPTFS_KEY_SET)) {
+		rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
+					     crypt_stat->key_size);
+		crypt_stat->flags |= ECRYPTFS_KEY_SET;
+	}
 	if (rc) {
 		ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n",
 				rc);
-- 
1.5.2.5



^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] eCryptfs: Load each file decryption key only once
@ 2007-12-19  2:37 Trevor Highland
  0 siblings, 0 replies; 5+ messages in thread
From: Trevor Highland @ 2007-12-19  2:37 UTC (permalink / raw)
  To: akpm, linux-kernel, ecryptfs-devel, mhalcrow

Load each file decryption key only once

Signed-off-by: Trevor Highland <trevor.highland@gmail.com>
---
 fs/ecryptfs/crypto.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 70f7aab..949fe44 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -353,7 +353,6 @@ static int encrypt_scatterlist(struct
ecryptfs_crypt_stat *crypt_stat,
 		ecryptfs_dump_hex(crypt_stat->key,
 				  crypt_stat->key_size);
 	}
-	/* Consider doing this once, when the file is opened */
 	mutex_lock(&crypt_stat->cs_tfm_mutex);
 	if (!(crypt_stat->flags & ECRYPTFS_KEY_SET)) {
 		rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
@@ -687,10 +686,12 @@ static int decrypt_scatterlist(struct
ecryptfs_crypt_stat *crypt_stat,
 	};
 	int rc = 0;
 
-	/* Consider doing this once, when the file is opened */
 	mutex_lock(&crypt_stat->cs_tfm_mutex);
-	rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
-				     crypt_stat->key_size);
+	if (!(crypt_stat->flags & ECRYPTFS_KEY_SET)) {
+		rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key,
+					     crypt_stat->key_size);
+		crypt_stat->flags |= ECRYPTFS_KEY_SET;
+	}
 	if (rc) {
 		ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n",
 				rc);
-- 
1.5.2.5



^ permalink raw reply related	[flat|nested] 5+ messages in thread
* [PATCH] eCryptfs: Load each file decryption key only once
@ 2007-12-18  6:11 Trevor Highland
  0 siblings, 0 replies; 5+ messages in thread
From: Trevor Highland @ 2007-12-18  6:11 UTC (permalink / raw)
  To: akpm, linux-kernel, ecryptfs-devel, mhalcrow

[-- Attachment #1: Type: text/plain, Size: 91 bytes --]

There is no need to set the decryption key every time eCryptfs decrypts
an extent.

Trevor

[-- Attachment #2: 0001-eCryptfs-Load-each-file-decryption-key-only-once.patch --]
[-- Type: application/mbox, Size: 1511 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-01-08 22:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-22  2:05 [PATCH] eCryptfs: Load each file decryption key only once Trevor Highland
2008-01-08 21:17 ` Michael Halcrow
2008-01-08 22:47   ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2007-12-19  2:37 Trevor Highland
2007-12-18  6:11 Trevor Highland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox