diff options
author | Jack Lloyd <[email protected]> | 2017-10-26 20:31:30 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-10-26 22:26:15 -0400 |
commit | e6d45052efedfe49e99adb6318aaf56e0a9e8d7b (patch) | |
tree | c6c3ccd3cff3d04285940bf1d518c809e0653947 /src/lib/block/kasumi | |
parent | 315b002ecf00f6b6bb0f0d5200d1f39a83527e8f (diff) |
Add checks that keyed algorithms are actually keyed before use
Previously calling update or encrypt without calling set_key first
would result in invalid outputs or else crashing.
Diffstat (limited to 'src/lib/block/kasumi')
-rw-r--r-- | src/lib/block/kasumi/kasumi.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/block/kasumi/kasumi.cpp b/src/lib/block/kasumi/kasumi.cpp index a9b5d8274..a40a9d9d5 100644 --- a/src/lib/block/kasumi/kasumi.cpp +++ b/src/lib/block/kasumi/kasumi.cpp @@ -110,6 +110,8 @@ uint16_t FI(uint16_t I, uint16_t K) */ void KASUMI::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { + verify_key_set(m_EK.empty() == false); + for(size_t i = 0; i != blocks; ++i) { uint16_t B0 = load_be<uint16_t>(in, 0); @@ -154,6 +156,8 @@ void KASUMI::encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const */ void KASUMI::decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { + verify_key_set(m_EK.empty() == false); + for(size_t i = 0; i != blocks; ++i) { uint16_t B0 = load_be<uint16_t>(in, 0); |