Replace manual core::fmt::Debug
implementation for RSA parameters.
This commit is contained in:
parent
00eebc26ea
commit
6dd3026adb
13
src/rsa.rs
13
src/rsa.rs
@ -40,21 +40,10 @@ const PUBLIC_KEY_PUBLIC_MODULUS_MAX_LEN: usize = bigint::MODULUS_MAX_LIMBS * lim
|
||||
const PRIVATE_KEY_PUBLIC_MODULUS_MAX_BITS: bits::BitLength = bits::BitLength::from_usize_bits(4096);
|
||||
|
||||
/// Parameters for RSA verification.
|
||||
#[derive(Debug)]
|
||||
pub struct Parameters {
|
||||
padding_alg: &'static padding::Verification,
|
||||
min_bits: bits::BitLength,
|
||||
id: ParametersId,
|
||||
}
|
||||
|
||||
enum ParametersId {
|
||||
RSA_PKCS1_2048_8192_SHA1,
|
||||
RSA_PKCS1_2048_8192_SHA256,
|
||||
RSA_PKCS1_2048_8192_SHA384,
|
||||
RSA_PKCS1_2048_8192_SHA512,
|
||||
RSA_PKCS1_3072_8192_SHA384,
|
||||
RSA_PSS_2048_8192_SHA256,
|
||||
RSA_PSS_2048_8192_SHA384,
|
||||
RSA_PSS_2048_8192_SHA512,
|
||||
}
|
||||
|
||||
fn parse_public_key(
|
||||
|
@ -20,7 +20,7 @@ use untrusted;
|
||||
use crate::rand;
|
||||
|
||||
/// Common features of both RSA padding encoding and RSA padding verification.
|
||||
pub trait Padding: 'static + Sync + crate::sealed::Sealed {
|
||||
pub trait Padding: 'static + Sync + crate::sealed::Sealed + core::fmt::Debug {
|
||||
// The digest algorithm used for digesting the message (and maybe for
|
||||
// other things).
|
||||
fn digest_alg(&self) -> &'static digest::Algorithm;
|
||||
@ -54,6 +54,7 @@ pub trait Verification: Padding {
|
||||
/// documentation for more details.
|
||||
///
|
||||
/// [RFC 3447 Section 8.2]: https://tools.ietf.org/html/rfc3447#section-8.2
|
||||
#[derive(Debug)]
|
||||
pub struct PKCS1 {
|
||||
digest_alg: &'static digest::Algorithm,
|
||||
digestinfo_prefix: &'static [u8],
|
||||
@ -200,6 +201,7 @@ pkcs1_digestinfo_prefix!(
|
||||
/// documentation for more details.
|
||||
///
|
||||
/// [RFC 3447 Section 8.1]: https://tools.ietf.org/html/rfc3447#section-8.1
|
||||
#[derive(Debug)]
|
||||
pub struct PSS {
|
||||
digest_alg: &'static digest::Algorithm,
|
||||
}
|
||||
|
@ -95,27 +95,6 @@ impl signature::VerificationAlgorithm for Parameters {
|
||||
|
||||
impl sealed::Sealed for Parameters {}
|
||||
|
||||
impl core::fmt::Debug for Parameters {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> Result<(), core::fmt::Error> {
|
||||
use super::ParametersId::*;
|
||||
// XXX: This doesn't include the padding algorithm nor the size range.
|
||||
write!(
|
||||
f,
|
||||
"ring::signature::{}",
|
||||
match self.id {
|
||||
RSA_PKCS1_2048_8192_SHA1 => "RSA_PKCS1_2048_8192_SHA1",
|
||||
RSA_PKCS1_2048_8192_SHA256 => "RSA_PKCS1_2048_8192_SHA256",
|
||||
RSA_PKCS1_2048_8192_SHA384 => "RSA_PKCS1_2048_8192_SHA384",
|
||||
RSA_PKCS1_2048_8192_SHA512 => "RSA_PKCS1_2048_8192_SHA512",
|
||||
RSA_PKCS1_3072_8192_SHA384 => "RSA_PKCS1_3072_8192_SHA384",
|
||||
RSA_PSS_2048_8192_SHA256 => "RSA_PSS_2048_8192_SHA256",
|
||||
RSA_PSS_2048_8192_SHA384 => "RSA_PSS_2048_8192_SHA384",
|
||||
RSA_PSS_2048_8192_SHA512 => "RSA_PSS_2048_8192_SHA512",
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! rsa_params {
|
||||
( $VERIFY_ALGORITHM:ident, $min_bits:expr, $PADDING_ALGORITHM:expr,
|
||||
$doc_str:expr ) => {
|
||||
@ -125,7 +104,6 @@ macro_rules! rsa_params {
|
||||
pub static $VERIFY_ALGORITHM: Parameters = Parameters {
|
||||
padding_alg: $PADDING_ALGORITHM,
|
||||
min_bits: bits::BitLength::from_usize_bits($min_bits),
|
||||
id: super::ParametersId::$VERIFY_ALGORITHM,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user