diff options
author | Richard van der Hoff <github@rvanderhoff.org.uk> | 2016-09-06 11:08:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-06 11:08:04 +0100 |
commit | 7c84ce8098f58b28e9996f8644caafef8d32d308 (patch) | |
tree | 3ffbabe907b4a3f46d740d01114016add4539300 /src/pickle.cpp | |
parent | 8912d13b0b856e5eb3e43594260dd5da3ad6535c (diff) | |
parent | 833ecd3c736cea71a693cd9dedec4f1bffa87000 (diff) |
Merge pull request #18 from matrix-org/rav/pickle_ed25519_in_c
Convert ed25519 pickling functions to C
Diffstat (limited to 'src/pickle.cpp')
-rw-r--r-- | src/pickle.cpp | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/pickle.cpp b/src/pickle.cpp index e9708b7..b6ee4c5 100644 --- a/src/pickle.cpp +++ b/src/pickle.cpp @@ -139,77 +139,76 @@ std::uint8_t const * olm::unpickle( return pos; } -std::size_t olm::pickle_length( - const _olm_ed25519_public_key & value +////// pickle.h implementations + +std::size_t _olm_pickle_ed25519_public_key_length( + const _olm_ed25519_public_key * value ) { - return sizeof(value.public_key); + return sizeof(value->public_key); } -std::uint8_t * olm::pickle( +std::uint8_t * _olm_pickle_ed25519_public_key( std::uint8_t * pos, - const _olm_ed25519_public_key & value + const _olm_ed25519_public_key *value ) { pos = olm::pickle_bytes( - pos, value.public_key, sizeof(value.public_key) + pos, value->public_key, sizeof(value->public_key) ); return pos; } -std::uint8_t const * olm::unpickle( +std::uint8_t const * _olm_unpickle_ed25519_public_key( std::uint8_t const * pos, std::uint8_t const * end, - _olm_ed25519_public_key & value + _olm_ed25519_public_key * value ) { pos = olm::unpickle_bytes( - pos, end, value.public_key, sizeof(value.public_key) + pos, end, value->public_key, sizeof(value->public_key) ); return pos; - } -std::size_t olm::pickle_length( - const _olm_ed25519_key_pair & value +std::size_t _olm_pickle_ed25519_key_pair_length( + const _olm_ed25519_key_pair *value ) { - return sizeof(value.public_key.public_key) - + sizeof(value.private_key.private_key); + return sizeof(value->public_key.public_key) + + sizeof(value->private_key.private_key); } -std::uint8_t * olm::pickle( +std::uint8_t * _olm_pickle_ed25519_key_pair( std::uint8_t * pos, - const _olm_ed25519_key_pair & value + const _olm_ed25519_key_pair *value ) { pos = olm::pickle_bytes( - pos, value.public_key.public_key, - sizeof(value.public_key.public_key) + pos, value->public_key.public_key, + sizeof(value->public_key.public_key) ); pos = olm::pickle_bytes( - pos, value.private_key.private_key, - sizeof(value.private_key.private_key) + pos, value->private_key.private_key, + sizeof(value->private_key.private_key) ); return pos; } -std::uint8_t const * olm::unpickle( +std::uint8_t const * _olm_unpickle_ed25519_key_pair( std::uint8_t const * pos, std::uint8_t const * end, - _olm_ed25519_key_pair & value + _olm_ed25519_key_pair *value ) { pos = olm::unpickle_bytes( - pos, end, value.public_key.public_key, - sizeof(value.public_key.public_key) + pos, end, value->public_key.public_key, + sizeof(value->public_key.public_key) ); pos = olm::unpickle_bytes( - pos, end, value.private_key.private_key, - sizeof(value.private_key.private_key) + pos, end, value->private_key.private_key, + sizeof(value->private_key.private_key) ); return pos; } -////// pickle.h implementations - uint8_t * _olm_pickle_uint32(uint8_t * pos, uint32_t value) { return olm::pickle(pos, value); } |