API
Keystream types
ChaChaCiphers.AbstractChaChaStream
— TypeAbstractChaChaStream
Abstract parent type for ChaCha keystreams.
ChaChaCiphers.CUDAChaChaStream
— TypeCUDAChaChaStream <: AbstractChaChaStream
CUDAChaChaStream
is a CUDA-compatible ChaCha keystream generator for GPU CRNG.
Examples
Create a CUDAChaChaStream
with a randomized key, and sample some random numbers with it:
julia> rng = CUDAChaChaStream();
julia> x = CuVector{Float32}(undef, 2^10);
See also: ChaChaStream
ChaChaCiphers.ChaChaStream
— TypeChaChaStream <: AbstractChaChaStream
ChaChaStream
provides access to the keystream generated by the ChaCha stream cipher. It can be used as a cryptographically secure random number generator (CRNG) for Julia's random number generation functions.
Examples
Create a ChaChaStream
with a randomly-generated key and nonce:
julia> stream = ChaCha20Stream();
Create a ChaChaStream
with a pre-specified key and nonce, and use it to generate random data:
julia> key = UInt32.([
0xe2e39848, 0x70bb974d, 0x845f88b4, 0xb30725e4,
0x15c309dc, 0x72d545bb, 0x466e99e3, 0x6a759f91
]);
julia> nonce = UInt64(1234);
julia> stream = ChaCha20Stream(key, nonce);
julia> randn(stream)
0.7689072580509484
julia> randstring(stream, 'a':'z', 8)
"klmptewr"
See also: CUDAChaChaStream
ChaChaCiphers.CUDAChaCha12Stream
— MethodCUDAChaCha12Stream
Create a CUDA-compatible keystream for a ChaCha12 stream cipher.
ChaChaCiphers.CUDAChaCha20Stream
— MethodCUDAChaCha20Stream
Create a CUDA-compatible keystream for a ChaCha20 stream cipher.
ChaChaCiphers.ChaCha12Stream
— MethodChaCha12Stream(args...)
Create a keystream for a ChaCha12 stream cipher.
ChaChaCiphers.ChaCha20Stream
— MethodChaCha20Stream(args...)
Create a keystream for a ChaCha20 stream cipher.
Keystream helpers
ChaChaCiphers.ChaChaState
— TypeChaChaState
A NamedTuple
storing the current state of a ChaCha keystream. ChaChaState
can be used to save and restore the state of a keystream.
ChaChaCiphers.getstate
— Methodgetstate(stream::AbstractChaChaStream)
Return a NamedTuple
containing enough state of the input AbstractChaChaStream
to be able to reproduce it.
Encryption and decryption
ChaChaCiphers.decrypt!
— Methoddecrypt(stream::ChaChaStream, x)
decrypt!(stream::ChaChaStream, x)
Decrypt an encrypted vector x
using the keystream from a ChaChaStream
.
ChaChaCiphers.encrypt!
— Methodencrypt(stream::ChaChaStream, x)
encrypt!(stream::ChaChaStream, x)
Encrypt a vector or string x
using the keystream from a ChaChaStream
.
Index
ChaChaCiphers.AbstractChaChaStream
ChaChaCiphers.CUDAChaChaStream
ChaChaCiphers.ChaChaState
ChaChaCiphers.ChaChaStream
ChaChaCiphers.CUDAChaCha12Stream
ChaChaCiphers.CUDAChaCha20Stream
ChaChaCiphers.ChaCha12Stream
ChaChaCiphers.ChaCha20Stream
ChaChaCiphers.decrypt!
ChaChaCiphers.encrypt!
ChaChaCiphers.getstate