|
@@ -37,12 +37,19 @@ static void chacha20_doneon(u32 *state, u8 *dst, const u8 *src,
|
|
u8 buf[CHACHA20_BLOCK_SIZE];
|
|
u8 buf[CHACHA20_BLOCK_SIZE];
|
|
|
|
|
|
while (bytes >= CHACHA20_BLOCK_SIZE * 4) {
|
|
while (bytes >= CHACHA20_BLOCK_SIZE * 4) {
|
|
|
|
+ kernel_neon_begin();
|
|
chacha20_4block_xor_neon(state, dst, src);
|
|
chacha20_4block_xor_neon(state, dst, src);
|
|
|
|
+ kernel_neon_end();
|
|
bytes -= CHACHA20_BLOCK_SIZE * 4;
|
|
bytes -= CHACHA20_BLOCK_SIZE * 4;
|
|
src += CHACHA20_BLOCK_SIZE * 4;
|
|
src += CHACHA20_BLOCK_SIZE * 4;
|
|
dst += CHACHA20_BLOCK_SIZE * 4;
|
|
dst += CHACHA20_BLOCK_SIZE * 4;
|
|
state[12] += 4;
|
|
state[12] += 4;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (!bytes)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ kernel_neon_begin();
|
|
while (bytes >= CHACHA20_BLOCK_SIZE) {
|
|
while (bytes >= CHACHA20_BLOCK_SIZE) {
|
|
chacha20_block_xor_neon(state, dst, src);
|
|
chacha20_block_xor_neon(state, dst, src);
|
|
bytes -= CHACHA20_BLOCK_SIZE;
|
|
bytes -= CHACHA20_BLOCK_SIZE;
|
|
@@ -55,6 +62,7 @@ static void chacha20_doneon(u32 *state, u8 *dst, const u8 *src,
|
|
chacha20_block_xor_neon(state, buf, buf);
|
|
chacha20_block_xor_neon(state, buf, buf);
|
|
memcpy(dst, buf, bytes);
|
|
memcpy(dst, buf, bytes);
|
|
}
|
|
}
|
|
|
|
+ kernel_neon_end();
|
|
}
|
|
}
|
|
|
|
|
|
static int chacha20_neon(struct skcipher_request *req)
|
|
static int chacha20_neon(struct skcipher_request *req)
|
|
@@ -68,11 +76,10 @@ static int chacha20_neon(struct skcipher_request *req)
|
|
if (!may_use_simd() || req->cryptlen <= CHACHA20_BLOCK_SIZE)
|
|
if (!may_use_simd() || req->cryptlen <= CHACHA20_BLOCK_SIZE)
|
|
return crypto_chacha20_crypt(req);
|
|
return crypto_chacha20_crypt(req);
|
|
|
|
|
|
- err = skcipher_walk_virt(&walk, req, true);
|
|
|
|
|
|
+ err = skcipher_walk_virt(&walk, req, false);
|
|
|
|
|
|
crypto_chacha20_init(state, ctx, walk.iv);
|
|
crypto_chacha20_init(state, ctx, walk.iv);
|
|
|
|
|
|
- kernel_neon_begin();
|
|
|
|
while (walk.nbytes > 0) {
|
|
while (walk.nbytes > 0) {
|
|
unsigned int nbytes = walk.nbytes;
|
|
unsigned int nbytes = walk.nbytes;
|
|
|
|
|
|
@@ -83,7 +90,6 @@ static int chacha20_neon(struct skcipher_request *req)
|
|
nbytes);
|
|
nbytes);
|
|
err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
|
err = skcipher_walk_done(&walk, walk.nbytes - nbytes);
|
|
}
|
|
}
|
|
- kernel_neon_end();
|
|
|
|
|
|
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|