aboutsummaryrefslogtreecommitdiff
path: root/tests/test_pk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_pk.cpp')
-rw-r--r--tests/test_pk.cpp30
1 files changed, 8 insertions, 22 deletions
diff --git a/tests/test_pk.cpp b/tests/test_pk.cpp
index 4c6fb6e..dcb412a 100644
--- a/tests/test_pk.cpp
+++ b/tests/test_pk.cpp
@@ -13,7 +13,7 @@ int main() {
TestCase test_case("Public Key Encryption/Decryption Test Case 1");
-std::uint8_t decryption_buffer[::olm_pk_decryption_size()];
+std::uint8_t decryption_buffer[olm_pk_decryption_size()];
OlmPkDecryption *decryption = olm_pk_decryption(decryption_buffer);
std::uint8_t alice_private[32] = {
@@ -23,14 +23,7 @@ std::uint8_t alice_private[32] = {
0xB1, 0x77, 0xFB, 0xA5, 0x1D, 0xB9, 0x2C, 0x2A
};
-/*
-std::uint8_t alice_public[32] = {
- 0x85, 0x20, 0xF0, 0x09, 0x89, 0x30, 0xA7, 0x54,
- 0x74, 0x8B, 0x7D, 0xDC, 0xB4, 0x3E, 0xF7, 0x5A,
- 0x0D, 0xBF, 0x3A, 0x0D, 0x26, 0x38, 0x1A, 0xF4,
- 0xEB, 0xA4, 0xA9, 0x8E, 0xAA, 0x9B, 0x4E, 0x6A
-};
-*/
+const std::uint8_t *alice_public = (std::uint8_t *) "hSDwCYkwp1R0i33ctD73Wg2/Og0mOBr066SpjqqbTmoK";
std::uint8_t bob_private[32] = {
0x5D, 0xAB, 0x08, 0x7E, 0x62, 0x4A, 0x8A, 0x4B,
@@ -39,14 +32,7 @@ std::uint8_t bob_private[32] = {
0x1C, 0x2F, 0x8B, 0x27, 0xFF, 0x88, 0xE0, 0xEB
};
-/*
-std::uint8_t bob_public[32] = {
- 0xDE, 0x9E, 0xDB, 0x7D, 0x7B, 0x7D, 0xC1, 0xB4,
- 0xD3, 0x5B, 0x61, 0xC2, 0xEC, 0xE4, 0x35, 0x37,
- 0x3F, 0x83, 0x43, 0xC8, 0x5B, 0x78, 0x67, 0x4D,
- 0xAD, 0xFC, 0x7E, 0x14, 0x6F, 0x88, 0x2B, 0x4F
-};
-*/
+const std::uint8_t *bob_public = (std::uint8_t *) "3p7bfXt9wbTTW2HC7OQ1Nz+DQ8hbeGdNrfx+FG+IK08K";
std::uint8_t pubkey[::olm_pk_key_length()];
@@ -56,9 +42,9 @@ olm_pk_generate_key(
alice_private, sizeof(alice_private)
);
-//FIXME:assert_equals(alice_public, pubkey, 32);
+assert_equals(alice_public, pubkey, olm_pk_key_length());
-std::uint8_t encryption_buffer[::olm_pk_encryption_size()];
+std::uint8_t encryption_buffer[olm_pk_encryption_size()];
OlmPkEncryption *encryption = olm_pk_encryption(encryption_buffer);
olm_pk_encryption_set_recipient_key(encryption, pubkey, sizeof(pubkey));
@@ -69,8 +55,8 @@ const std::uint8_t *plaintext = (std::uint8_t *) "This is a test";
size_t ciphertext_length = olm_pk_ciphertext_length(encryption, plaintext_length);
std::uint8_t *ciphertext_buffer = (std::uint8_t *) malloc(ciphertext_length);
-std::uint8_t output_buffer[::olm_pk_mac_length(encryption)];
-std::uint8_t ephemeral_key[::olm_pk_key_length()];
+std::uint8_t output_buffer[olm_pk_mac_length(encryption)];
+std::uint8_t ephemeral_key[olm_pk_key_length()];
olm_pk_encrypt(
encryption,
@@ -81,7 +67,7 @@ olm_pk_encrypt(
bob_private, sizeof(bob_private)
);
-//FIXME:assert_equals(bob_public, ephemeral_key, 32);
+assert_equals(bob_public, ephemeral_key, olm_pk_key_length());
size_t max_plaintext_length = olm_pk_max_plaintext_length(decryption, ciphertext_length);
std::uint8_t *plaintext_buffer = (std::uint8_t *) malloc(max_plaintext_length);