aboutsummaryrefslogtreecommitdiff
path: root/src/cipher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cipher.cpp')
-rw-r--r--src/cipher.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/cipher.cpp b/src/cipher.cpp
index 8c56efa..73d6680 100644
--- a/src/cipher.cpp
+++ b/src/cipher.cpp
@@ -32,7 +32,7 @@ static void derive_keys(
DerivedKeys & keys
) {
std::uint8_t derived_secrets[2 * olm::KEY_LENGTH + olm::IV_LENGTH];
- crypto_hkdf_sha256(
+ _olm_crypto_hkdf_sha256(
key, key_length,
nullptr, 0,
kdf_info, kdf_info_length,
@@ -47,24 +47,24 @@ static void derive_keys(
static const std::size_t MAC_LENGTH = 8;
-size_t aes_sha_256_cipher_mac_length(const struct olm_cipher *cipher) {
+size_t aes_sha_256_cipher_mac_length(const struct _olm_cipher *cipher) {
return MAC_LENGTH;
}
size_t aes_sha_256_cipher_encrypt_ciphertext_length(
- const struct olm_cipher *cipher, size_t plaintext_length
+ const struct _olm_cipher *cipher, size_t plaintext_length
) {
return olm::aes_encrypt_cbc_length(plaintext_length);
}
size_t aes_sha_256_cipher_encrypt(
- const struct olm_cipher *cipher,
+ const struct _olm_cipher *cipher,
uint8_t const * key, size_t key_length,
uint8_t const * plaintext, size_t plaintext_length,
uint8_t * ciphertext, size_t ciphertext_length,
uint8_t * output, size_t output_length
) {
- auto *c = reinterpret_cast<const olm_cipher_aes_sha_256 *>(cipher);
+ auto *c = reinterpret_cast<const _olm_cipher_aes_sha_256 *>(cipher);
if (aes_sha_256_cipher_encrypt_ciphertext_length(cipher, plaintext_length)
< ciphertext_length) {
@@ -80,7 +80,7 @@ size_t aes_sha_256_cipher_encrypt(
keys.aes_key, keys.aes_iv, plaintext, plaintext_length, ciphertext
);
- crypto_hmac_sha256(
+ _olm_crypto_hmac_sha256(
keys.mac_key, olm::KEY_LENGTH, output, output_length - MAC_LENGTH, mac
);
@@ -92,27 +92,27 @@ size_t aes_sha_256_cipher_encrypt(
size_t aes_sha_256_cipher_decrypt_max_plaintext_length(
- const struct olm_cipher *cipher,
+ const struct _olm_cipher *cipher,
size_t ciphertext_length
) {
return ciphertext_length;
}
size_t aes_sha_256_cipher_decrypt(
- const struct olm_cipher *cipher,
+ const struct _olm_cipher *cipher,
uint8_t const * key, size_t key_length,
uint8_t const * input, size_t input_length,
uint8_t const * ciphertext, size_t ciphertext_length,
uint8_t * plaintext, size_t max_plaintext_length
) {
- auto *c = reinterpret_cast<const olm_cipher_aes_sha_256 *>(cipher);
+ auto *c = reinterpret_cast<const _olm_cipher_aes_sha_256 *>(cipher);
DerivedKeys keys;
std::uint8_t mac[SHA256_OUTPUT_LENGTH];
derive_keys(c->kdf_info, c->kdf_info_length, key, key_length, keys);
- crypto_hmac_sha256(
+ _olm_crypto_hmac_sha256(
keys.mac_key, olm::KEY_LENGTH, input, input_length - MAC_LENGTH, mac
);
@@ -131,11 +131,11 @@ size_t aes_sha_256_cipher_decrypt(
}
-void aes_sha_256_cipher_destruct(struct olm_cipher *cipher) {
+void aes_sha_256_cipher_destruct(struct _olm_cipher *cipher) {
}
-const cipher_ops aes_sha_256_cipher_ops = {
+const _olm_cipher_ops aes_sha_256_cipher_ops = {
aes_sha_256_cipher_mac_length,
aes_sha_256_cipher_encrypt_ciphertext_length,
aes_sha_256_cipher_encrypt,
@@ -147,10 +147,11 @@ const cipher_ops aes_sha_256_cipher_ops = {
} // namespace
-olm_cipher *olm_cipher_aes_sha_256_init(struct olm_cipher_aes_sha_256 *cipher,
- uint8_t const * kdf_info,
- size_t kdf_info_length)
-{
+_olm_cipher *_olm_cipher_aes_sha_256_init(
+ struct _olm_cipher_aes_sha_256 *cipher,
+ uint8_t const * kdf_info,
+ size_t kdf_info_length
+) {
cipher->base_cipher.ops = &aes_sha_256_cipher_ops;
cipher->kdf_info = kdf_info;
cipher->kdf_info_length = kdf_info_length;