mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 11:55:06 -05:00
siv: return error if key is not set
Avoid encryption or decryption using uninitialized data, or causing a crash, if a key was not set for the SIV instance.
This commit is contained in:
@@ -149,6 +149,17 @@ test_unit(void)
|
||||
|
||||
TEST_CHECK(SIV_GetKeyLength(tests[i].algorithm) == tests[i].key_length);
|
||||
|
||||
r = SIV_Encrypt(siv, tests[i].nonce, tests[i].nonce_length,
|
||||
tests[i].assoc, tests[i].assoc_length,
|
||||
tests[i].plaintext, tests[i].plaintext_length,
|
||||
ciphertext, tests[i].ciphertext_length);
|
||||
TEST_CHECK(!r);
|
||||
r = SIV_Decrypt(siv, tests[i].nonce, tests[i].nonce_length,
|
||||
tests[i].assoc, tests[i].assoc_length,
|
||||
tests[i].ciphertext, tests[i].ciphertext_length,
|
||||
plaintext, tests[i].plaintext_length);
|
||||
TEST_CHECK(!r);
|
||||
|
||||
for (j = -1; j < 1024; j++) {
|
||||
r = SIV_SetKey(siv, tests[i].key, j);
|
||||
TEST_CHECK(r == (j == tests[i].key_length));
|
||||
|
||||
Reference in New Issue
Block a user