Skip to contentSkip to conversation

eCryptfs: Load each file decryption key only once

PATCH New Trevor Highland 1 participant 1 message Dec 18, 2007 Ecrypt file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eCryptfs: Load each file decryption key only once

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

Trevor

Quoted 1 line

From e09d7a07ef3d34762cc1f850cf255961f74712d6 Mon Sep 17 00:00:00 2001

From: Trevor Highland <[email protected]>
Date: Thu, 13 Dec 2007 00:31:11 -0600
Subject: [PATCH] [PATCH] eCryptfs: Load each file decryption key only once

---
 fs/ecryptfs/crypto.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
fs/ecryptfs/crypto.c +5 -4
index 70f7aab..949fe44 100644
@@ -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);
Signature · 1 line
1.5.2.5