diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-09-30 13:38:12 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-25 15:08:31 -0400 |
commit | c75e275574b7a3496cd5050ef75f8d82d075642e (patch) | |
tree | 4bcaf273a655aae197921e4532bd966c7334da01 /src/common/crypto_format.c | |
parent | 22760c4899cb7e8b643f3f572ce93fb6587b31b8 (diff) | |
download | tor-c75e275574b7a3496cd5050ef75f8d82d075642e.tar.gz tor-c75e275574b7a3496cd5050ef75f8d82d075642e.zip |
Add encode/decode functions for ed25519 public keys
Diffstat (limited to 'src/common/crypto_format.c')
-rw-r--r-- | src/common/crypto_format.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/common/crypto_format.c b/src/common/crypto_format.c index be669c8d2b..a9f104cab2 100644 --- a/src/common/crypto_format.c +++ b/src/common/crypto_format.c @@ -9,6 +9,7 @@ #endif #include "crypto.h" #include "crypto_curve25519.h" +#include "crypto_ed25519.h" #include "util.h" #include "torlog.h" @@ -43,3 +44,24 @@ curve25519_public_from_base64(curve25519_public_key_t *pkey, } } +/** Try to decode the string <b>input</b> into an ed25519 public key. On + * success, store the value in <b>pkey</b> and return 0. Otherwise return + * -1. */ +int +ed25519_public_from_base64(ed25519_public_key_t *pkey, + const char *input) +{ + return digest256_from_base64((char*)pkey->pubkey, input); +} + +/** Encode the public key <b>pkey</b> into the buffer at <b>output</b>, + * which must have space for ED25519_BASE64_LEN bytes of encoded key, + * plus one byte for a terminating NUL. Return 0 on success, -1 on failure. + */ +int +ed25519_public_to_base64(char *output, + const ed25519_public_key_t *pkey) +{ + return digest256_to_base64(output, (const char *)pkey->pubkey); +} + |