Skip to main content
This is unreleased documentation for the main (development) branch of crypto-glue.

Builder

Trait Builder 

Source
pub trait Builder: Sized {
    type Output: Sized;

    // Required methods
    fn assemble<S>(
        self,
        signature: BitString,
        signer: &S,
    ) -> Result<Self::Output>
       where S: Keypair + DynSignatureAlgorithmIdentifier,
             S::VerifyingKey: EncodePublicKey;
    fn finalize<S>(&mut self, signer: &S) -> Result<Vec<u8>>
       where S: Keypair + DynSignatureAlgorithmIdentifier,
             S::VerifyingKey: EncodePublicKey;

    // Provided methods
    fn build<S, Signature>(self, signer: &S) -> Result<Self::Output>
       where S: Signer<Signature> + Keypair + DynSignatureAlgorithmIdentifier,
             S::VerifyingKey: EncodePublicKey,
             Signature: SignatureBitStringEncoding { ... }
    fn build_with_rng<S, Signature, R>(
        self,
        signer: &S,
        rng: &mut R,
    ) -> Result<Self::Output>
       where S: RandomizedSigner<Signature> + Keypair + DynSignatureAlgorithmIdentifier,
             S::VerifyingKey: EncodePublicKey,
             Signature: SignatureBitStringEncoding,
             R: CryptoRng + ?Sized { ... }
}
Expand description

Trait for X509 builders

This trait defines the interface between builder and the signers.

Required Associated Types§

Source

type Output: Sized

Type built by this builder

Required Methods§

Source

fn assemble<S>(self, signature: BitString, signer: &S) -> Result<Self::Output>

Assemble the final object from signature.

Source

fn finalize<S>(&mut self, signer: &S) -> Result<Vec<u8>>

Finalize and return a serialization of the object for signature.

Provided Methods§

Source

fn build<S, Signature>(self, signer: &S) -> Result<Self::Output>

Run the object through the signer and build it.

§Notes

When using ECDSA signers, the Signature parameter will need to be explicit as multiple implementation of signature::Signer with various signature are available.

This would look like:

let certificate = builder.build::<_, ecdsa::der::Signature<_>>(&signer).unwrap();
Source

fn build_with_rng<S, Signature, R>( self, signer: &S, rng: &mut R, ) -> Result<Self::Output>

Run the object through the signer and build it.

§Notes

When using ECDSA signers, the Signature parameter will need to be explicit as multiple implementation of signature::Signer with various signature are available.

This would look like:

let certificate = builder.build_with_rng::<_, ecdsa::der::Signature<_>, _>(
    &signer,
    &mut rng
).unwrap();

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§