diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-02-04 11:32:55 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-02-04 11:32:55 -0500 |
commit | 5ea9a90d682279e857efd63e2a829bd5a39b0178 (patch) | |
tree | 8b0bcad6ef5587bf67f0dda897c5bdcaf45c905f /src/common/crypto_curve25519.c | |
parent | ddf2c36ab1e606ea9dcd0253512da16ab17b3457 (diff) | |
download | tor-5ea9a90d682279e857efd63e2a829bd5a39b0178.tar.gz tor-5ea9a90d682279e857efd63e2a829bd5a39b0178.zip |
Fix compilation with --disable-curve25519 option
The fix is to move the two functions to format/parse base64
curve25519 public keys into a new "crypto_format.c" file. I could
have put them in crypto.c, but that's a big file worth splitting
anyway.
Fixes bug 8153; bugfix on 0.2.4.8-alpha where I did the fix for 7869.
Diffstat (limited to 'src/common/crypto_curve25519.c')
-rw-r--r-- | src/common/crypto_curve25519.c | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/src/common/crypto_curve25519.c b/src/common/crypto_curve25519.c index 62398f62e6..425a1a078c 100644 --- a/src/common/crypto_curve25519.c +++ b/src/common/crypto_curve25519.c @@ -182,34 +182,3 @@ curve25519_handshake(uint8_t *output, curve25519_impl(output, skey->secret_key, pkey->public_key); } -int -curve25519_public_to_base64(char *output, - const curve25519_public_key_t *pkey) -{ - char buf[128]; - base64_encode(buf, sizeof(buf), - (const char*)pkey->public_key, CURVE25519_PUBKEY_LEN); - buf[CURVE25519_BASE64_PADDED_LEN] = '\0'; - memcpy(output, buf, CURVE25519_BASE64_PADDED_LEN+1); - return 0; -} - -int -curve25519_public_from_base64(curve25519_public_key_t *pkey, - const char *input) -{ - size_t len = strlen(input); - if (len == CURVE25519_BASE64_PADDED_LEN - 1) { - /* not padded */ - return digest256_from_base64((char*)pkey->public_key, input); - } else if (len == CURVE25519_BASE64_PADDED_LEN) { - char buf[128]; - if (base64_decode(buf, sizeof(buf), input, len) != CURVE25519_PUBKEY_LEN) - return -1; - memcpy(pkey->public_key, buf, CURVE25519_PUBKEY_LEN); - return 0; - } else { - return -1; - } -} - |