crypto: incorporate C implementation of ARC4

Incorporate the LGPL v2.1 licensed implementation of ARC4, taken from
the Nettle project (,
commit 3e7a480a1e351884), and tweak it a bit so we don't have to
operate on a skip buffer to fast forward the stream cipher, but can
simply invoke it with NULL dst or src arguments to achieve the same.

This removes the dependency on the OS's implementation of ecb(arc4),
which may be going away, and which is not usually accelerated in the
first place.

Signed-off-by: Ard Biesheuvel <>
3 files changed