crypto.c (112d6212c80a1c560757520bd822a41c0ad15c2c) | crypto.c (4006d799d93b159fd834c50999265b5c534a71d5) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * This contains encryption functions for per-file encryption. 4 * 5 * Copyright (C) 2015, Google, Inc. 6 * Copyright (C) 2015, Motorola Mobility 7 * 8 * Written by Michael Halcrow, 2014. --- 13 unchanged lines hidden (view full) --- 22 23#include <linux/pagemap.h> 24#include <linux/mempool.h> 25#include <linux/module.h> 26#include <linux/scatterlist.h> 27#include <linux/ratelimit.h> 28#include <linux/dcache.h> 29#include <linux/namei.h> | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * This contains encryption functions for per-file encryption. 4 * 5 * Copyright (C) 2015, Google, Inc. 6 * Copyright (C) 2015, Motorola Mobility 7 * 8 * Written by Michael Halcrow, 2014. --- 13 unchanged lines hidden (view full) --- 22 23#include <linux/pagemap.h> 24#include <linux/mempool.h> 25#include <linux/module.h> 26#include <linux/scatterlist.h> 27#include <linux/ratelimit.h> 28#include <linux/dcache.h> 29#include <linux/namei.h> |
30#include <crypto/aes.h> | |
31#include <crypto/skcipher.h> 32#include "fscrypt_private.h" 33 34static unsigned int num_prealloc_crypto_pages = 32; 35static unsigned int num_prealloc_crypto_ctxs = 128; 36 37module_param(num_prealloc_crypto_pages, uint, 0444); 38MODULE_PARM_DESC(num_prealloc_crypto_pages, --- 99 unchanged lines hidden (view full) --- 138void fscrypt_generate_iv(union fscrypt_iv *iv, u64 lblk_num, 139 const struct fscrypt_info *ci) 140{ 141 memset(iv, 0, ci->ci_mode->ivsize); 142 iv->lblk_num = cpu_to_le64(lblk_num); 143 144 if (fscrypt_is_direct_key_policy(&ci->ci_policy)) 145 memcpy(iv->nonce, ci->ci_nonce, FS_KEY_DERIVATION_NONCE_SIZE); | 30#include <crypto/skcipher.h> 31#include "fscrypt_private.h" 32 33static unsigned int num_prealloc_crypto_pages = 32; 34static unsigned int num_prealloc_crypto_ctxs = 128; 35 36module_param(num_prealloc_crypto_pages, uint, 0444); 37MODULE_PARM_DESC(num_prealloc_crypto_pages, --- 99 unchanged lines hidden (view full) --- 137void fscrypt_generate_iv(union fscrypt_iv *iv, u64 lblk_num, 138 const struct fscrypt_info *ci) 139{ 140 memset(iv, 0, ci->ci_mode->ivsize); 141 iv->lblk_num = cpu_to_le64(lblk_num); 142 143 if (fscrypt_is_direct_key_policy(&ci->ci_policy)) 144 memcpy(iv->nonce, ci->ci_nonce, FS_KEY_DERIVATION_NONCE_SIZE); |
146 147 if (ci->ci_essiv_tfm != NULL) 148 crypto_cipher_encrypt_one(ci->ci_essiv_tfm, iv->raw, iv->raw); | |
149} 150 151/* Encrypt or decrypt a single filesystem block of file contents */ 152int fscrypt_crypt_block(const struct inode *inode, fscrypt_direction_t rw, 153 u64 lblk_num, struct page *src_page, 154 struct page *dest_page, unsigned int len, 155 unsigned int offs, gfp_t gfp_flags) 156{ --- 364 unchanged lines hidden --- | 145} 146 147/* Encrypt or decrypt a single filesystem block of file contents */ 148int fscrypt_crypt_block(const struct inode *inode, fscrypt_direction_t rw, 149 u64 lblk_num, struct page *src_page, 150 struct page *dest_page, unsigned int len, 151 unsigned int offs, gfp_t gfp_flags) 152{ --- 364 unchanged lines hidden --- |