36 releases (21 breaking)

new 0.26.0 Jan 7, 2025
0.25.0 Dec 2, 2024
0.24.0 Oct 31, 2024
0.20.0 Jun 27, 2024
0.0.0 Jun 24, 2021

#248 in Parser implementations

Download history 1292/week @ 2024-09-18 1927/week @ 2024-09-25 1223/week @ 2024-10-02 904/week @ 2024-10-09 1037/week @ 2024-10-16 1113/week @ 2024-10-23 2250/week @ 2024-10-30 1079/week @ 2024-11-06 1995/week @ 2024-11-13 2005/week @ 2024-11-20 2304/week @ 2024-11-27 2074/week @ 2024-12-04 2540/week @ 2024-12-11 1662/week @ 2024-12-18 714/week @ 2024-12-25 1227/week @ 2025-01-01

6,652 downloads per month
Used in 56 crates (6 directly)

MIT/Apache

240KB
3.5K SLoC

tor-cert

Implementation for Tor certificates

Overview

The tor-cert crate implements the binary certificate types documented in Tor's cert-spec.txt, which are used when authenticating Tor channels. (Eventually, support for onion service certificate support will get added too.)

This crate is part of Arti, a project to implement Tor in Rust.

There are other types of certificate used by Tor as well, and they are implemented in other places. In particular, see tor-netdoc::doc::authcert for the certificate types used by authorities in the directory protocol.

Design notes

The tor-cert code is in its own separate crate because it is required by several other higher-level crates that do not depend upon each other. For example, tor-netdoc parses encoded certificates from router descriptors, while tor-proto uses certificates when authenticating relays.

Examples

Parsing, validating, and inspecting a certificate:

use base64ct::{Base64, Encoding as _};
use tor_cert::*;
use tor_checkable::*;
// Taken from a random relay on the Tor network.
let cert_base64 =
 "AQQABrntAThPWJ4nFH1L77Ar+emd4GPXZTPUYzIwmR2H6Zod5TvXAQAgBAC+vzqh
  VFO1SGATubxcrZzrsNr+8hrsdZtyGg/Dde/TqaY1FNbeMqtAPMziWOd6txzShER4
  qc/haDk5V45Qfk6kjcKw+k7cPwyJeu+UF/azdoqcszHRnUHRXpiPzudPoA4=";
// Remove the whitespace, so base64 doesn't choke on it.
let cert_base64: String = cert_base64.split_whitespace().collect();
// Decode the base64.
let cert_bin = Base64::decode_vec(&cert_base64).unwrap();

// Decode the cert and check its signature.
let cert = Ed25519Cert::decode(&cert_bin).unwrap()
    .check_key(None).unwrap()
    .check_signature().unwrap()
    .dangerously_assume_timely();
let signed_key = cert.subject_key();

License: MIT OR Apache-2.0

Dependencies

~10–21MB
~294K SLoC