Skip to content

Commit be3380c

Browse files
committed
Switch to 4 double-rounds (i.e. to ChaCha8) by default.
1 parent 38fd5d9 commit be3380c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/keystream.jl

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ mutable struct ChaChaStream <: AbstractChaChaStream
5454
nonce,
5555
counter = UInt64(0),
5656
position = 1;
57-
doublerounds = 10
57+
doublerounds = 4
5858
)
5959
if doublerounds 0
6060
error("`doublerounds` must be an even positive number")
@@ -75,17 +75,24 @@ end
7575
"""
7676
ChaCha20Stream(args...)
7777
78-
Create a keystream for a ChaCha20 stream cipher.
78+
Create a random stream from the ChaCha20 stream cipher.
7979
"""
8080
ChaCha20Stream(args...) = ChaChaStream(args...; doublerounds=10)
8181

8282
"""
8383
ChaCha12Stream(args...)
8484
85-
Create a keystream for a ChaCha12 stream cipher.
85+
Create a random stream from the ChaCha12 stream cipher.
8686
"""
8787
ChaCha12Stream(args...) = ChaChaStream(args...; doublerounds=6)
8888

89+
"""
90+
ChaCha8Stream(args...)
91+
92+
Create a random stream from the ChaCha8 stream cipher.
93+
"""
94+
ChaCha8Stream(args...) = ChaChaStream(args...; doublerounds=4)
95+
8996
function Base.show(io::IO, rng::ChaChaStream)
9097
msg = """
9198
ChaChaStream(

test/test_keystream.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ using Test
1212
stream = ChaChaStream()
1313
@test stream.nonce == 0
1414
@test stream.position == 1
15-
16-
stream = ChaChaStream(; doublerounds=4)
1715
@test stream.doublerounds == 4
1816

17+
stream = ChaChaStream(; doublerounds=6)
18+
@test stream.doublerounds == 6
19+
1920
# We should receive an error if we try to create a
2021
# keystream with non-positive number of doublerounds
2122
@test_throws ErrorException ChaChaStream(; doublerounds=0)

0 commit comments

Comments
 (0)