pub struct PublicKey { /* private fields */ }
Expand description
A public key.
Implementations§
source§impl PublicKey
impl PublicKey
sourcepub fn rsa_from_components(
modulus: &[u8],
exponent: &[u8]
) -> Result<Self, InvalidInteger>
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
sourcepub fn rsa_from_bits_bytes(
bytes: Bytes
) -> Result<Self, DecodeError<Infallible>>
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
.
sourcepub fn algorithm(&self) -> PublicKeyFormat
pub fn algorithm(&self) -> PublicKeyFormat
Returns the algorithm of this public key.
sourcepub fn bits_bytes(&self) -> Bytes
pub fn bits_bytes(&self) -> Bytes
Returns the bits as a Bytes
value.
sourcepub fn allow_rpki_cert(&self) -> bool
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.
sourcepub fn allow_router_cert(&self) -> bool
pub fn allow_router_cert(&self) -> bool
Returns whether the key is acceptable for BGPSec router certificates.
sourcepub fn key_identifier(&self) -> KeyIdentifier
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.
sourcepub fn verify<Alg: SignatureAlgorithm>(
&self,
message: &[u8],
signature: &Signature<Alg>
) -> Result<(), SignatureVerificationError>
pub fn verify<Alg: SignatureAlgorithm>( &self, message: &[u8], signature: &Signature<Alg> ) -> Result<(), SignatureVerificationError>
Verifies a signature using this public key.
source§impl PublicKey
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.
pub fn decode<S: IntoSource>( source: S ) -> Result<Self, DecodeError<<S::Source as Source>::Error>>
pub fn take_from<S: Source>( cons: &mut Constructed<'_, S> ) -> Result<Self, DecodeError<S::Error>>
pub fn encode(self) -> impl Values
pub fn encode_ref(&self) -> impl Values + '_
pub fn encode_subject_name(&self) -> impl Values + '_
pub fn to_subject_name(&self) -> Name
sourcepub fn to_info_bytes(&self) -> Bytes
pub fn to_info_bytes(&self) -> Bytes
Returns a bytes values of the encoded the subjectPublicKeyInfo.
This returns a newly “allocated” bytes object.