Commit 37d45180 authored by Herbert Xu's avatar Herbert Xu
Browse files

crypto: skcipher - Make skcipher_walk src.virt.addr const



Mark the src.virt.addr field in struct skcipher_walk as a pointer
to const data.  This guarantees that the user won't modify the data
which should be done through dst.virt.addr to ensure that flushing
is done when necessary.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent db873be6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -399,9 +399,9 @@ static int ctr_encrypt(struct skcipher_request *req)
	}
	if (walk.nbytes) {
		u8 __aligned(8) tail[AES_BLOCK_SIZE];
		const u8 *tsrc = walk.src.virt.addr;
		unsigned int nbytes = walk.nbytes;
		u8 *tdst = walk.dst.virt.addr;
		u8 *tsrc = walk.src.virt.addr;

		/*
		 * Tell aes_ctr_encrypt() to process a tail block.
+2 −1
Original line number Diff line number Diff line
@@ -287,7 +287,8 @@ static int __xts_crypt(struct skcipher_request *req, bool encrypt,
	struct skcipher_walk walk;
	int nbytes, err;
	int first = 1;
	u8 *out, *in;
	const u8 *in;
	u8 *out;

	if (req->cryptlen < AES_BLOCK_SIZE)
		return -EINVAL;
+3 −3
Original line number Diff line number Diff line
@@ -35,9 +35,9 @@ MODULE_ALIAS_CRYPTO("aes");
asmlinkage int aes_p10_set_encrypt_key(const u8 *userKey, const int bits,
				       void *key);
asmlinkage void aes_p10_encrypt(const u8 *in, u8 *out, const void *key);
asmlinkage void aes_p10_gcm_encrypt(u8 *in, u8 *out, size_t len,
asmlinkage void aes_p10_gcm_encrypt(const u8 *in, u8 *out, size_t len,
				    void *rkey, u8 *iv, void *Xi);
asmlinkage void aes_p10_gcm_decrypt(u8 *in, u8 *out, size_t len,
asmlinkage void aes_p10_gcm_decrypt(const u8 *in, u8 *out, size_t len,
				    void *rkey, u8 *iv, void *Xi);
asmlinkage void gcm_init_htable(unsigned char htable[], unsigned char Xi[]);
asmlinkage void gcm_ghash_p10(unsigned char *Xi, unsigned char *Htable,
@@ -261,7 +261,7 @@ static int p10_aes_gcm_crypt(struct aead_request *req, u8 *riv,
		return ret;

	while ((nbytes = walk.nbytes) > 0 && ret == 0) {
		u8 *src = walk.src.virt.addr;
		const u8 *src = walk.src.virt.addr;
		u8 *dst = walk.dst.virt.addr;
		u8 buf[AES_BLOCK_SIZE];

+1 −1
Original line number Diff line number Diff line
@@ -69,9 +69,9 @@ static int p8_aes_ctr_setkey(struct crypto_skcipher *tfm, const u8 *key,
static void p8_aes_ctr_final(const struct p8_aes_ctr_ctx *ctx,
			     struct skcipher_walk *walk)
{
	const u8 *src = walk->src.virt.addr;
	u8 *ctrblk = walk->iv;
	u8 keystream[AES_BLOCK_SIZE];
	u8 *src = walk->src.virt.addr;
	u8 *dst = walk->dst.virt.addr;
	unsigned int nbytes = walk->nbytes;

+1 −1
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ static void ctr_crypt_final(const struct crypto_sparc64_aes_ctx *ctx,
{
	u8 *ctrblk = walk->iv;
	u64 keystream[AES_BLOCK_SIZE / sizeof(u64)];
	u8 *src = walk->src.virt.addr;
	const u8 *src = walk->src.virt.addr;
	u8 *dst = walk->dst.virt.addr;
	unsigned int nbytes = walk->nbytes;

Loading