diff options
author | Robert Ransom <rransom.8774@gmail.com> | 2012-09-15 03:52:13 -0700 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-09-17 11:02:53 -0400 |
commit | 62babcaf0a88edb081529977981cf8865b32ea21 (patch) | |
tree | beef615e21bb0f58b37559f791f04eac230fa538 /src/common/crypto.c | |
parent | f3916a685594a6e0e4f4a215a57f5aea34c8570c (diff) | |
download | tor-62babcaf0a88edb081529977981cf8865b32ea21.tar.gz tor-62babcaf0a88edb081529977981cf8865b32ea21.zip |
Implement and use crypto_pk_eq_keys
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 5b5fb755b2..283b00575d 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -774,6 +774,18 @@ crypto_pk_cmp_keys(crypto_pk_t *a, crypto_pk_t *b) return BN_cmp((a->key)->e, (b->key)->e); } +/** Compare the public-key components of a and b. Return non-zero iff + * a==b. A NULL key is considered to be distinct from all non-NULL + * keys, and equal to itself. + * + * Note that this may leak information about the keys through timing. + */ +int +crypto_pk_eq_keys(crypto_pk_t *a, crypto_pk_t *b) +{ + return (crypto_pk_cmp_keys(a, b) == 0); +} + /** Return the size of the public key modulus in <b>env</b>, in bytes. */ size_t crypto_pk_keysize(crypto_pk_t *env) |