Skip to main content

SignService

Struct SignService 

Source
pub struct SignService {
    pub backend: EcdsaBackend,
    pub cert_library: CertificateLibrary,
    pub cam_handler: CooperativeAwarenessMessageSecurityHandler,
    pub other_handler: CooperativeAwarenessMessageSecurityHandler,
    pub unknown_ats: Vec<[u8; 3]>,
    pub requested_ats: Vec<[u8; 3]>,
    pub trust_list_request: Option<TrustListRequestProvider>,
    /* private fields */
}
Expand description

Signing service for ETSI TS 103 097-secured messages.

Fields§

§backend: EcdsaBackend§cert_library: CertificateLibrary§cam_handler: CooperativeAwarenessMessageSecurityHandler§other_handler: CooperativeAwarenessMessageSecurityHandler

Certificate timer of the messages other than CAM and DENM (clause 7.1.3): the certificate once per second, the digest otherwise.

§unknown_ats: Vec<[u8; 3]>

HashedId3 values of unknown ATs to include in inlineP2pcdRequest.

§requested_ats: Vec<[u8; 3]>

HashedId3 values for which we should embed requestedCertificate.

§trust_list_request: Option<TrustListRequestProvider>

P2P CRL / CTL request for the next CAM (TS 103 601 clause 5.3.4).

Implementations§

Source§

impl SignService

Source

pub fn new(backend: EcdsaBackend, cert_library: CertificateLibrary) -> Self

Source

pub fn with_clock(self, clock: SignClock) -> Self

Use clock instead of the system time (UTC seconds since the Unix epoch).

Source

pub fn now_secs(&self) -> f64

Current UTC time in seconds (the injected clock, or the system time).

Source

pub fn now_its_us(&self) -> u64

Current ITS time (TAI) in microseconds, as generationTime (Time64).

Source

pub fn cam_state(&self) -> &CooperativeAwarenessMessageSecurityHandler

Accessor for CAM security handler (cam_state).

Source

pub fn cam_state_mut( &mut self, ) -> &mut CooperativeAwarenessMessageSecurityHandler

Mutable accessor for CAM security handler (cam_state).

Source

pub fn sign_request(&mut self, request: &SNSignRequest) -> SNSignConfirm

Route to the correct profile based on ITS-AID.

§Panics

When no authorization ticket may sign the message; use SignService::try_sign_request to handle that case.

Source

pub fn try_sign_request( &mut self, request: &SNSignRequest, ) -> Result<SNSignConfirm, SigningError>

Route to the correct profile based on ITS-AID; Err when no AT may sign the message (the message shall then not be sent).

Source

pub fn get_present_at(&self, its_aid: u64) -> Option<&OwnCertificate>

Find the own certificate that may sign for the given ITS-AID now.

Source

pub fn get_present_at_for_signging( &self, its_aid: u64, ) -> Option<&OwnCertificate>

Parity alias for Python get_present_at_for_signging.

Source

pub fn select_at( &self, its_aid: u64, permissions: &[u8], location: Option<&GenerationLocation>, ) -> Option<&OwnCertificate>

Select the AT to sign with (IEEE Std 1609.2-2016 clause 5.2.3.2.2): its appPermissions contain the ITS-AID with an SSP granting the requested permissions, the current time lies in the validity period of its chain and, when location is given, the position lies in the region of its chain.

Source

pub fn get_known_at_for_request( &self, hashedid3: &[u8; 3], ) -> Result<AsnCertificate, String>

Look up a known CA certificate by its HashedId3 for inclusion in requestedCertificate.

Source

pub fn sign_other(&mut self, request: &SNSignRequest) -> SNSignConfirm

Source

pub fn try_sign_other( &mut self, request: &SNSignRequest, ) -> Result<SNSignConfirm, SigningError>

Messages other than CAM and DENM (TS 103 097 clause 7.1.3, which does not constrain the signer): the certificate once per second, so that receivers can verify them without having heard a CAM, the digest otherwise.

Source

pub fn sign_denm(&self, request: &SNSignRequest) -> SNSignConfirm

Source

pub fn try_sign_denm( &self, request: &SNSignRequest, ) -> Result<SNSignConfirm, SigningError>

Source

pub fn sign_cam(&mut self, request: &SNSignRequest) -> SNSignConfirm

Source

pub fn sign_cam_at( &mut self, request: &SNSignRequest, timestamp_secs: Option<f64>, ) -> SNSignConfirm

Sign a CAM according to ETSI TS 103 097 V2.2.1 §5.2 and §7.1.1, with an optional timestamp in seconds (for deterministic testing).

Source

pub fn try_sign_cam_at( &mut self, request: &SNSignRequest, timestamp_secs: Option<f64>, ) -> Result<SNSignConfirm, SigningError>

SignService::sign_cam_at returning Err when no AT may sign.

Source

pub fn notify_unknown_at(&mut self, hashedid8: &[u8; 8])

Record an unknown AT HashedId3 and force own cert inclusion in next CAM.

Source

pub fn notify_known_at(&mut self, hashedid8: &[u8; 8])

An AT was learned (received as certificate signer): stop requesting it.

Source

pub fn notify_inline_p2pcd_request(&mut self, request_list: &[[u8; 3]])

Process a received inlineP2pcdRequest.

Source

pub fn notify_received_ca_certificate(&mut self, cert: Certificate)

Process a received CA certificate from requestedCertificate.

Source

pub fn add_own_certificate(&mut self, cert: OwnCertificate)

Add an own certificate.

Auto Trait Implementations§

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
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

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

Source§

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>,

Source§

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