aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-09-05 12:59:12 +0100
committerRichard van der Hoff <richard@matrix.org>2016-09-05 12:59:12 +0100
commit833ecd3c736cea71a693cd9dedec4f1bffa87000 (patch)
tree487626a261a69640e00baa7ff888a35e08b42fbe /src
parentc09aa77c4a8dd27d98d2fe454fa1b589fee47977 (diff)
Convert ed25519 pickling functions to C
... so that I can use them from the group session bits.
Diffstat (limited to 'src')
-rw-r--r--src/account.cpp7
-rw-r--r--src/pickle.cpp55
2 files changed, 31 insertions, 31 deletions
diff --git a/src/account.cpp b/src/account.cpp
index c77f95c..248f3d1 100644
--- a/src/account.cpp
+++ b/src/account.cpp
@@ -14,6 +14,7 @@
*/
#include "olm/account.hh"
#include "olm/base64.hh"
+#include "olm/pickle.h"
#include "olm/pickle.hh"
#include "olm/memory.hh"
@@ -265,7 +266,7 @@ static std::size_t pickle_length(
olm::IdentityKeys const & value
) {
size_t length = 0;
- length += olm::pickle_length(value.ed25519_key);
+ length += _olm_pickle_ed25519_key_pair_length(&value.ed25519_key);
length += olm::pickle_length(value.curve25519_key);
return length;
}
@@ -275,7 +276,7 @@ static std::uint8_t * pickle(
std::uint8_t * pos,
olm::IdentityKeys const & value
) {
- pos = olm::pickle(pos, value.ed25519_key);
+ pos = _olm_pickle_ed25519_key_pair(pos, &value.ed25519_key);
pos = olm::pickle(pos, value.curve25519_key);
return pos;
}
@@ -285,7 +286,7 @@ static std::uint8_t const * unpickle(
std::uint8_t const * pos, std::uint8_t const * end,
olm::IdentityKeys & value
) {
- pos = olm::unpickle(pos, end, value.ed25519_key);
+ pos = _olm_unpickle_ed25519_key_pair(pos, end, &value.ed25519_key);
pos = olm::unpickle(pos, end, value.curve25519_key);
return pos;
}
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);
}