drm/panfrost: Remove set but not used variable 'bo'
[linux/fpc-iii.git] / lib / crypto / libchacha.c
blobdabc3accae05135924d00462f3eba8b9fd7ef37a
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * The ChaCha stream cipher (RFC7539)
5 * Copyright (C) 2015 Martin Willi
6 */
8 #include <linux/kernel.h>
9 #include <linux/export.h>
10 #include <linux/module.h>
12 #include <crypto/algapi.h> // for crypto_xor_cpy
13 #include <crypto/chacha.h>
15 void chacha_crypt_generic(u32 *state, u8 *dst, const u8 *src,
16 unsigned int bytes, int nrounds)
18 /* aligned to potentially speed up crypto_xor() */
19 u8 stream[CHACHA_BLOCK_SIZE] __aligned(sizeof(long));
21 while (bytes >= CHACHA_BLOCK_SIZE) {
22 chacha_block_generic(state, stream, nrounds);
23 crypto_xor_cpy(dst, src, stream, CHACHA_BLOCK_SIZE);
24 bytes -= CHACHA_BLOCK_SIZE;
25 dst += CHACHA_BLOCK_SIZE;
26 src += CHACHA_BLOCK_SIZE;
28 if (bytes) {
29 chacha_block_generic(state, stream, nrounds);
30 crypto_xor_cpy(dst, src, stream, bytes);
33 EXPORT_SYMBOL(chacha_crypt_generic);
35 MODULE_LICENSE("GPL");