aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/account.cpp28
-rw-r--r--src/cipher.cpp16
-rw-r--r--src/crypto.cpp66
-rw-r--r--src/olm.cpp10
-rw-r--r--src/pickle.cpp54
-rw-r--r--src/ratchet.cpp15
-rw-r--r--src/session.cpp43
-rw-r--r--src/utility.cpp6
8 files changed, 128 insertions, 110 deletions
diff --git a/src/account.cpp b/src/account.cpp
index 9512068..c77f95c 100644
--- a/src/account.cpp
+++ b/src/account.cpp
@@ -24,10 +24,10 @@ olm::Account::Account(
olm::OneTimeKey const * olm::Account::lookup_key(
- olm::Curve25519PublicKey const & public_key
+ _olm_curve25519_public_key const & public_key
) {
for (olm::OneTimeKey const & key : one_time_keys) {
- if (olm::array_equal(key.key.public_key, public_key.public_key)) {
+ if (olm::array_equal(key.key.public_key.public_key, public_key.public_key)) {
return &key;
}
}
@@ -35,11 +35,11 @@ olm::OneTimeKey const * olm::Account::lookup_key(
}
std::size_t olm::Account::remove_key(
- olm::Curve25519PublicKey const & public_key
+ _olm_curve25519_public_key const & public_key
) {
OneTimeKey * i;
for (i = one_time_keys.begin(); i != one_time_keys.end(); ++i) {
- if (olm::array_equal(i->key.public_key, public_key.public_key)) {
+ if (olm::array_equal(i->key.public_key.public_key, public_key.public_key)) {
std::uint32_t id = i->id;
one_time_keys.erase(i);
return id;
@@ -60,9 +60,9 @@ std::size_t olm::Account::new_account(
return std::size_t(-1);
}
- olm::ed25519_generate_key(random, identity_keys.ed25519_key);
+ _olm_crypto_ed25519_generate_key(random, &identity_keys.ed25519_key);
random += ED25519_RANDOM_LENGTH;
- olm::curve25519_generate_key(random, identity_keys.curve25519_key);
+ _olm_crypto_curve25519_generate_key(random, &identity_keys.curve25519_key);
return 0;
}
@@ -118,16 +118,16 @@ std::size_t olm::Account::get_identity_json(
pos = write_string(pos, KEY_JSON_CURVE25519);
*(pos++) = '\"';
pos = olm::encode_base64(
- identity_keys.curve25519_key.public_key,
- sizeof(identity_keys.curve25519_key.public_key),
+ identity_keys.curve25519_key.public_key.public_key,
+ sizeof(identity_keys.curve25519_key.public_key.public_key),
pos
);
*(pos++) = '\"'; *(pos++) = ',';
pos = write_string(pos, KEY_JSON_ED25519);
*(pos++) = '\"';
pos = olm::encode_base64(
- identity_keys.ed25519_key.public_key,
- sizeof(identity_keys.ed25519_key.public_key),
+ identity_keys.ed25519_key.public_key.public_key,
+ sizeof(identity_keys.ed25519_key.public_key.public_key),
pos
);
*(pos++) = '\"'; *(pos++) = '}';
@@ -149,8 +149,8 @@ std::size_t olm::Account::sign(
last_error = OlmErrorCode::OLM_OUTPUT_BUFFER_TOO_SMALL;
return std::size_t(-1);
}
- olm::ed25519_sign(
- identity_keys.ed25519_key, message, message_length, signature
+ _olm_crypto_ed25519_sign(
+ &identity_keys.ed25519_key, message, message_length, signature
);
return this->signature_length();
}
@@ -202,7 +202,7 @@ std::size_t olm::Account::get_one_time_keys_json(
pos = olm::encode_base64(key_id, sizeof(key_id), pos);
*(pos++) = '\"'; *(pos++) = ':'; *(pos++) = '\"';
pos = olm::encode_base64(
- key.key.public_key, sizeof(key.key.public_key), pos
+ key.key.public_key.public_key, sizeof(key.key.public_key.public_key), pos
);
*(pos++) = '\"';
sep = ',';
@@ -253,7 +253,7 @@ std::size_t olm::Account::generate_one_time_keys(
OneTimeKey & key = *one_time_keys.insert(one_time_keys.begin());
key.id = ++next_one_time_key_id;
key.published = false;
- olm::curve25519_generate_key(random, key.key);
+ _olm_crypto_curve25519_generate_key(random, &key.key);
random += CURVE25519_RANDOM_LENGTH;
}
return number_of_keys;
diff --git a/src/cipher.cpp b/src/cipher.cpp
index 8e3d7a5..6b53690 100644
--- a/src/cipher.cpp
+++ b/src/cipher.cpp
@@ -13,7 +13,7 @@
* limitations under the License.
*/
#include "olm/cipher.h"
-#include "olm/crypto.hh"
+#include "olm/crypto.h"
#include "olm/memory.hh"
#include <cstring>
@@ -22,9 +22,9 @@ const std::size_t HMAC_KEY_LENGTH = 32;
namespace {
struct DerivedKeys {
- olm::Aes256Key aes_key;
+ _olm_aes256_key aes_key;
std::uint8_t mac_key[HMAC_KEY_LENGTH];
- olm::Aes256Iv aes_iv;
+ _olm_aes256_iv aes_iv;
};
@@ -58,7 +58,7 @@ size_t aes_sha_256_cipher_mac_length(const struct _olm_cipher *cipher) {
size_t aes_sha_256_cipher_encrypt_ciphertext_length(
const struct _olm_cipher *cipher, size_t plaintext_length
) {
- return olm::aes_encrypt_cbc_length(plaintext_length);
+ return _olm_crypto_aes_encrypt_cbc_length(plaintext_length);
}
size_t aes_sha_256_cipher_encrypt(
@@ -80,8 +80,8 @@ size_t aes_sha_256_cipher_encrypt(
derive_keys(c->kdf_info, c->kdf_info_length, key, key_length, keys);
- olm::aes_encrypt_cbc(
- keys.aes_key, keys.aes_iv, plaintext, plaintext_length, ciphertext
+ _olm_crypto_aes_encrypt_cbc(
+ &keys.aes_key, &keys.aes_iv, plaintext, plaintext_length, ciphertext
);
_olm_crypto_hmac_sha256(
@@ -126,8 +126,8 @@ size_t aes_sha_256_cipher_decrypt(
return std::size_t(-1);
}
- std::size_t plaintext_length = olm::aes_decrypt_cbc(
- keys.aes_key, keys.aes_iv, ciphertext, ciphertext_length, plaintext
+ std::size_t plaintext_length = _olm_crypto_aes_decrypt_cbc(
+ &keys.aes_key, &keys.aes_iv, ciphertext, ciphertext_length, plaintext
);
olm::unset(keys);
diff --git a/src/crypto.cpp b/src/crypto.cpp
index 0b08c54..5095c79 100644
--- a/src/crypto.cpp
+++ b/src/crypto.cpp
@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "olm/crypto.hh"
+#include "olm/crypto.h"
#include "olm/memory.hh"
#include <cstring>
@@ -100,80 +100,86 @@ inline static void hmac_sha256_final(
} // namespace
-void olm::curve25519_generate_key(
- std::uint8_t const * random_32_bytes,
- olm::Curve25519KeyPair & key_pair
+void _olm_crypto_curve25519_generate_key(
+ uint8_t const * random_32_bytes,
+ struct _olm_curve25519_key_pair *key_pair
) {
- std::memcpy(key_pair.private_key, random_32_bytes, CURVE25519_KEY_LENGTH);
+ std::memcpy(
+ key_pair->private_key.private_key, random_32_bytes,
+ CURVE25519_KEY_LENGTH
+ );
::curve25519_donna(
- key_pair.public_key, key_pair.private_key, CURVE25519_BASEPOINT
+ key_pair->public_key.public_key,
+ key_pair->private_key.private_key,
+ CURVE25519_BASEPOINT
);
}
-void olm::curve25519_shared_secret(
- olm::Curve25519KeyPair const & our_key,
- olm::Curve25519PublicKey const & their_key,
+void _olm_crypto_curve25519_shared_secret(
+ const struct _olm_curve25519_key_pair *our_key,
+ const struct _olm_curve25519_public_key * their_key,
std::uint8_t * output
) {
- ::curve25519_donna(output, our_key.private_key, their_key.public_key);
+ ::curve25519_donna(output, our_key->private_key.private_key, their_key->public_key);
}
-void olm::ed25519_generate_key(
+void _olm_crypto_ed25519_generate_key(
std::uint8_t const * random_32_bytes,
- olm::Ed25519KeyPair & key_pair
+ struct _olm_ed25519_key_pair *key_pair
) {
::ed25519_create_keypair(
- key_pair.public_key, key_pair.private_key,
+ key_pair->public_key.public_key, key_pair->private_key.private_key,
random_32_bytes
);
}
-void olm::ed25519_sign(
- olm::Ed25519KeyPair const & our_key,
+void _olm_crypto_ed25519_sign(
+ const struct _olm_ed25519_key_pair *our_key,
std::uint8_t const * message, std::size_t message_length,
std::uint8_t * output
) {
::ed25519_sign(
output,
message, message_length,
- our_key.public_key, our_key.private_key
+ our_key->public_key.public_key,
+ our_key->private_key.private_key
);
}
-bool olm::ed25519_verify(
- olm::Ed25519PublicKey const & their_key,
+int _olm_crypto_ed25519_verify(
+ const struct _olm_ed25519_public_key *their_key,
std::uint8_t const * message, std::size_t message_length,
std::uint8_t const * signature
) {
return 0 != ::ed25519_verify(
signature,
message, message_length,
- their_key.public_key
+ their_key->public_key
);
}
-std::size_t olm::aes_encrypt_cbc_length(
+std::size_t _olm_crypto_aes_encrypt_cbc_length(
std::size_t input_length
) {
return input_length + AES_BLOCK_LENGTH - input_length % AES_BLOCK_LENGTH;
}
-void olm::aes_encrypt_cbc(
- olm::Aes256Key const & key,
- olm::Aes256Iv const & iv,
+void _olm_crypto_aes_encrypt_cbc(
+ _olm_aes256_key const *key,
+ _olm_aes256_iv const *iv,
std::uint8_t const * input, std::size_t input_length,
std::uint8_t * output
) {
std::uint32_t key_schedule[AES_KEY_SCHEDULE_LENGTH];
- ::aes_key_setup(key.key, key_schedule, AES_KEY_BITS);
+ ::aes_key_setup(key->key, key_schedule, AES_KEY_BITS);
std::uint8_t input_block[AES_BLOCK_LENGTH];
- std::memcpy(input_block, iv.iv, AES_BLOCK_LENGTH);
+ std::memcpy(input_block, iv->iv, AES_BLOCK_LENGTH);
while (input_length >= AES_BLOCK_LENGTH) {
xor_block<AES_BLOCK_LENGTH>(input_block, input);
::aes_encrypt(input_block, output, key_schedule, AES_KEY_BITS);
@@ -195,17 +201,17 @@ void olm::aes_encrypt_cbc(
}
-std::size_t olm::aes_decrypt_cbc(
- olm::Aes256Key const & key,
- olm::Aes256Iv const & iv,
+std::size_t _olm_crypto_aes_decrypt_cbc(
+ _olm_aes256_key const *key,
+ _olm_aes256_iv const *iv,
std::uint8_t const * input, std::size_t input_length,
std::uint8_t * output
) {
std::uint32_t key_schedule[AES_KEY_SCHEDULE_LENGTH];
- ::aes_key_setup(key.key, key_schedule, AES_KEY_BITS);
+ ::aes_key_setup(key->key, key_schedule, AES_KEY_BITS);
std::uint8_t block1[AES_BLOCK_LENGTH];
std::uint8_t block2[AES_BLOCK_LENGTH];
- std::memcpy(block1, iv.iv, AES_BLOCK_LENGTH);
+ std::memcpy(block1, iv->iv, AES_BLOCK_LENGTH);
for (std::size_t i = 0; i < input_length; i += AES_BLOCK_LENGTH) {
std::memcpy(block2, &input[i], AES_BLOCK_LENGTH);
::aes_decrypt(&input[i], &output[i], key_schedule, AES_KEY_BITS);
diff --git a/src/olm.cpp b/src/olm.cpp
index 3fe9c5e..d3af19c 100644
--- a/src/olm.cpp
+++ b/src/olm.cpp
@@ -442,8 +442,8 @@ size_t olm_create_outbound_session(
from_c(session)->last_error = OlmErrorCode::OLM_INVALID_BASE64;
return std::size_t(-1);
}
- olm::Curve25519PublicKey identity_key;
- olm::Curve25519PublicKey one_time_key;
+ _olm_curve25519_public_key identity_key;
+ _olm_curve25519_public_key one_time_key;
olm::decode_base64(id_key, id_key_length, identity_key.public_key);
olm::decode_base64(ot_key, ot_key_length, one_time_key.public_key);
@@ -487,7 +487,7 @@ size_t olm_create_inbound_session_from(
from_c(session)->last_error = OlmErrorCode::OLM_INVALID_BASE64;
return std::size_t(-1);
}
- olm::Curve25519PublicKey identity_key;
+ _olm_curve25519_public_key identity_key;
olm::decode_base64(id_key, id_key_length, identity_key.public_key);
std::size_t raw_length = b64_input(
@@ -564,7 +564,7 @@ size_t olm_matches_inbound_session_from(
from_c(session)->last_error = OlmErrorCode::OLM_INVALID_BASE64;
return std::size_t(-1);
}
- olm::Curve25519PublicKey identity_key;
+ _olm_curve25519_public_key identity_key;
olm::decode_base64(id_key, id_key_length, identity_key.public_key);
std::size_t raw_length = b64_input(
@@ -720,7 +720,7 @@ size_t olm_ed25519_verify(
from_c(utility)->last_error = OlmErrorCode::OLM_INVALID_BASE64;
return std::size_t(-1);
}
- olm::Ed25519PublicKey verify_key;
+ _olm_ed25519_public_key verify_key;
olm::decode_base64(from_c(key), key_length, verify_key.public_key);
std::size_t raw_signature_length = b64_input(
from_c(signature), signature_length, from_c(utility)->last_error
diff --git a/src/pickle.cpp b/src/pickle.cpp
index fc3e2b4..e9708b7 100644
--- a/src/pickle.cpp
+++ b/src/pickle.cpp
@@ -71,7 +71,7 @@ std::uint8_t const * olm::unpickle_bytes(
std::size_t olm::pickle_length(
- const olm::Curve25519PublicKey & value
+ const _olm_curve25519_public_key & value
) {
return sizeof(value.public_key);
}
@@ -79,7 +79,7 @@ std::size_t olm::pickle_length(
std::uint8_t * olm::pickle(
std::uint8_t * pos,
- const olm::Curve25519PublicKey & value
+ const _olm_curve25519_public_key & value
) {
pos = olm::pickle_bytes(
pos, value.public_key, sizeof(value.public_key)
@@ -90,7 +90,7 @@ std::uint8_t * olm::pickle(
std::uint8_t const * olm::unpickle(
std::uint8_t const * pos, std::uint8_t const * end,
- olm::Curve25519PublicKey & value
+ _olm_curve25519_public_key & value
) {
pos = olm::unpickle_bytes(
pos, end, value.public_key, sizeof(value.public_key)
@@ -101,21 +101,24 @@ std::uint8_t const * olm::unpickle(
std::size_t olm::pickle_length(
- const olm::Curve25519KeyPair & value
+ const _olm_curve25519_key_pair & value
) {
- return sizeof(value.public_key) + sizeof(value.private_key);
+ return sizeof(value.public_key.public_key)
+ + sizeof(value.private_key.private_key);
}
std::uint8_t * olm::pickle(
std::uint8_t * pos,
- const olm::Curve25519KeyPair & value
+ const _olm_curve25519_key_pair & value
) {
pos = olm::pickle_bytes(
- pos, value.public_key, sizeof(value.public_key)
+ pos, value.public_key.public_key,
+ sizeof(value.public_key.public_key)
);
pos = olm::pickle_bytes(
- pos, value.private_key, sizeof(value.private_key)
+ pos, value.private_key.private_key,
+ sizeof(value.private_key.private_key)
);
return pos;
}
@@ -123,19 +126,21 @@ std::uint8_t * olm::pickle(
std::uint8_t const * olm::unpickle(
std::uint8_t const * pos, std::uint8_t const * end,
- olm::Curve25519KeyPair & value
+ _olm_curve25519_key_pair & value
) {
pos = olm::unpickle_bytes(
- pos, end, value.public_key, sizeof(value.public_key)
+ pos, end, value.public_key.public_key,
+ sizeof(value.public_key.public_key)
);
pos = olm::unpickle_bytes(
- pos, end, value.private_key, sizeof(value.private_key)
+ pos, end, value.private_key.private_key,
+ sizeof(value.private_key.private_key)
);
return pos;
}
std::size_t olm::pickle_length(
- const olm::Ed25519PublicKey & value
+ const _olm_ed25519_public_key & value
) {
return sizeof(value.public_key);
}
@@ -143,7 +148,7 @@ std::size_t olm::pickle_length(
std::uint8_t * olm::pickle(
std::uint8_t * pos,
- const olm::Ed25519PublicKey & value
+ const _olm_ed25519_public_key & value
) {
pos = olm::pickle_bytes(
pos, value.public_key, sizeof(value.public_key)
@@ -154,7 +159,7 @@ std::uint8_t * olm::pickle(
std::uint8_t const * olm::unpickle(
std::uint8_t const * pos, std::uint8_t const * end,
- olm::Ed25519PublicKey & value
+ _olm_ed25519_public_key & value
) {
pos = olm::unpickle_bytes(
pos, end, value.public_key, sizeof(value.public_key)
@@ -165,21 +170,24 @@ std::uint8_t const * olm::unpickle(
std::size_t olm::pickle_length(
- const olm::Ed25519KeyPair & value
+ const _olm_ed25519_key_pair & value
) {
- return sizeof(value.public_key) + sizeof(value.private_key);
+ return sizeof(value.public_key.public_key)
+ + sizeof(value.private_key.private_key);
}
std::uint8_t * olm::pickle(
std::uint8_t * pos,
- const olm::Ed25519KeyPair & value
+ const _olm_ed25519_key_pair & value
) {
pos = olm::pickle_bytes(
- pos, value.public_key, sizeof(value.public_key)
+ pos, value.public_key.public_key,
+ sizeof(value.public_key.public_key)
);
pos = olm::pickle_bytes(
- pos, value.private_key, sizeof(value.private_key)
+ pos, value.private_key.private_key,
+ sizeof(value.private_key.private_key)
);
return pos;
}
@@ -187,13 +195,15 @@ std::uint8_t * olm::pickle(
std::uint8_t const * olm::unpickle(
std::uint8_t const * pos, std::uint8_t const * end,
- olm::Ed25519KeyPair & value
+ _olm_ed25519_key_pair & value
) {
pos = olm::unpickle_bytes(
- pos, end, value.public_key, sizeof(value.public_key)
+ pos, end, value.public_key.public_key,
+ sizeof(value.public_key.public_key)
);
pos = olm::unpickle_bytes(
- pos, end, value.private_key, sizeof(value.private_key)
+ pos, end, value.private_key.private_key,
+ sizeof(value.private_key.private_key)
);
return pos;
}
diff --git a/src/ratchet.cpp b/src/ratchet.cpp
index 57cb385..279c4c0 100644
--- a/src/ratchet.cpp
+++ b/src/ratchet.cpp
@@ -41,14 +41,14 @@ static const std::size_t MAX_MESSAGE_GAP = 2000;
*/
static void create_chain_key(
olm::SharedKey const & root_key,
- olm::Curve25519KeyPair const & our_key,
- olm::Curve25519PublicKey const & their_key,
+ _olm_curve25519_key_pair const & our_key,
+ _olm_curve25519_public_key const & their_key,
olm::KdfInfo const & info,
olm::SharedKey & new_root_key,
olm::ChainKey & new_chain_key
) {
olm::SharedKey secret;
- olm::curve25519_shared_secret(our_key, their_key, secret);
+ _olm_crypto_curve25519_shared_secret(&our_key, &their_key, secret);
std::uint8_t derived_secrets[2 * olm::OLM_SHARED_KEY_LENGTH];
_olm_crypto_hkdf_sha256(
secret, sizeof(secret),
@@ -189,7 +189,7 @@ olm::Ratchet::Ratchet(
void olm::Ratchet::initialise_as_bob(
std::uint8_t const * shared_secret, std::size_t shared_secret_length,
- olm::Curve25519PublicKey const & their_ratchet_key
+ _olm_curve25519_public_key const & their_ratchet_key
) {
std::uint8_t derived_secrets[2 * olm::OLM_SHARED_KEY_LENGTH];
_olm_crypto_hkdf_sha256(
@@ -210,7 +210,7 @@ void olm::Ratchet::initialise_as_bob(
void olm::Ratchet::initialise_as_alice(
std::uint8_t const * shared_secret, std::size_t shared_secret_length,
- olm::Curve25519KeyPair const & our_ratchet_key
+ _olm_curve25519_key_pair const & our_ratchet_key
) {
std::uint8_t derived_secrets[2 * olm::OLM_SHARED_KEY_LENGTH];
_olm_crypto_hkdf_sha256(
@@ -437,7 +437,7 @@ std::size_t olm::Ratchet::encrypt(
if (sender_chain.empty()) {
sender_chain.insert();
- olm::curve25519_generate_key(random, sender_chain[0].ratchet_key);
+ _olm_crypto_curve25519_generate_key(random, &sender_chain[0].ratchet_key);
create_chain_key(
root_key,
sender_chain[0].ratchet_key,
@@ -456,7 +456,8 @@ std::size_t olm::Ratchet::encrypt(
plaintext_length
);
std::uint32_t counter = keys.index;
- Curve25519PublicKey const & ratchet_key = sender_chain[0].ratchet_key;
+ _olm_curve25519_public_key const & ratchet_key =
+ sender_chain[0].ratchet_key.public_key;
olm::MessageWriter writer;
diff --git a/src/session.cpp b/src/session.cpp
index 7bde5d1..f1bc5a7 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -14,7 +14,7 @@
*/
#include "olm/session.hh"
#include "olm/cipher.h"
-#include "olm/crypto.hh"
+#include "olm/crypto.h"
#include "olm/account.hh"
#include "olm/memory.hh"
#include "olm/message.hh"
@@ -55,8 +55,8 @@ std::size_t olm::Session::new_outbound_session_random_length() {
std::size_t olm::Session::new_outbound_session(
olm::Account const & local_account,
- olm::Curve25519PublicKey const & identity_key,
- olm::Curve25519PublicKey const & one_time_key,
+ _olm_curve25519_public_key const & identity_key,
+ _olm_curve25519_public_key const & one_time_key,
std::uint8_t const * random, std::size_t random_length
) {
if (random_length < new_outbound_session_random_length()) {
@@ -64,29 +64,30 @@ std::size_t olm::Session::new_outbound_session(
return std::size_t(-1);
}
- olm::Curve25519KeyPair base_key;
- olm::curve25519_generate_key(random, base_key);
+ _olm_curve25519_key_pair base_key;
+ _olm_crypto_curve25519_generate_key(random, &base_key);
- olm::Curve25519KeyPair ratchet_key;
- olm::curve25519_generate_key(random + CURVE25519_RANDOM_LENGTH, ratchet_key);
+ _olm_curve25519_key_pair ratchet_key;
+ _olm_crypto_curve25519_generate_key(random + CURVE25519_RANDOM_LENGTH, &ratchet_key);
- olm::Curve25519KeyPair const & alice_identity_key_pair = (
+ _olm_curve25519_key_pair const & alice_identity_key_pair = (
local_account.identity_keys.curve25519_key
);
received_message = false;
- alice_identity_key = alice_identity_key_pair;
- alice_base_key = base_key;
+ alice_identity_key = alice_identity_key_pair.public_key;
+ alice_base_key = base_key.public_key;
bob_one_time_key = one_time_key;
// Calculate the shared secret S via triple DH
std::uint8_t secret[3 * CURVE25519_SHARED_SECRET_LENGTH];
std::uint8_t * pos = secret;
- olm::curve25519_shared_secret(alice_identity_key_pair, one_time_key, pos);
+
+ _olm_crypto_curve25519_shared_secret(&alice_identity_key_pair, &one_time_key, pos);
pos += CURVE25519_SHARED_SECRET_LENGTH;
- olm::curve25519_shared_secret(base_key, identity_key, pos);
+ _olm_crypto_curve25519_shared_secret(&base_key, &identity_key, pos);
pos += CURVE25519_SHARED_SECRET_LENGTH;
- olm::curve25519_shared_secret(base_key, one_time_key, pos);
+ _olm_crypto_curve25519_shared_secret(&base_key, &one_time_key, pos);
ratchet.initialise_as_alice(secret, sizeof(secret), ratchet_key);
@@ -120,7 +121,7 @@ static bool check_message_fields(
std::size_t olm::Session::new_inbound_session(
olm::Account & local_account,
- olm::Curve25519PublicKey const * their_identity_key,
+ _olm_curve25519_public_key const * their_identity_key,
std::uint8_t const * one_time_key_message, std::size_t message_length
) {
olm::PreKeyMessageReader reader;
@@ -157,7 +158,7 @@ std::size_t olm::Session::new_inbound_session(
return std::size_t(-1);
}
- olm::Curve25519PublicKey ratchet_key;
+ _olm_curve25519_public_key ratchet_key;
olm::load_array(ratchet_key.public_key, message_reader.ratchet_key);
olm::OneTimeKey const * our_one_time_key = local_account.lookup_key(
@@ -169,19 +170,19 @@ std::size_t olm::Session::new_inbound_session(
return std::size_t(-1);
}
- olm::Curve25519KeyPair const & bob_identity_key = (
+ _olm_curve25519_key_pair const & bob_identity_key = (
local_account.identity_keys.curve25519_key
);
- olm::Curve25519KeyPair const & bob_one_time_key = our_one_time_key->key;
+ _olm_curve25519_key_pair const & bob_one_time_key = our_one_time_key->key;
// Calculate the shared secret S via triple DH
std::uint8_t secret[CURVE25519_SHARED_SECRET_LENGTH * 3];
std::uint8_t * pos = secret;
- olm::curve25519_shared_secret(bob_one_time_key, alice_identity_key, pos);
+ _olm_crypto_curve25519_shared_secret(&bob_one_time_key, &alice_identity_key, pos);
pos += CURVE25519_SHARED_SECRET_LENGTH;
- olm::curve25519_shared_secret(bob_identity_key, alice_base_key, pos);
+ _olm_crypto_curve25519_shared_secret(&bob_identity_key, &alice_base_key, pos);
pos += CURVE25519_SHARED_SECRET_LENGTH;
- olm::curve25519_shared_secret(bob_one_time_key, alice_base_key, pos);
+ _olm_crypto_curve25519_shared_secret(&bob_one_time_key, &alice_base_key, pos);
ratchet.initialise_as_bob(secret, sizeof(secret), ratchet_key);
@@ -214,7 +215,7 @@ std::size_t olm::Session::session_id(
bool olm::Session::matches_inbound_session(
- olm::Curve25519PublicKey const * their_identity_key,
+ _olm_curve25519_public_key const * their_identity_key,
std::uint8_t const * one_time_key_message, std::size_t message_length
) {
olm::PreKeyMessageReader reader;
diff --git a/src/utility.cpp b/src/utility.cpp
index e33351c..e9688de 100644
--- a/src/utility.cpp
+++ b/src/utility.cpp
@@ -14,7 +14,7 @@
*/
#include "olm/utility.hh"
-#include "olm/crypto.hh"
+#include "olm/crypto.h"
olm::Utility::Utility(
@@ -41,7 +41,7 @@ size_t olm::Utility::sha256(
size_t olm::Utility::ed25519_verify(
- Ed25519PublicKey const & key,
+ _olm_ed25519_public_key const & key,
std::uint8_t const * message, std::size_t message_length,
std::uint8_t const * signature, std::size_t signature_length
) {
@@ -49,7 +49,7 @@ size_t olm::Utility::ed25519_verify(
last_error = OlmErrorCode::OLM_BAD_MESSAGE_MAC;
return std::size_t(-1);
}
- if (!olm::ed25519_verify(key, message, message_length, signature)) {
+ if (!_olm_crypto_ed25519_verify(&key, message, message_length, signature)) {
last_error = OlmErrorCode::OLM_BAD_MESSAGE_MAC;
return std::size_t(-1);
}