aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/stream/salsa20/salsa20.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/stream/salsa20/salsa20.cpp')
-rw-r--r--src/lib/stream/salsa20/salsa20.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/stream/salsa20/salsa20.cpp b/src/lib/stream/salsa20/salsa20.cpp
index 0d8942789..60bf19285 100644
--- a/src/lib/stream/salsa20/salsa20.cpp
+++ b/src/lib/stream/salsa20/salsa20.cpp
@@ -158,8 +158,7 @@ void Salsa20::key_schedule(const byte key[], size_t length)
m_position = 0;
- const byte ZERO[8] = { 0 };
- set_iv(ZERO, sizeof(ZERO));
+ set_iv(nullptr, 0); // all-zero IV
}
/*
@@ -170,7 +169,13 @@ void Salsa20::set_iv(const byte iv[], size_t length)
if(!valid_iv_length(length))
throw Invalid_IV_Length(name(), length);
- if(length == 8)
+ if(length == 0)
+ {
+ // Salsa20 null IV
+ m_state[6] = 0;
+ m_state[7] = 0;
+ }
+ else if(length == 8)
{
// Salsa20
m_state[6] = load_le<u32bit>(iv, 0);