From 2835110cee6c9a47b869a13c069d07d9ed9b2833 Mon Sep 17 00:00:00 2001 From: David Baker Date: Mon, 1 Oct 2018 20:01:47 +0100 Subject: Remove trailing letter 'K's from the test pubkeys base64 encoded newlines somehow? --- tests/test_pk.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_pk.cpp b/tests/test_pk.cpp index ab1f477..ee12603 100644 --- a/tests/test_pk.cpp +++ b/tests/test_pk.cpp @@ -23,7 +23,7 @@ std::uint8_t alice_private[32] = { 0xB1, 0x77, 0xFB, 0xA5, 0x1D, 0xB9, 0x2C, 0x2A }; -const std::uint8_t *alice_public = (std::uint8_t *) "hSDwCYkwp1R0i33ctD73Wg2/Og0mOBr066SpjqqbTmoK"; +const std::uint8_t *alice_public = (std::uint8_t *) "hSDwCYkwp1R0i33ctD73Wg2/Og0mOBr066SpjqqbTmo"; std::uint8_t bob_private[32] = { 0x5D, 0xAB, 0x08, 0x7E, 0x62, 0x4A, 0x8A, 0x4B, @@ -32,7 +32,7 @@ std::uint8_t bob_private[32] = { 0x1C, 0x2F, 0x8B, 0x27, 0xFF, 0x88, 0xE0, 0xEB }; -const std::uint8_t *bob_public = (std::uint8_t *) "3p7bfXt9wbTTW2HC7OQ1Nz+DQ8hbeGdNrfx+FG+IK08K"; +const std::uint8_t *bob_public = (std::uint8_t *) "3p7bfXt9wbTTW2HC7OQ1Nz+DQ8hbeGdNrfx+FG+IK08"; std::uint8_t pubkey[::olm_pk_key_length()]; -- cgit v1.2.3 From 0346145a813cfb719fdf218956cb2f29030134a8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 2 Oct 2018 12:02:56 +0100 Subject: Work with PkDecryption keys by their private keys Change interface to allow the app to get the private part of the key and instantiate a decryption object from just the private part of the key. Changes the function generating a key from random bytes to be initialising a key with a private key (because it's exactly the same thing). Exports & imports private key parts as ArrayBuffer at JS level rather than base64 assuming we are moving that way in general. --- tests/test_pk.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_pk.cpp b/tests/test_pk.cpp index ee12603..42cc8c9 100644 --- a/tests/test_pk.cpp +++ b/tests/test_pk.cpp @@ -36,7 +36,7 @@ const std::uint8_t *bob_public = (std::uint8_t *) "3p7bfXt9wbTTW2HC7OQ1Nz+DQ8hbe std::uint8_t pubkey[::olm_pk_key_length()]; -olm_pk_generate_key( +olm_pk_key_from_private( decryption, pubkey, sizeof(pubkey), alice_private, sizeof(alice_private) @@ -44,6 +44,11 @@ olm_pk_generate_key( assert_equals(alice_public, pubkey, olm_pk_key_length()); +uint8_t *alice_private_back_out = (uint8_t *)malloc(olm_pk_private_key_length()); +olm_pk_get_private_key(decryption, alice_private_back_out, olm_pk_private_key_length()); +assert_equals(alice_private, alice_private_back_out, olm_pk_private_key_length()); +free(alice_private_back_out); + std::uint8_t encryption_buffer[olm_pk_encryption_size()]; OlmPkEncryption *encryption = olm_pk_encryption(encryption_buffer); @@ -105,7 +110,7 @@ const std::uint8_t *alice_public = (std::uint8_t *) "hSDwCYkwp1R0i33ctD73Wg2/Og0 std::uint8_t pubkey[olm_pk_key_length()]; -olm_pk_generate_key( +olm_pk_key_from_private( decryption, pubkey, sizeof(pubkey), alice_private, sizeof(alice_private) -- cgit v1.2.3