Struct tor_netdoc::doc::hsdesc::HsDesc

source ·
pub struct HsDesc { /* private fields */ }
Available on crate feature hs-common only.
Expand description

A decrypted, decoded onion service descriptor.

This object includes information from both the outer (plaintext) document of the descriptor, and the inner (encrypted) documents. It tells the client the information it needs to contact the onion service, including necessary introduction points and public keys.

Implementations§

source§

impl HsDesc

source

pub fn parse( input: &str, blinded_onion_id: &HsBlindId ) -> Result<UncheckedEncryptedHsDesc>

Parse the outermost document of the descriptor in input, and validate that its identity is consistent with blinded_onion_id.

On success, the caller will get a wrapped object which they must validate and then decrypt.

Use HsDesc::parse_decrypt_validate if you just need an HsDesc and don’t want to handle the validation/decryption of the wrapped object yourself.

§Example
// Parse the descriptor
let unchecked_desc = HsDesc::parse(unparsed_desc, &blinded_id)?;
// Validate the signature and timeliness of the outer document
let checked_desc = unchecked_desc
    .check_signature()?
    .check_valid_at(&timestamp)?;
// Decrypt the outer and inner layers of the descriptor
let unchecked_decrypted_desc = checked_desc.decrypt(&subcredential, None)?;
// Validate the signature and timeliness of the inner document
let hsdesc = unchecked_decrypted_desc
    .check_valid_at(&timestamp)?
    .check_signature()?;
source

pub fn parse_decrypt_validate( input: &str, blinded_onion_id: &HsBlindId, valid_at: SystemTime, subcredential: &Subcredential, hsc_desc_enc: Option<&HsClientDescEncKeypair> ) -> StdResult<TimerangeBound<Self>, HsDescError>

A convenience function for parsing, decrypting and validating HS descriptors.

This function:

  • parses the outermost document of the descriptor in input, and validates that its identity is consistent with blinded_onion_id.
  • decrypts both layers of encryption in the onion service descriptor. If hsc_desc_enc is provided, we use it to decrypt the inner encryption layer; otherwise, we require that the inner document is encrypted using the “no client authorization” method.
  • checks if both layers are valid at the valid_at timestamp
  • validates the signatures on both layers

Returns an error if the descriptor cannot be parsed, or if one of the validation steps fails.

source

pub fn intro_points(&self) -> &[IntroPointDesc]

One or more introduction points used to contact the onion service.

Always returns at least one introduction point, and never more than NUM_INTRO_POINT_MAX. (Descriptors which have fewer or more are dealt with during parsing.)

Accessor function.

source

pub fn is_single_onion_service(&self) -> bool

Return true if this onion service claims to be a non-anonymous “single onion service”.

(We should always anonymize our own connection to an onion service.)

source

pub fn requires_intro_authentication(&self) -> bool

Return true if this onion service claims that it needs user authentication of some kind in its INTRODUCE messages.

(Arti does not currently support sending this kind of authentication.)

Trait Implementations§

source§

impl Clone for HsDesc

source§

fn clone(&self) -> HsDesc

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HsDesc

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for HsDesc

§

impl RefUnwindSafe for HsDesc

§

impl Send for HsDesc

§

impl Sync for HsDesc

§

impl Unpin for HsDesc

§

impl UnwindSafe for HsDesc

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more