Commit 65775cf3 authored by Herbert Xu's avatar Herbert Xu
Browse files

crypto: scatterwalk - Change scatterwalk_next calling convention



Rather than returning the address and storing the length into an
argument pointer, add an address field to the walk struct and use
that to store the address.  The length is returned directly.

Change the done functions to use this stored address instead of
getting them from the caller.

Split the address into two using a union.  The user should only
access the const version so that it is never changed.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent b949f556
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -460,11 +460,10 @@ static void gcm_calculate_auth_mac(struct aead_request *req, u64 dg[], u32 len)

	do {
		unsigned int n;
		const u8 *p;

		p = scatterwalk_next(&walk, len, &n);
		gcm_update_mac(dg, p, n, buf, &buf_count, ctx);
		scatterwalk_done_src(&walk, p, n);
		n = scatterwalk_next(&walk, len);
		gcm_update_mac(dg, walk.addr, n, buf, &buf_count, ctx);
		scatterwalk_done_src(&walk,  n);

		if (unlikely(len / SZ_4K > (len - n) / SZ_4K)) {
			kernel_neon_end();
+4 −5
Original line number Diff line number Diff line
@@ -157,12 +157,11 @@ static void ccm_calculate_auth_mac(struct aead_request *req, u8 mac[])

	do {
		unsigned int n;
		const u8 *p;

		p = scatterwalk_next(&walk, len, &n);
		macp = ce_aes_ccm_auth_data(mac, p, n, macp, ctx->key_enc,
					    num_rounds(ctx));
		scatterwalk_done_src(&walk, p, n);
		n = scatterwalk_next(&walk, len);
		macp = ce_aes_ccm_auth_data(mac, walk.addr, n, macp,
					    ctx->key_enc, num_rounds(ctx));
		scatterwalk_done_src(&walk, n);
		len -= n;
	} while (len);
}
+3 −4
Original line number Diff line number Diff line
@@ -309,11 +309,10 @@ static void gcm_calculate_auth_mac(struct aead_request *req, u64 dg[], u32 len)

	do {
		unsigned int n;
		const u8 *p;

		p = scatterwalk_next(&walk, len, &n);
		gcm_update_mac(dg, p, n, buf, &buf_count, ctx);
		scatterwalk_done_src(&walk, p, n);
		n = scatterwalk_next(&walk, len);
		gcm_update_mac(dg, walk.addr, n, buf, &buf_count, ctx);
		scatterwalk_done_src(&walk, n);
		len -= n;
	} while (len);

+4 −4
Original line number Diff line number Diff line
@@ -113,10 +113,10 @@ static void ccm_calculate_auth_mac(struct aead_request *req, u8 mac[])

	do {
		unsigned int n, orig_n;
		const u8 *p, *orig_p;
		const u8 *p;

		orig_p = scatterwalk_next(&walk, assoclen, &orig_n);
		p = orig_p;
		orig_n = scatterwalk_next(&walk, assoclen);
		p = walk.addr;
		n = orig_n;

		while (n > 0) {
@@ -149,7 +149,7 @@ static void ccm_calculate_auth_mac(struct aead_request *req, u8 mac[])
			}
		}

		scatterwalk_done_src(&walk, orig_p, orig_n);
		scatterwalk_done_src(&walk, orig_n);
		assoclen -= orig_n;
	} while (assoclen);
}
+4 −4
Original line number Diff line number Diff line
@@ -83,10 +83,10 @@ static void gcm_calculate_auth_mac(struct aead_request *req, u8 ghash[])

	do {
		unsigned int n, orig_n;
		const u8 *p, *orig_p;
		const u8 *p;

		orig_p = scatterwalk_next(&walk, assoclen, &orig_n);
		p = orig_p;
		orig_n = scatterwalk_next(&walk, assoclen);
		p = walk.addr;
		n = orig_n;

		if (n + buflen < GHASH_BLOCK_SIZE) {
@@ -118,7 +118,7 @@ static void gcm_calculate_auth_mac(struct aead_request *req, u8 ghash[])
				memcpy(&buffer[0], p, buflen);
		}

		scatterwalk_done_src(&walk, orig_p, orig_n);
		scatterwalk_done_src(&walk, orig_n);
		assoclen -= orig_n;
	} while (assoclen);

Loading