mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
Compare commits
4 Commits
2.55.0
...
b6b92da7fd
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6b92da7fd | ||
|
|
fc16a70f7b | ||
|
|
619ec5d9c1 | ||
|
|
6e639f0e6a |
@@ -2,6 +2,7 @@
|
|||||||
Description=I2P Router written in C++
|
Description=I2P Router written in C++
|
||||||
Documentation=man:i2pd(1) https://i2pd.readthedocs.io/en/latest/
|
Documentation=man:i2pd(1) https://i2pd.readthedocs.io/en/latest/
|
||||||
After=network.target
|
After=network.target
|
||||||
|
Wants=yggdrasil.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=i2pd
|
User=i2pd
|
||||||
|
|||||||
@@ -43,18 +43,20 @@ uint8_t encrypted[114] =
|
|||||||
int main ()
|
int main ()
|
||||||
{
|
{
|
||||||
uint8_t buf[114+16];
|
uint8_t buf[114+16];
|
||||||
|
i2p::crypto::AEADChaCha20Poly1305Encryptor encryptor;
|
||||||
// test encryption
|
// test encryption
|
||||||
i2p::crypto::AEADChaCha20Poly1305 ((uint8_t *)text, 114, ad, 12, key, nonce, buf, 114 + 16, true);
|
encryptor.Encrypt ((uint8_t *)text, 114, ad, 12, key, nonce, buf, 114 + 16);
|
||||||
assert (memcmp (buf, encrypted, 114) == 0);
|
assert (memcmp (buf, encrypted, 114) == 0);
|
||||||
assert (memcmp (buf + 114, tag, 16) == 0);
|
assert (memcmp (buf + 114, tag, 16) == 0);
|
||||||
// test decryption
|
// test decryption
|
||||||
uint8_t buf1[114];
|
uint8_t buf1[114];
|
||||||
assert (i2p::crypto::AEADChaCha20Poly1305 (buf, 114, ad, 12, key, nonce, buf1, 114, false));
|
i2p::crypto::AEADChaCha20Poly1305Decryptor decryptor;
|
||||||
|
assert (decryptor.Decrypt (buf, 114, ad, 12, key, nonce, buf1, 114));
|
||||||
assert (memcmp (buf1, text, 114) == 0);
|
assert (memcmp (buf1, text, 114) == 0);
|
||||||
// test encryption of multiple buffers
|
// test encryption of multiple buffers
|
||||||
memcpy (buf, text, 114);
|
memcpy (buf, text, 114);
|
||||||
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) };
|
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) };
|
||||||
i2p::crypto::AEADChaCha20Poly1305Encrypt (bufs, key, nonce, buf + 114);
|
encryptor.Encrypt (bufs, key, nonce, buf + 114);
|
||||||
i2p::crypto::AEADChaCha20Poly1305 (buf, 114, nullptr, 0, key, nonce, buf1, 114, false);
|
decryptor.Decrypt (buf, 114, nullptr, 0, key, nonce, buf1, 114);
|
||||||
assert (memcmp (buf1, text, 114) == 0);
|
assert (memcmp (buf1, text, 114) == 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user