|
@@ -355,8 +355,11 @@ static int encrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
|
|
|
}
|
|
|
/* 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);
|