* Allocate a new Crypto API context if we don't already have
* one or if it isn't the right mode.
*/
- BUG_ON(ci->ci_mode == F2FS_ENCRYPTION_MODE_INVALID);
- if (ctx->tfm && (ctx->mode != ci->ci_mode)) {
+ if (ctx->tfm && (ctx->mode != ci->ci_data_mode)) {
crypto_free_tfm(ctx->tfm);
ctx->tfm = NULL;
ctx->mode = F2FS_ENCRYPTION_MODE_INVALID;
}
if (!ctx->tfm) {
- switch (ci->ci_mode) {
+ switch (ci->ci_data_mode) {
case F2FS_ENCRYPTION_MODE_AES_256_XTS:
ctx->tfm = crypto_ablkcipher_tfm(
crypto_alloc_ablkcipher("xts(aes)", 0, 0));
ctx->tfm = NULL;
goto out;
}
- ctx->mode = ci->ci_mode;
+ ctx->mode = ci->ci_data_mode;
}
- BUG_ON(ci->ci_size != f2fs_encryption_key_size(ci->ci_mode));
+ BUG_ON(ci->ci_size != f2fs_encryption_key_size(ci->ci_data_mode));
/*
* There shouldn't be a bounce page attached to the crypto
int res = 0;
BUG_ON(!ctx->tfm);
- BUG_ON(ctx->mode != fi->i_crypt_info->ci_mode);
+ BUG_ON(ctx->mode != fi->i_crypt_info->ci_data_mode);
if (ctx->mode != F2FS_ENCRYPTION_MODE_AES_256_XTS) {
printk_ratelimited(KERN_ERR
if (!ci || ci->ci_ctfm)
return 0;
- if (ci->ci_mode != F2FS_ENCRYPTION_MODE_AES_256_CTS) {
+ if (ci->ci_filename_mode != F2FS_ENCRYPTION_MODE_AES_256_CTS) {
printk_once(KERN_WARNING "f2fs: unsupported key mode %d\n",
- ci->ci_mode);
+ ci->ci_filename_mode);
return -ENOKEY;
}
memcpy(crypt_info->ci_master_key, ctx.master_key_descriptor,
sizeof(crypt_info->ci_master_key));
if (S_ISREG(inode->i_mode))
- crypt_info->ci_mode = ctx.contents_encryption_mode;
+ crypt_info->ci_size =
+ f2fs_encryption_key_size(crypt_info->ci_data_mode);
else if (S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))
- crypt_info->ci_mode = ctx.filenames_encryption_mode;
- else {
- printk(KERN_ERR "f2fs crypto: Unsupported inode type.\n");
+ crypt_info->ci_size =
+ f2fs_encryption_key_size(crypt_info->ci_filename_mode);
+ else
BUG();
- }
- crypt_info->ci_size = f2fs_encryption_key_size(crypt_info->ci_mode);
+
BUG_ON(!crypt_info->ci_size);
memcpy(full_key_descriptor, F2FS_KEY_DESC_PREFIX,