diff options
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/crypto.c | 7 | ||||
-rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 1 |
2 files changed, 6 insertions, 2 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 4d1b2b4eb79e..7eaa395a77bd 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -355,8 +355,11 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, | |||
355 | } | 355 | } |
356 | /* Consider doing this once, when the file is opened */ | 356 | /* Consider doing this once, when the file is opened */ |
357 | mutex_lock(&crypt_stat->cs_tfm_mutex); | 357 | mutex_lock(&crypt_stat->cs_tfm_mutex); |
358 | rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key, | 358 | if (!(crypt_stat->flags & ECRYPTFS_KEY_SET)) { |
359 | crypt_stat->key_size); | 359 | rc = crypto_blkcipher_setkey(crypt_stat->tfm, crypt_stat->key, |
360 | crypt_stat->key_size); | ||
361 | crypt_stat->flags |= ECRYPTFS_KEY_SET; | ||
362 | } | ||
360 | if (rc) { | 363 | if (rc) { |
361 | ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n", | 364 | ecryptfs_printk(KERN_ERR, "Error setting key; rc = [%d]\n", |
362 | rc); | 365 | rc); |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index 3d637e9ca36a..2a6103954c1e 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -234,6 +234,7 @@ struct ecryptfs_crypt_stat { | |||
234 | #define ECRYPTFS_KEY_VALID 0x00000080 | 234 | #define ECRYPTFS_KEY_VALID 0x00000080 |
235 | #define ECRYPTFS_METADATA_IN_XATTR 0x00000100 | 235 | #define ECRYPTFS_METADATA_IN_XATTR 0x00000100 |
236 | #define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000200 | 236 | #define ECRYPTFS_VIEW_AS_ENCRYPTED 0x00000200 |
237 | #define ECRYPTFS_KEY_SET 0x00000400 | ||
237 | u32 flags; | 238 | u32 flags; |
238 | unsigned int file_version; | 239 | unsigned int file_version; |
239 | size_t iv_bytes; | 240 | size_t iv_bytes; |