diff options
author | teor <teor@torproject.org> | 2019-04-05 15:10:00 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-04-05 15:17:19 +1000 |
commit | 5e2cba8eb4b80990fa63626054d070ad77578028 (patch) | |
tree | c0df1a978035cabfb34c469b5cf9a0b8816fcd86 /src/lib/crypt_ops | |
parent | ce5e38642d1f5e48a7e5c98422e0fa23145f0363 (diff) | |
download | tor-5e2cba8eb4b80990fa63626054d070ad77578028.tar.gz tor-5e2cba8eb4b80990fa63626054d070ad77578028.zip |
crypto_format: Stop adding padding in ed25519_signature_from_base64()
base64_decode() does not require padding.
Part of 29660.
Diffstat (limited to 'src/lib/crypt_ops')
-rw-r--r-- | src/lib/crypt_ops/crypto_format.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/lib/crypt_ops/crypto_format.c b/src/lib/crypt_ops/crypto_format.c index 269e6d9da9..1827168c75 100644 --- a/src/lib/crypt_ops/crypto_format.c +++ b/src/lib/crypt_ops/crypto_format.c @@ -246,14 +246,11 @@ int ed25519_signature_from_base64(ed25519_signature_t *sig, const char *input) { - if (strlen(input) != ED25519_SIG_BASE64_LEN) return -1; - char buf[ED25519_SIG_BASE64_LEN+3]; + char buf[ED25519_SIG_BASE64_LEN+1]; memcpy(buf, input, ED25519_SIG_BASE64_LEN); - buf[ED25519_SIG_BASE64_LEN+0] = '='; - buf[ED25519_SIG_BASE64_LEN+1] = '='; - buf[ED25519_SIG_BASE64_LEN+2] = 0; + buf[ED25519_SIG_BASE64_LEN] = 0; char decoded[128]; int n = base64_decode(decoded, sizeof(decoded), buf, strlen(buf)); if (n < 0 || n != ED25519_SIG_LEN) |