aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-07-07 09:50:32 +0100
committerMark Haines <mark.haines@matrix.org>2015-07-07 09:50:32 +0100
commit2a873fd4e1d53c45898b27e1c953b551b2cf6023 (patch)
tree6096e97b2245d3ada64013a90c4488c2caaeae3e /src
parenta30a64d17931c43ca20090220272ce9257064072 (diff)
Add functions for creating and verifying ed25519 signatures
Diffstat (limited to 'src')
-rw-r--r--src/crypto.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/crypto.cpp b/src/crypto.cpp
index db4bfa6..ed89d64 100644
--- a/src/crypto.cpp
+++ b/src/crypto.cpp
@@ -191,6 +191,42 @@ bool olm::curve25519_verify(
);
}
+
+void olm::ed25519_generate_key(
+ std::uint8_t const * random_32_bytes,
+ olm::Ed25519KeyPair & key_pair
+) {
+ std::memcpy(key_pair.private_key, random_32_bytes, 32);
+ ::ed25519_keypair(key_pair.private_key, key_pair.public_key);
+}
+
+
+void olm::ed25519_sign(
+ olm::Ed25519KeyPair const & our_key,
+ std::uint8_t const * message, std::size_t message_length,
+ std::uint8_t * output
+) {
+ ::ed25519_sign(
+ output,
+ message, message_length,
+ our_key.public_key, our_key.private_key
+ );
+}
+
+
+bool olm::ed25519_verify(
+ olm::Ed25519PublicKey const & their_key,
+ std::uint8_t const * message, std::size_t message_length,
+ std::uint8_t const * signature
+) {
+ return 0 != ::ed25519_verify(
+ signature,
+ message, message_length,
+ their_key.public_key
+ );
+}
+
+
std::size_t olm::aes_encrypt_cbc_length(
std::size_t input_length
) {