aboutsummaryrefslogtreecommitdiff
path: root/include/olm/ratchet.hh
diff options
context:
space:
mode:
Diffstat (limited to 'include/olm/ratchet.hh')
-rw-r--r--include/olm/ratchet.hh39
1 files changed, 23 insertions, 16 deletions
diff --git a/include/olm/ratchet.hh b/include/olm/ratchet.hh
index 2393e5b..2e87e35 100644
--- a/include/olm/ratchet.hh
+++ b/include/olm/ratchet.hh
@@ -13,23 +13,29 @@
* limitations under the License.
*/
-#include "olm/crypto.hh"
+#include <cstdint>
+
+#include "olm/crypto.h"
#include "olm/list.hh"
-#include "olm/error.hh"
+#include "olm/error.h"
-namespace olm {
+struct _olm_cipher;
-class Cipher;
+namespace olm {
-typedef std::uint8_t SharedKey[olm::KEY_LENGTH];
+/** length of a shared key: the root key R(i), chain key C(i,j), and message key
+ * M(i,j)). They are all only used to stuff into HMACs, so could be any length
+ * for that. The chain key and message key are both derived from SHA256
+ * operations, so their length is determined by that. */
+const std::size_t OLM_SHARED_KEY_LENGTH = SHA256_OUTPUT_LENGTH;
+typedef std::uint8_t SharedKey[OLM_SHARED_KEY_LENGTH];
struct ChainKey {
std::uint32_t index;
SharedKey key;
};
-
struct MessageKey {
std::uint32_t index;
SharedKey key;
@@ -37,19 +43,19 @@ struct MessageKey {
struct SenderChain {
- Curve25519KeyPair ratchet_key;
+ _olm_curve25519_key_pair ratchet_key;
ChainKey chain_key;
};
struct ReceiverChain {
- Curve25519PublicKey ratchet_key;
+ _olm_curve25519_public_key ratchet_key;
ChainKey chain_key;
};
struct SkippedMessageKey {
- Curve25519PublicKey ratchet_key;
+ _olm_curve25519_public_key ratchet_key;
MessageKey message_key;
};
@@ -70,20 +76,20 @@ struct Ratchet {
Ratchet(
KdfInfo const & kdf_info,
- Cipher const & ratchet_cipher
+ _olm_cipher const *ratchet_cipher
);
/** A some strings identifying the application to feed into the KDF. */
KdfInfo const & kdf_info;
/** The AEAD cipher to use for encrypting messages. */
- Cipher const & ratchet_cipher;
+ _olm_cipher const *ratchet_cipher;
/** The last error that happened encrypting or decrypting a message. */
- ErrorCode last_error;
+ OlmErrorCode last_error;
/** The root key is used to generate chain keys from the ephemeral keys.
- * A new root_key derived each time a chain key is derived. */
+ * A new root_key derived each time a new chain is started. */
SharedKey root_key;
/** The sender chain is used to send messages. Each time a new ephemeral
@@ -104,14 +110,14 @@ struct Ratchet {
* remote's first ratchet key */
void initialise_as_bob(
std::uint8_t const * shared_secret, std::size_t shared_secret_length,
- Curve25519PublicKey const & their_ratchet_key
+ _olm_curve25519_public_key const & their_ratchet_key
);
/** Initialise the session using a shared secret and the public/private key
* pair for the first ratchet key */
void initialise_as_alice(
std::uint8_t const * shared_secret, std::size_t shared_secret_length,
- Curve25519KeyPair const & our_ratchet_key
+ _olm_curve25519_key_pair const & our_ratchet_key
);
/** The number of bytes of output the encrypt method will write for
@@ -170,7 +176,8 @@ std::uint8_t * pickle(
std::uint8_t const * unpickle(
std::uint8_t const * pos, std::uint8_t const * end,
- Ratchet & value
+ Ratchet & value,
+ bool includes_chain_index
);