diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-08-30 08:48:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-11-03 08:37:22 -0400 |
commit | fae7060aea5c562fc59e7089b6a3459a5718b2d0 (patch) | |
tree | eacff22a1786872d336b6099c3fabce28b22b2c0 /src/or/torcert.c | |
parent | 0b4221f98dbb93c9322e7a778f04bcbcfcc79738 (diff) | |
download | tor-fae7060aea5c562fc59e7089b6a3459a5718b2d0.tar.gz tor-fae7060aea5c562fc59e7089b6a3459a5718b2d0.zip |
Fix a misfeature with the Ed cert expiration API
The batch-verification helper didn't expose the expiration time,
which made it pretty error-prone.
This closes ticket 15087.
Diffstat (limited to 'src/or/torcert.c')
-rw-r--r-- | src/or/torcert.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/or/torcert.c b/src/or/torcert.c index b7ed7f8083..2629155477 100644 --- a/src/or/torcert.c +++ b/src/or/torcert.c @@ -166,11 +166,17 @@ tor_cert_parse(const uint8_t *encoded, const size_t len) } /** Fill in <b>checkable_out</b> with the information needed to check - * the signature on <b>cert</b> with <b>pubkey</b>. */ + * the signature on <b>cert</b> with <b>pubkey</b>. + * + * On success, if <b>expiration_out</b> is provided, and it is some time + * _after_ the expiration time of this certificate, set it to the + * expiration time of this certificate. + */ int tor_cert_get_checkable_sig(ed25519_checkable_t *checkable_out, const tor_cert_t *cert, - const ed25519_public_key_t *pubkey) + const ed25519_public_key_t *pubkey, + time_t *expiration_out) { if (! pubkey) { if (cert->signing_key_included) @@ -187,6 +193,10 @@ tor_cert_get_checkable_sig(ed25519_checkable_t *checkable_out, memcpy(checkable_out->signature.sig, cert->encoded + signed_len, ED25519_SIG_LEN); + if (expiration_out) { + *expiration_out = MIN(*expiration_out, cert->valid_until); + } + return 0; } @@ -201,14 +211,15 @@ tor_cert_checksig(tor_cert_t *cert, { ed25519_checkable_t checkable; int okay; + time_t expires = TIME_MAX; - if (now && now > cert->valid_until) { - cert->cert_expired = 1; + if (tor_cert_get_checkable_sig(&checkable, cert, pubkey, &expires) < 0) return -1; - } - if (tor_cert_get_checkable_sig(&checkable, cert, pubkey) < 0) + if (now && now > expires) { + cert->cert_expired = 1; return -1; + } if (ed25519_checksig_batch(&okay, &checkable, 1) < 0) { cert->sig_bad = 1; |