pub struct PublicKeyInitiator { /* private fields */ }

Implementations§

Create a new initiator using public key agreement.

Examples found in repository?
src/cli.rs (lines 518-521)
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
fn get_remote_signing_initiator(
    args: &ArgMatches,
) -> Result<Box<dyn SessionInitiatePeer>, RemoteSignError> {
    let server_url = args
        .get_one::<String>("remote_signing_url")
        .map(|x| x.to_string());

    if let Some(public_key_data) = args.get_one::<String>("remote_public_key") {
        let public_key_data = base64::decode(public_key_data)?;

        Ok(Box::new(PublicKeyInitiator::new(
            public_key_data,
            server_url,
        )?))
    } else if let Some(path) = args.get_one::<String>("remote_public_key_pem_file") {
        let pem_data = std::fs::read(path)?;
        let doc = pem::parse(pem_data)?;

        let spki_der = match doc.tag.as_str() {
            "PUBLIC KEY" => doc.contents,
            "CERTIFICATE" => {
                let cert = CapturedX509Certificate::from_der(doc.contents)?;
                cert.to_public_key_der()?.as_ref().to_vec()
            }
            tag => {
                error!(
                    "unknown PEM format: {}; only `PUBLIC KEY` and `CERTIFICATE` are parsed",
                    tag
                );
                return Err(RemoteSignError::Crypto("invalid public key data".into()));
            }
        };

        Ok(Box::new(PublicKeyInitiator::new(spki_der, server_url)?))
    } else if let Some(env) = args.get_one::<String>("remote_shared_secret_env") {
        let secret = std::env::var(env).map_err(|_| {
            RemoteSignError::ClientState("failed reading from shared secret environment variable")
        })?;

        Ok(Box::new(SharedSecretInitiator::new(
            secret.as_bytes().to_vec(),
        )?))
    } else if let Some(value) = args.get_one::<String>("remote_shared_secret") {
        Ok(Box::new(SharedSecretInitiator::new(
            value.as_bytes().to_vec(),
        )?))
    } else {
        error!("no arguments provided to establish session with remote signer");
        error!(
            "specify --remote-public-key, --remote-shared-secret-env, or --remote-shared-secret"
        );
        Err(RemoteSignError::ClientState(
            "unable to initiate remote signing",
        ))
    }
}

Trait Implementations§

Obtain the session ID to create / use.
Obtain additional session context to store with the server. Read more
Obtain the raw bytes constituting the session join string.
Finalize a peer joined session using optional context provided by the peer. Read more
Obtain the base 64 encoded session join string.
Obtain the PEM encoded session join string.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Causes self to use its Binary implementation when Debug-formatted.
Causes self to use its Display implementation when Debug-formatted.
Causes self to use its LowerExp implementation when Debug-formatted.
Causes self to use its LowerHex implementation when Debug-formatted.
Causes self to use its Octal implementation when Debug-formatted.
Causes self to use its Pointer implementation when Debug-formatted.
Causes self to use its UpperExp implementation when Debug-formatted.
Causes self to use its UpperHex implementation when Debug-formatted.
Formats each item in a sequence. Read more

Returns the argument unchanged.

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

Calls U::from(self).

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

Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function.
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function.
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds.
Calls .tap_borrow() only in debug builds, and is erased in release builds.
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Calls .tap_ref() only in debug builds, and is erased in release builds.
Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Calls .tap_deref() only in debug builds, and is erased in release builds.
Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more