Skip to content

Commit fc16a70

Browse files
committed
use AEADChaCha20Poly1305Encryptor and AEADChaCha20Poly1305Decryptor for test
1 parent 619ec5d commit fc16a70

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/test-aeadchacha20poly1305.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,20 @@ uint8_t encrypted[114] =
4343
int main ()
4444
{
4545
uint8_t buf[114+16];
46+
i2p::crypto::AEADChaCha20Poly1305Encryptor encryptor;
4647
// test encryption
47-
i2p::crypto::AEADChaCha20Poly1305 ((uint8_t *)text, 114, ad, 12, key, nonce, buf, 114 + 16, true);
48+
encryptor.Encrypt ((uint8_t *)text, 114, ad, 12, key, nonce, buf, 114 + 16);
4849
assert (memcmp (buf, encrypted, 114) == 0);
4950
assert (memcmp (buf + 114, tag, 16) == 0);
5051
// test decryption
5152
uint8_t buf1[114];
52-
assert (i2p::crypto::AEADChaCha20Poly1305 (buf, 114, ad, 12, key, nonce, buf1, 114, false));
53+
i2p::crypto::AEADChaCha20Poly1305Decryptor decryptor;
54+
assert (decryptor.Decrypt (buf, 114, ad, 12, key, nonce, buf1, 114));
5355
assert (memcmp (buf1, text, 114) == 0);
5456
// test encryption of multiple buffers
5557
memcpy (buf, text, 114);
5658
std::vector<std::pair<uint8_t*, std::size_t> > bufs{ std::make_pair (buf, 20), std::make_pair (buf + 20, 10), std::make_pair (buf + 30, 70), std::make_pair (buf + 100, 14) };
57-
i2p::crypto::AEADChaCha20Poly1305Encryptor encryptor;
5859
encryptor.Encrypt (bufs, key, nonce, buf + 114);
59-
i2p::crypto::AEADChaCha20Poly1305 (buf, 114, nullptr, 0, key, nonce, buf1, 114, false);
60+
decryptor.Decrypt (buf, 114, nullptr, 0, key, nonce, buf1, 114);
6061
assert (memcmp (buf1, text, 114) == 0);
6162
}

0 commit comments

Comments
 (0)