From 833ecd3c736cea71a693cd9dedec4f1bffa87000 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Mon, 5 Sep 2016 12:59:12 +0100 Subject: Convert ed25519 pickling functions to C ... so that I can use them from the group session bits. --- include/olm/pickle.h | 40 ++++++++++++++++++++++++++++++++++++++++ include/olm/pickle.hh | 34 ---------------------------------- 2 files changed, 40 insertions(+), 34 deletions(-) (limited to 'include') diff --git a/include/olm/pickle.h b/include/olm/pickle.h index c1e8192..0e668bb 100644 --- a/include/olm/pickle.h +++ b/include/olm/pickle.h @@ -21,6 +21,10 @@ extern "C" { #endif +struct _olm_ed25519_public_key; +struct _olm_ed25519_key_pair; + + #define _olm_pickle_uint32_length(value) 4 uint8_t * _olm_pickle_uint32(uint8_t * pos, uint32_t value); uint8_t const * _olm_unpickle_uint32( @@ -43,6 +47,42 @@ uint8_t const * _olm_unpickle_bytes(uint8_t const * pos, uint8_t const * end, uint8_t * bytes, size_t bytes_length); +/** Get the number of bytes needed to pickle an ed25519 public key */ +size_t _olm_pickle_ed25519_public_key_length( + const struct _olm_ed25519_public_key * value +); + +/** Pickle the ed25519 public key. Returns a pointer to the next free space in + * the buffer. */ +uint8_t * _olm_pickle_ed25519_public_key( + uint8_t *pos, const struct _olm_ed25519_public_key * value +); + +/** Unpickle the ed25519 public key. Returns a pointer to the next item in the + * buffer. */ +const uint8_t * _olm_unpickle_ed25519_public_key( + const uint8_t *pos, const uint8_t *end, + struct _olm_ed25519_public_key * value +); + +/** Get the number of bytes needed to pickle an ed25519 key pair */ +size_t _olm_pickle_ed25519_key_pair_length( + const struct _olm_ed25519_key_pair * value +); + +/** Pickle the ed25519 key pair. Returns a pointer to the next free space in + * the buffer. */ +uint8_t * _olm_pickle_ed25519_key_pair( + uint8_t *pos, const struct _olm_ed25519_key_pair * value +); + +/** Unpickle the ed25519 key pair. Returns a pointer to the next item in the + * buffer. */ +const uint8_t * _olm_unpickle_ed25519_key_pair( + const uint8_t *pos, const uint8_t *end, + struct _olm_ed25519_key_pair * value +); + #ifdef __cplusplus } // extern "C" #endif diff --git a/include/olm/pickle.hh b/include/olm/pickle.hh index a09b8a1..4cf3f36 100644 --- a/include/olm/pickle.hh +++ b/include/olm/pickle.hh @@ -141,40 +141,6 @@ std::uint8_t const * unpickle( _olm_curve25519_key_pair & value ); - -std::size_t pickle_length( - const _olm_ed25519_public_key & value -); - - -std::uint8_t * pickle( - std::uint8_t * pos, - const _olm_ed25519_public_key & value -); - - -std::uint8_t const * unpickle( - std::uint8_t const * pos, std::uint8_t const * end, - _olm_ed25519_public_key & value -); - - -std::size_t pickle_length( - const _olm_ed25519_key_pair & value -); - - -std::uint8_t * pickle( - std::uint8_t * pos, - const _olm_ed25519_key_pair & value -); - - -std::uint8_t const * unpickle( - std::uint8_t const * pos, std::uint8_t const * end, - _olm_ed25519_key_pair & value -); - } // namespace olm -- cgit v1.2.3