diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-06-09 18:03:01 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-06-09 18:03:01 +0100 |
commit | a08d706366ff593431bfb85ec873045bf496b810 (patch) | |
tree | 3c22e706ba6ddc8bbcf70bb4eeaf57b980fca3f1 /include/axolotl/ratchet.hh | |
parent | 8123ce62094bf88a4107506d7acd3e8e2866bc1f (diff) |
Add methods for pickling and unpickling sessions
Diffstat (limited to 'include/axolotl/ratchet.hh')
-rw-r--r-- | include/axolotl/ratchet.hh | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/axolotl/ratchet.hh b/include/axolotl/ratchet.hh index 9d7ff9a..cf41359 100644 --- a/include/axolotl/ratchet.hh +++ b/include/axolotl/ratchet.hh @@ -84,7 +84,7 @@ struct Session { ); /** A some strings identifing the application to feed into the KDF. */ - KdfInfo kdf_info; + const KdfInfo &kdf_info; /** The last error that happened encypting or decrypting a message. */ ErrorCode last_error; @@ -121,6 +121,24 @@ struct Session { Curve25519KeyPair const & our_ratchet_key ); + /** The number of bytes needed to persist the current session. */ + std::size_t pickle_max_output_length(); + + /** Persists a session as a sequence of bytes, encrypting using a key + * Returns the number of output bytes used. */ + std::size_t pickle( + std::uint8_t const * key, std::size_t key_length, + std::uint8_t * output, std::size_t max_output_length + ); + + /** Loads a session from a sequence of bytes, decrypting using a key. + * Returns 0 on success, or std::size_t(-1) on failure. The last_error + * will be BAD_SESSION_KEY if the supplied key is incorrect. */ + std::size_t unpickle( + std::uint8_t const * key, std::size_t key_length, + std::uint8_t * input, std::size_t input_length + ); + /** The maximum number of bytes of output the encrypt method will write for * a given message length. */ std::size_t encrypt_max_output_length( |