#tor #signature #type-state #arti #data #certificate #object

tor-checkable

Types to ensure that signed or time-bound data is validated before use

30 releases (15 breaking)

0.23.0 Sep 30, 2024
0.21.0 Aug 1, 2024
0.20.0 Jun 27, 2024
0.8.0 Mar 4, 2024
0.0.0 Jun 24, 2021

#1467 in Cryptography

Download history 1455/week @ 2024-07-01 239/week @ 2024-07-08 810/week @ 2024-07-15 745/week @ 2024-07-22 1644/week @ 2024-07-29 1378/week @ 2024-08-05 865/week @ 2024-08-12 1486/week @ 2024-08-19 1491/week @ 2024-08-26 1759/week @ 2024-09-02 1321/week @ 2024-09-09 1286/week @ 2024-09-16 1677/week @ 2024-09-23 1563/week @ 2024-09-30 810/week @ 2024-10-07 892/week @ 2024-10-14

4,994 downloads per month
Used in 45 crates (6 directly)

MIT/Apache

110KB
1.5K SLoC

tor-checkable

Traits for wrapping up signed and/or time-bound objects

Overview

Frequently (for testing reasons or otherwise), we want to ensure that an object can only be used if a signature is valid, or if some timestamp is recent enough.

As an example, consider a self-signed certificate. You can parse it cheaply enough (and find its key by doing so), but you probably want to make sure that nobody will use that certificate unless its signature is correct and its timestamps are not expired.

With the tor-checkable crate, you can instead return an object that represents the certificate in its unchecked state. The caller can access the certificate, but only after checking the signature and the time.

This crate is part of Arti, a project to implement Tor in Rust. Many other crates in Arti depend on it, but it should be generally useful outside of Arti.

Design notes and alternatives

The types in this crate provide functions to return the underlying objects without checking them. This is very convenient for testing, though you wouldn't want to do it in production code. To prevent mistakes, these functions all begin with the word dangerously.

Another approach you might take is to put signature and timeliness checks inside your parsing function. But if you do that, it will get hard to test your code: you will only be able to parse certificates that are valid when the parser is running. And if you want to test parsing a new kind of certificate, you'll need to make sure to put a valid signature on it. (And all of this signature parsing will slow down any attempts to fuzz your parser.)

You could have your parser take a flag to tell it whether to check signatures and timeliness, but that could be error prone: if anybody sets the flag wrong, they will skip doing the checks.

License: MIT OR Apache-2.0

Dependencies

~10MB
~179K SLoC