Struct rpki::crypto::keys::PublicKey

source ·
pub struct PublicKey { /* private fields */ }
Expand description

A public key.

Implementations§

source§

impl PublicKey

source

pub fn rsa_from_components( modulus: &[u8], exponent: &[u8] ) -> Result<Self, InvalidInteger>

Creates an RSA Public Key based on the supplied exponent and modulus.

See: [RFC 4055]: https://tools.ietf.org/html/rfc4055

An RSA Public Key uses the following DER encoded structure inside its BitString component:

RSAPublicKey  ::=  SEQUENCE  {
    modulus            INTEGER,    -- n
    publicExponent     INTEGER  }  -- e
source

pub fn rsa_from_bits_bytes( bytes: Bytes ) -> Result<Self, DecodeError<Infallible>>

Creates an RSA public key from the key’s bits.

Note that this is not the DER-encoded public key written by, for instance, the OpenSSL command line tools. These files contain the complete public key including the algorithm and need to be read with PublicKey::decode.

source

pub fn algorithm(&self) -> PublicKeyFormat

Returns the algorithm of this public key.

source

pub fn bits(&self) -> &[u8]

Returns the bits of this public key.

source

pub fn bits_bytes(&self) -> Bytes

Returns the bits as a Bytes value.

source

pub fn allow_rpki_cert(&self) -> bool

Returns whether the key is acceptable for RPKI-internal certificates.

RPKI-internal certificates in this context are those used within the repository itself, i.e., CA certificates and EE certificates for signed objects.

source

pub fn allow_router_cert(&self) -> bool

Returns whether the key is acceptable for BGPSec router certificates.

source

pub fn key_identifier(&self) -> KeyIdentifier

Returns a key identifier for this key.

The identifier will be the SHA1 hash of the key’s bits.

source

pub fn verify<Alg: SignatureAlgorithm>( &self, message: &[u8], signature: &Signature<Alg> ) -> Result<(), SignatureVerificationError>

Verifies a signature using this public key.

source§

impl PublicKey

As SubjectPublicKeyInfo

Public keys are included in X.509 certificates as SubjectPublicKeyInfo structures. As these contain the same information as PublicKey, it can be decoded from and encoded to such sequences.

source

pub fn decode<S: IntoSource>( source: S ) -> Result<Self, DecodeError<<S::Source as Source>::Error>>

source

pub fn take_from<S: Source>( cons: &mut Constructed<'_, S> ) -> Result<Self, DecodeError<S::Error>>

source

pub fn encode(self) -> impl Values

source

pub fn encode_ref(&self) -> impl Values + '_

source

pub fn encode_subject_name(&self) -> impl Values + '_

source

pub fn to_subject_name(&self) -> Name

source

pub fn to_info_bytes(&self) -> Bytes

Returns a bytes values of the encoded the subjectPublicKeyInfo.

This returns a newly “allocated” bytes object.

Trait Implementations§

source§

impl Clone for PublicKey

source§

fn clone(&self) -> PublicKey

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 PublicKey

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for PublicKey

source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
source§

impl PartialEq for PublicKey

source§

fn eq(&self, other: &PublicKey) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for PublicKey

source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for PublicKey

source§

impl StructuralEq for PublicKey

source§

impl StructuralPartialEq for PublicKey

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
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> 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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,