Struct RsaKeyPair
pub struct RsaKeyPair { /* private fields */ }
Expand description
An RSA key pair, used for signing.
Implementations§
§impl KeyPair
impl KeyPair
pub fn generate(size: KeySize) -> Result<KeyPair, Unspecified>
pub fn generate(size: KeySize) -> Result<KeyPair, Unspecified>
Generate a RSA KeyPair
of the specified key-strength.
Supports the following key sizes:
KeySize::Rsa2048
KeySize::Rsa3072
KeySize::Rsa4096
KeySize::Rsa8192
§Errors
Unspecified
: Any key generation failure.
pub fn from_pkcs8(pkcs8: &[u8]) -> Result<KeyPair, KeyRejected>
pub fn from_pkcs8(pkcs8: &[u8]) -> Result<KeyPair, KeyRejected>
Parses an unencrypted PKCS#8 DER encoded RSA private key.
Keys can be generated using KeyPair::generate
.
§ring-compatibility
aws-lc-rs does not impose the same limitations that ring does for RSA keys. Thus signatures may be generated by keys that are not accepted by ring. In particular:
- RSA private keys ranging between 2048-bit keys and 8192-bit keys are supported.
- The public exponent does not have a required minimum size.
§Errors
error::KeyRejected
if bytes do not encode an RSA private key or if the key is otherwise
not acceptable.
pub fn from_der(input: &[u8]) -> Result<KeyPair, KeyRejected>
pub fn from_der(input: &[u8]) -> Result<KeyPair, KeyRejected>
pub fn sign(
&self,
padding_alg: &'static dyn RsaEncoding,
_rng: &dyn SecureRandom,
msg: &[u8],
signature: &mut [u8],
) -> Result<(), Unspecified>
pub fn sign( &self, padding_alg: &'static dyn RsaEncoding, _rng: &dyn SecureRandom, msg: &[u8], signature: &mut [u8], ) -> Result<(), Unspecified>
Sign msg
. msg
is digested using the digest algorithm from
padding_alg
and the digest is then padded using the padding algorithm
from padding_alg
. The signature it written into signature
;
signature
’s length must be exactly the length returned by
public_modulus_len()
.
Many other crypto libraries have signing functions that takes a
precomputed digest as input, instead of the message to digest. This
function does not take a precomputed digest; instead, sign
calculates the digest itself.
§ring Compatibility
Our implementation ignores the SecureRandom
parameter.
§Errors
error::Unspecified
on error.
With “fips” feature enabled, errors if digest length is greater than u32::MAX
.
pub fn public_modulus_len(&self) -> usize
pub fn public_modulus_len(&self) -> usize
Returns the length in bytes of the key pair’s public modulus.
A signature has the same length as the public modulus.
Trait Implementations§
§impl AsDer<Pkcs8V1Der<'static>> for KeyPair
impl AsDer<Pkcs8V1Der<'static>> for KeyPair
§fn as_der(&self) -> Result<Pkcs8V1Der<'static>, Unspecified>
fn as_der(&self) -> Result<Pkcs8V1Der<'static>, Unspecified>
impl Send for KeyPair
impl Sync for KeyPair
Auto Trait Implementations§
impl Freeze for KeyPair
impl RefUnwindSafe for KeyPair
impl Unpin for KeyPair
impl UnwindSafe for KeyPair
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more