@@ -107,12 +107,12 @@ struct crypto_skcipher *fscrypt_allocate_skcipher(struct fscrypt_mode *mode,
107
107
return ERR_PTR (err );
108
108
}
109
109
110
- /* Given the per-file key, set up the file's crypto transform object */
111
- int fscrypt_set_derived_key (struct fscrypt_info * ci , const u8 * derived_key )
110
+ /* Given a per-file encryption key, set up the file's crypto transform object */
111
+ int fscrypt_set_per_file_enc_key (struct fscrypt_info * ci , const u8 * raw_key )
112
112
{
113
113
struct crypto_skcipher * tfm ;
114
114
115
- tfm = fscrypt_allocate_skcipher (ci -> ci_mode , derived_key , ci -> ci_inode );
115
+ tfm = fscrypt_allocate_skcipher (ci -> ci_mode , raw_key , ci -> ci_inode );
116
116
if (IS_ERR (tfm ))
117
117
return PTR_ERR (tfm );
118
118
@@ -121,10 +121,10 @@ int fscrypt_set_derived_key(struct fscrypt_info *ci, const u8 *derived_key)
121
121
return 0 ;
122
122
}
123
123
124
- static int setup_per_mode_key (struct fscrypt_info * ci ,
125
- struct fscrypt_master_key * mk ,
126
- struct crypto_skcipher * * tfms ,
127
- u8 hkdf_context , bool include_fs_uuid )
124
+ static int setup_per_mode_enc_key (struct fscrypt_info * ci ,
125
+ struct fscrypt_master_key * mk ,
126
+ struct crypto_skcipher * * tfms ,
127
+ u8 hkdf_context , bool include_fs_uuid )
128
128
{
129
129
const struct inode * inode = ci -> ci_inode ;
130
130
const struct super_block * sb = inode -> i_sb ;
@@ -196,15 +196,15 @@ static int fscrypt_setup_v2_file_key(struct fscrypt_info *ci,
196
196
197
197
if (ci -> ci_policy .v2 .flags & FSCRYPT_POLICY_FLAG_DIRECT_KEY ) {
198
198
/*
199
- * DIRECT_KEY: instead of deriving per-file keys, the per-file
200
- * nonce will be included in all the IVs. But unlike v1
201
- * policies, for v2 policies in this case we don't encrypt with
202
- * the master key directly but rather derive a per-mode key.
203
- * This ensures that the master key is consistently used only
204
- * for HKDF, avoiding key reuse issues.
199
+ * DIRECT_KEY: instead of deriving per-file encryption keys, the
200
+ * per-file nonce will be included in all the IVs. But unlike
201
+ * v1 policies, for v2 policies in this case we don't encrypt
202
+ * with the master key directly but rather derive a per-mode
203
+ * encryption key. This ensures that the master key is
204
+ * consistently used only for HKDF, avoiding key reuse issues.
205
205
*/
206
- err = setup_per_mode_key (ci , mk , mk -> mk_direct_tfms ,
207
- HKDF_CONTEXT_DIRECT_KEY , false);
206
+ err = setup_per_mode_enc_key (ci , mk , mk -> mk_direct_tfms ,
207
+ HKDF_CONTEXT_DIRECT_KEY , false);
208
208
} else if (ci -> ci_policy .v2 .flags &
209
209
FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64 ) {
210
210
/*
@@ -213,20 +213,21 @@ static int fscrypt_setup_v2_file_key(struct fscrypt_info *ci,
213
213
* the IVs. This format is optimized for use with inline
214
214
* encryption hardware compliant with the UFS or eMMC standards.
215
215
*/
216
- err = setup_per_mode_key (ci , mk , mk -> mk_iv_ino_lblk_64_tfms ,
217
- HKDF_CONTEXT_IV_INO_LBLK_64_KEY , true);
216
+ err = setup_per_mode_enc_key (ci , mk , mk -> mk_iv_ino_lblk_64_tfms ,
217
+ HKDF_CONTEXT_IV_INO_LBLK_64_KEY ,
218
+ true);
218
219
} else {
219
220
u8 derived_key [FSCRYPT_MAX_KEY_SIZE ];
220
221
221
222
err = fscrypt_hkdf_expand (& mk -> mk_secret .hkdf ,
222
- HKDF_CONTEXT_PER_FILE_KEY ,
223
+ HKDF_CONTEXT_PER_FILE_ENC_KEY ,
223
224
ci -> ci_nonce ,
224
225
FS_KEY_DERIVATION_NONCE_SIZE ,
225
226
derived_key , ci -> ci_mode -> keysize );
226
227
if (err )
227
228
return err ;
228
229
229
- err = fscrypt_set_derived_key (ci , derived_key );
230
+ err = fscrypt_set_per_file_enc_key (ci , derived_key );
230
231
memzero_explicit (derived_key , ci -> ci_mode -> keysize );
231
232
}
232
233
if (err )
0 commit comments