commit 0d5eb451b10d74f5c83e2bc376d4abb82d532a09
parent e417cff57c7d18af13f0b34d3024cd12a83e4b58
Author: Zack Newman <zack@philomathiclife.com>
Date: Thu, 12 Jun 2025 22:27:46 -0600
better rsa bits check
Diffstat:
6 files changed, 259 insertions(+), 208 deletions(-)
diff --git a/src/request.rs b/src/request.rs
@@ -3392,23 +3392,29 @@ mod tests {
24, 245, 127, 122, 247, 152, 212, 75, 45, 59, 90, 184, 234, 31, 147, 36, 8, 212, 45,
50, 23, 3, 25, 253, 87, 227, 79, 119, 161,
];
- let p = BigUint::from_slice(
+ let p = BigUint::from_bytes_le(
[
- 352691927, 1294578443, 816143558, 690659917, 1161596366, 1544791087, 3999549486,
- 3319149924, 2349250979, 1304689381, 3959753736, 3377900978, 866506027, 1671521644,
- 3926847564, 898221388, 3448219846, 494454484, 3915534864, 2869735916, 2456511629,
- 3397234721, 3012775852, 3472309790, 1923617705, 2993441050, 3210302569, 3605331368,
- 3352563766, 688081007, 4104512503, 4145593376,
+ 215, 166, 5, 21, 11, 179, 41, 77, 198, 92, 165, 48, 77, 162, 42, 41, 206, 141, 60,
+ 69, 47, 164, 19, 92, 46, 72, 100, 238, 100, 53, 214, 197, 163, 185, 6, 140, 229,
+ 250, 195, 77, 8, 12, 5, 236, 178, 173, 86, 201, 43, 213, 165, 51, 108, 101, 161,
+ 99, 76, 240, 14, 234, 76, 197, 137, 53, 198, 168, 135, 205, 212, 198, 120, 29, 16,
+ 82, 98, 233, 236, 177, 12, 171, 141, 100, 107, 146, 33, 176, 125, 202, 172, 79,
+ 147, 179, 30, 62, 247, 206, 169, 19, 168, 114, 26, 73, 108, 178, 105, 84, 89, 191,
+ 168, 253, 228, 214, 54, 16, 212, 199, 111, 72, 3, 41, 247, 227, 165, 244, 32, 188,
+ 24, 247,
]
.as_slice(),
);
- let p_2 = BigUint::from_slice(
+ let p_2 = BigUint::from_bytes_le(
[
- 4039514409, 964284038, 3230008587, 3320139220, 3562360334, 3165876926, 212773653,
- 2752465512, 2973674888, 1717425549, 2084262803, 3585031058, 4162394935, 1428626842,
- 1015474994, 3283774155, 2840050110, 190639246, 147241978, 2994256073, 4081014755,
- 3102401369, 3547397148, 1545029057, 895305733, 2689179461, 1593439337, 3960057302,
- 193068804, 2835123424, 4054880057, 4200258364,
+ 41, 25, 198, 240, 134, 206, 121, 57, 11, 5, 134, 192, 212, 77, 229, 197, 14, 78,
+ 85, 212, 190, 114, 179, 188, 21, 171, 174, 12, 104, 74, 15, 164, 136, 173, 62, 177,
+ 141, 213, 93, 102, 147, 83, 59, 124, 146, 59, 175, 213, 55, 27, 25, 248, 154, 29,
+ 39, 85, 50, 235, 134, 60, 203, 106, 186, 195, 190, 185, 71, 169, 142, 236, 92, 11,
+ 250, 187, 198, 8, 201, 184, 120, 178, 227, 87, 63, 243, 89, 227, 234, 184, 28, 252,
+ 112, 211, 193, 69, 23, 92, 5, 72, 93, 53, 69, 159, 73, 160, 105, 244, 249, 94, 214,
+ 173, 9, 236, 4, 255, 129, 11, 224, 140, 252, 168, 57, 143, 176, 241, 60, 219, 90,
+ 250,
]
.as_slice(),
);
@@ -3536,23 +3542,29 @@ mod tests {
24, 245, 127, 122, 247, 152, 212, 75, 45, 59, 90, 184, 234, 31, 147, 36, 8, 212, 45,
50, 23, 3, 25, 253, 87, 227, 79, 119, 161,
];
- let p = BigUint::from_slice(
+ let p = BigUint::from_bytes_le(
[
- 352691927, 1294578443, 816143558, 690659917, 1161596366, 1544791087, 3999549486,
- 3319149924, 2349250979, 1304689381, 3959753736, 3377900978, 866506027, 1671521644,
- 3926847564, 898221388, 3448219846, 494454484, 3915534864, 2869735916, 2456511629,
- 3397234721, 3012775852, 3472309790, 1923617705, 2993441050, 3210302569, 3605331368,
- 3352563766, 688081007, 4104512503, 4145593376,
+ 215, 166, 5, 21, 11, 179, 41, 77, 198, 92, 165, 48, 77, 162, 42, 41, 206, 141, 60,
+ 69, 47, 164, 19, 92, 46, 72, 100, 238, 100, 53, 214, 197, 163, 185, 6, 140, 229,
+ 250, 195, 77, 8, 12, 5, 236, 178, 173, 86, 201, 43, 213, 165, 51, 108, 101, 161,
+ 99, 76, 240, 14, 234, 76, 197, 137, 53, 198, 168, 135, 205, 212, 198, 120, 29, 16,
+ 82, 98, 233, 236, 177, 12, 171, 141, 100, 107, 146, 33, 176, 125, 202, 172, 79,
+ 147, 179, 30, 62, 247, 206, 169, 19, 168, 114, 26, 73, 108, 178, 105, 84, 89, 191,
+ 168, 253, 228, 214, 54, 16, 212, 199, 111, 72, 3, 41, 247, 227, 165, 244, 32, 188,
+ 24, 247,
]
.as_slice(),
);
- let p_2 = BigUint::from_slice(
+ let p_2 = BigUint::from_bytes_le(
[
- 4039514409, 964284038, 3230008587, 3320139220, 3562360334, 3165876926, 212773653,
- 2752465512, 2973674888, 1717425549, 2084262803, 3585031058, 4162394935, 1428626842,
- 1015474994, 3283774155, 2840050110, 190639246, 147241978, 2994256073, 4081014755,
- 3102401369, 3547397148, 1545029057, 895305733, 2689179461, 1593439337, 3960057302,
- 193068804, 2835123424, 4054880057, 4200258364,
+ 41, 25, 198, 240, 134, 206, 121, 57, 11, 5, 134, 192, 212, 77, 229, 197, 14, 78,
+ 85, 212, 190, 114, 179, 188, 21, 171, 174, 12, 104, 74, 15, 164, 136, 173, 62, 177,
+ 141, 213, 93, 102, 147, 83, 59, 124, 146, 59, 175, 213, 55, 27, 25, 248, 154, 29,
+ 39, 85, 50, 235, 134, 60, 203, 106, 186, 195, 190, 185, 71, 169, 142, 236, 92, 11,
+ 250, 187, 198, 8, 201, 184, 120, 178, 227, 87, 63, 243, 89, 227, 234, 184, 28, 252,
+ 112, 211, 193, 69, 23, 92, 5, 72, 93, 53, 69, 159, 73, 160, 105, 244, 249, 94, 214,
+ 173, 9, 236, 4, 255, 129, 11, 224, 140, 252, 168, 57, 143, 176, 241, 60, 219, 90,
+ 250,
]
.as_slice(),
);
diff --git a/src/response/register.rs b/src/response/register.rs
@@ -1376,16 +1376,12 @@ pub const MIN_RSA_E: u32 = 3;
///
/// [RFC 8230 § 6.1](https://www.rfc-editor.org/rfc/rfc8230#section-6.1) recommends allowing moduli up to 16K bits.
pub const MAX_RSA_N_BITS: usize = 0x4000;
-/// [`MAX_RSA_N_BITS`] as bytes.
-pub const MAX_RSA_N_BYTES: usize = MAX_RSA_N_BITS >> 3;
/// The fewest bits an RSA public key modulus is allowed to consist of per [`RsaPubKey`].
///
/// [RFC 8230 § 6.1](https://www.rfc-editor.org/rfc/rfc8230#section-6.1) requires the modulus to be at least 2048
/// bits.
pub const MIN_RSA_N_BITS: usize = 0x800;
-/// [`MIN_RSA_N_BITS`] as bytes.
-pub const MIN_RSA_N_BYTES: usize = MIN_RSA_N_BITS >> 3;
-/// [`MIN_RSA_N_BYTES`]–[`MAX_RSA_N_BYTES`] bytes representing the big-endian modulus and a `u32` `>=`
+/// [`MIN_RSA_N_BITS`]–[`MAX_RSA_N_BITS`] bits representing the big-endian modulus and a `u32` `>=`
/// [`MIN_RSA_E`] representing the exponent of an alleged RSA public key.
#[derive(Clone, Copy, Debug)]
pub struct RsaPubKey<T>(T, u32);
@@ -1423,13 +1419,11 @@ impl<T: AsRef<[u8]>> RsaPubKey<T> {
}
/// Converts `self` into [`RsaVerKey`].
pub(super) fn as_ver_key(&self) -> Result<RsaVerKey<Sha256>, PubKeyErr> {
- RsaPublicKey::new_with_max_size(
- BigUint::from_bytes_be(self.0.as_ref()),
- self.1.into(),
- MAX_RSA_N_BITS,
- )
- .map_err(|_e| PubKeyErr::Rsa)
- .map(RsaVerKey::new)
+ let n = BigUint::from_bytes_be(self.0.as_ref());
+ let bits = n.bits();
+ RsaPublicKey::new_with_max_size(n, self.1.into(), bits)
+ .map_err(|_e| PubKeyErr::Rsa)
+ .map(RsaVerKey::new)
}
}
impl RsaPubKey<&[u8]> {
@@ -1444,21 +1438,36 @@ impl<'a: 'b, 'b> TryFrom<(&'a [u8], u32)> for RsaPubKey<&'b [u8]> {
type Error = RsaPubKeyErr;
/// The first item is the big-endian modulus, and the second item is the exponent.
///
- /// Note `n` is _not_ checked for leading 0s before its length is checked to be within [`MIN_RSA_N_BYTES`]
- /// and [`MAX_RSA_N_BYTES`] inclusively. If this is not desired, then calling code must remove leading 0s
- /// before calling. Several encodings require leading 0s to not exist so one would likely already be
- /// verifying there are no leading 0s.
+ /// Note the first byte of `n` must not be `0`.
+ #[expect(
+ clippy::arithmetic_side_effects,
+ clippy::as_conversions,
+ reason = "comment justifies correctness"
+ )]
#[inline]
fn try_from((n, e): (&'a [u8], u32)) -> Result<Self, Self::Error> {
- if (MIN_RSA_N_BYTES..=MAX_RSA_N_BYTES).contains(&n.len()) {
- if e >= MIN_RSA_E {
- Ok(Self(n, e))
+ n.first().map_or(Err(RsaPubKeyErr::N), |fst| {
+ if *fst == 0 {
+ Err(RsaPubKeyErr::NLeading0)
+ } else if let Some(bits) = n.len().checked_mul(8) {
+ if (MIN_RSA_N_BITS..=MAX_RSA_N_BITS)
+ // `fst.leading_zeros()` is inclusively between `0` and `8`, so it's safe to convert to a
+ // `usize`.
+ // `bits` is at least 8 since `n.len()` is at least 1; thus underflow cannot occur.
+ .contains(&(bits - fst.leading_zeros() as usize))
+ {
+ if e >= MIN_RSA_E {
+ Ok(Self(n, e))
+ } else {
+ Err(RsaPubKeyErr::E)
+ }
+ } else {
+ Err(RsaPubKeyErr::N)
+ }
} else {
- Err(RsaPubKeyErr::E)
+ Err(RsaPubKeyErr::N)
}
- } else {
- Err(RsaPubKeyErr::N)
- }
+ })
}
}
impl TryFrom<(Vec<u8>, u32)> for RsaPubKey<Vec<u8>> {
@@ -1829,48 +1838,41 @@ impl<'a> FromCbor<'a> for RsaPubKey<&'a [u8]> {
let n_len = usize::from(u16::from_be_bytes(len));
if n_len > 255 {
n_len_rem.split_at_checked(n_len).ok_or(CoseKeyErr::Len).and_then(|(n, n_rem)| {
- // `n` has length at least 256, so this is fine.
- // We ensure the leading byte is not 0; otherwise the modulus is not properly
- // encoded. Note the modulus can never be 0.
- if n[0] > 0 {
- n_rem.split_at_checked(2).ok_or(CoseKeyErr::RsaCoseEncoding).and_then(|(e_meta, e_meta_rem)| {
+ n_rem.split_at_checked(2).ok_or(CoseKeyErr::RsaCoseEncoding).and_then(|(e_meta, e_meta_rem)| {
+ // `e_meta.len() == 2`, so this is fine.
+ if e_meta[0] == E {
// `e_meta.len() == 2`, so this is fine.
- if e_meta[0] == E {
- // `e_meta.len() == 2`, so this is fine.
- let e_meta_len = e_meta[1];
- if e_meta_len & cbor::BYTES == cbor::BYTES {
- let e_len = usize::from(e_meta_len ^ cbor::BYTES);
- if e_len < 5 {
- e_meta_rem.split_at_checked(e_len).ok_or(CoseKeyErr::Len).and_then(|(e_slice, remaining)| {
- e_slice.first().ok_or(CoseKeyErr::Len).and_then(|e_first| {
- // We ensure the leading byte is not 0; otherwise the
- // exponent is not properly encoded. Note the exponent
- // can never be 0.
- if *e_first > 0 {
- let mut e = [0; 4];
- // `e_slice.len()` is `e_len` which is less than 5.
- // We also know it is greater than 0 since `e_slice.first()` did not err.
- // Thus this won't `panic`.
- e[4 - e_len..].copy_from_slice(e_slice);
- Self::try_from((n, u32::from_be_bytes(e))).map_err(CoseKeyErr::RsaPubKey).map(|value| CborSuccess { value, remaining, } )
- } else {
- Err(CoseKeyErr::RsaCoseEncoding)
- }
- })
+ let e_meta_len = e_meta[1];
+ if e_meta_len & cbor::BYTES == cbor::BYTES {
+ let e_len = usize::from(e_meta_len ^ cbor::BYTES);
+ if e_len < 5 {
+ e_meta_rem.split_at_checked(e_len).ok_or(CoseKeyErr::Len).and_then(|(e_slice, remaining)| {
+ e_slice.first().ok_or(CoseKeyErr::Len).and_then(|e_first| {
+ // We ensure the leading byte is not 0; otherwise the
+ // exponent is not properly encoded. Note the exponent
+ // can never be 0.
+ if *e_first > 0 {
+ let mut e = [0; 4];
+ // `e_slice.len()` is `e_len` which is less than 5.
+ // We also know it is greater than 0 since `e_slice.first()` did not err.
+ // Thus this won't `panic`.
+ e[4 - e_len..].copy_from_slice(e_slice);
+ Self::try_from((n, u32::from_be_bytes(e))).map_err(CoseKeyErr::RsaPubKey).map(|value| CborSuccess { value, remaining, } )
+ } else {
+ Err(CoseKeyErr::RsaCoseEncoding)
+ }
})
- } else {
- Err(CoseKeyErr::RsaExponentTooLarge)
- }
+ })
} else {
- Err(CoseKeyErr::RsaCoseEncoding)
+ Err(CoseKeyErr::RsaExponentTooLarge)
}
} else {
Err(CoseKeyErr::RsaCoseEncoding)
}
- })
- } else {
- Err(CoseKeyErr::RsaCoseEncoding)
- }
+ } else {
+ Err(CoseKeyErr::RsaCoseEncoding)
+ }
+ })
})
} else {
Err(CoseKeyErr::RsaCoseEncoding)
diff --git a/src/response/register/bin.rs b/src/response/register/bin.rs
@@ -169,16 +169,8 @@ impl<'a> DecodeBuffer<'a> for RsaPubKey<Vec<u8>> {
// benefit in performing "expensive" validation checks.
fn decode_from_buffer(data: &mut &'a [u8]) -> Result<Self, Self::Err> {
Vec::decode_from_buffer(data).and_then(|n| {
- // [`Self::try_from`] allows leading 0s; thus we ensure
- // there are none since it's cheap. `Self::try_from` enforces
- // that the length is at least 256, so we don't have to worry
- // about the case when `n` is empty here.
- if n.first() == Some(&0) {
- Err(EncDecErr)
- } else {
- u32::decode_from_buffer(data)
- .and_then(|e| Self::try_from((n, e)).map_err(|_e| EncDecErr))
- }
+ u32::decode_from_buffer(data)
+ .and_then(|e| Self::try_from((n, e)).map_err(|_e| EncDecErr))
})
}
}
diff --git a/src/response/register/error.rs b/src/response/register/error.rs
@@ -16,7 +16,7 @@ use super::{
Aaguid, Attestation, AttestationObject, AttestedCredentialData, AuthenticatorAttachment,
AuthenticatorAttestation, AuthenticatorData, AuthenticatorExtensionOutput, Backup,
ClientExtensionsOutputs, CollectedClientData, CompressedP256PubKey, CompressedP384PubKey,
- Ed25519PubKey, Ed25519Signature, Flag, MAX_RSA_N_BYTES, MIN_RSA_E, MIN_RSA_N_BYTES, Metadata,
+ Ed25519PubKey, Ed25519Signature, Flag, MAX_RSA_N_BITS, MIN_RSA_E, MIN_RSA_N_BITS, Metadata,
PackedAttestation, RsaPubKey, UncompressedP256PubKey, UncompressedP384PubKey,
UncompressedPubKey,
};
@@ -104,8 +104,10 @@ impl Error for CompressedP384PubKeyErr {}
/// Error returned from [`RsaPubKey::try_from`].
#[derive(Clone, Copy, Debug)]
pub enum RsaPubKeyErr {
- /// Variant returned when the modulus has length less than [`MIN_RSA_N_BYTES`] or greater than
- /// [`MAX_RSA_N_BYTES`].
+ /// Variant returned when the modulus has a leading 0.
+ NLeading0,
+ /// Variant returned when the modulus has fewer than [`MIN_RSA_N_BITS`] or more than
+ /// [`MAX_RSA_N_BITS`].
N,
/// Variant returned when the exponent is less than [`MIN_RSA_E`].
E,
@@ -114,7 +116,8 @@ impl Display for RsaPubKeyErr {
#[inline]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str(match *self {
- Self::N => "the RSA public key modulus had length less than 256 or greater than 2048",
+ Self::NLeading0 => "the RSA public key modulus had a leading 0",
+ Self::N => "the RSA public key modulus was less than 2048 bits or greater than 16384",
Self::E => "the RSA public key exponent was less than 3",
})
}
diff --git a/src/response/register/ser.rs b/src/response/register/ser.rs
@@ -1500,23 +1500,29 @@ mod tests {
24, 245, 127, 122, 247, 152, 212, 75, 45, 59, 90, 184, 234, 31, 147, 36, 8, 212, 45,
50, 23, 3, 25, 253, 87, 227, 79, 119, 161,
];
- let p = BigUint::from_slice(
+ let p = BigUint::from_bytes_le(
[
- 352691927, 1294578443, 816143558, 690659917, 1161596366, 1544791087, 3999549486,
- 3319149924, 2349250979, 1304689381, 3959753736, 3377900978, 866506027, 1671521644,
- 3926847564, 898221388, 3448219846, 494454484, 3915534864, 2869735916, 2456511629,
- 3397234721, 3012775852, 3472309790, 1923617705, 2993441050, 3210302569, 3605331368,
- 3352563766, 688081007, 4104512503, 4145593376,
+ 215, 166, 5, 21, 11, 179, 41, 77, 198, 92, 165, 48, 77, 162, 42, 41, 206, 141, 60,
+ 69, 47, 164, 19, 92, 46, 72, 100, 238, 100, 53, 214, 197, 163, 185, 6, 140, 229,
+ 250, 195, 77, 8, 12, 5, 236, 178, 173, 86, 201, 43, 213, 165, 51, 108, 101, 161,
+ 99, 76, 240, 14, 234, 76, 197, 137, 53, 198, 168, 135, 205, 212, 198, 120, 29, 16,
+ 82, 98, 233, 236, 177, 12, 171, 141, 100, 107, 146, 33, 176, 125, 202, 172, 79,
+ 147, 179, 30, 62, 247, 206, 169, 19, 168, 114, 26, 73, 108, 178, 105, 84, 89, 191,
+ 168, 253, 228, 214, 54, 16, 212, 199, 111, 72, 3, 41, 247, 227, 165, 244, 32, 188,
+ 24, 247,
]
.as_slice(),
);
- let p_2 = BigUint::from_slice(
+ let p_2 = BigUint::from_bytes_le(
[
- 4039514409, 964284038, 3230008587, 3320139220, 3562360334, 3165876926, 212773653,
- 2752465512, 2973674888, 1717425549, 2084262803, 3585031058, 4162394935, 1428626842,
- 1015474994, 3283774155, 2840050110, 190639246, 147241978, 2994256073, 4081014755,
- 3102401369, 3547397148, 1545029057, 895305733, 2689179461, 1593439337, 3960057302,
- 193068804, 2835123424, 4054880057, 4200258364,
+ 41, 25, 198, 240, 134, 206, 121, 57, 11, 5, 134, 192, 212, 77, 229, 197, 14, 78,
+ 85, 212, 190, 114, 179, 188, 21, 171, 174, 12, 104, 74, 15, 164, 136, 173, 62, 177,
+ 141, 213, 93, 102, 147, 83, 59, 124, 146, 59, 175, 213, 55, 27, 25, 248, 154, 29,
+ 39, 85, 50, 235, 134, 60, 203, 106, 186, 195, 190, 185, 71, 169, 142, 236, 92, 11,
+ 250, 187, 198, 8, 201, 184, 120, 178, 227, 87, 63, 243, 89, 227, 234, 184, 28, 252,
+ 112, 211, 193, 69, 23, 92, 5, 72, 93, 53, 69, 159, 73, 160, 105, 244, 249, 94, 214,
+ 173, 9, 236, 4, 255, 129, 11, 224, 140, 252, 168, 57, 143, 176, 241, 60, 219, 90,
+ 250,
]
.as_slice(),
);
@@ -5247,23 +5253,29 @@ mod tests {
24, 245, 127, 122, 247, 152, 212, 75, 45, 59, 90, 184, 234, 31, 147, 36, 8, 212, 45,
50, 23, 3, 25, 253, 87, 227, 79, 119, 161,
];
- let p = BigUint::from_slice(
+ let p = BigUint::from_bytes_le(
[
- 352691927, 1294578443, 816143558, 690659917, 1161596366, 1544791087, 3999549486,
- 3319149924, 2349250979, 1304689381, 3959753736, 3377900978, 866506027, 1671521644,
- 3926847564, 898221388, 3448219846, 494454484, 3915534864, 2869735916, 2456511629,
- 3397234721, 3012775852, 3472309790, 1923617705, 2993441050, 3210302569, 3605331368,
- 3352563766, 688081007, 4104512503, 4145593376,
+ 215, 166, 5, 21, 11, 179, 41, 77, 198, 92, 165, 48, 77, 162, 42, 41, 206, 141, 60,
+ 69, 47, 164, 19, 92, 46, 72, 100, 238, 100, 53, 214, 197, 163, 185, 6, 140, 229,
+ 250, 195, 77, 8, 12, 5, 236, 178, 173, 86, 201, 43, 213, 165, 51, 108, 101, 161,
+ 99, 76, 240, 14, 234, 76, 197, 137, 53, 198, 168, 135, 205, 212, 198, 120, 29, 16,
+ 82, 98, 233, 236, 177, 12, 171, 141, 100, 107, 146, 33, 176, 125, 202, 172, 79,
+ 147, 179, 30, 62, 247, 206, 169, 19, 168, 114, 26, 73, 108, 178, 105, 84, 89, 191,
+ 168, 253, 228, 214, 54, 16, 212, 199, 111, 72, 3, 41, 247, 227, 165, 244, 32, 188,
+ 24, 247,
]
.as_slice(),
);
- let p_2 = BigUint::from_slice(
+ let p_2 = BigUint::from_bytes_le(
[
- 4039514409, 964284038, 3230008587, 3320139220, 3562360334, 3165876926, 212773653,
- 2752465512, 2973674888, 1717425549, 2084262803, 3585031058, 4162394935, 1428626842,
- 1015474994, 3283774155, 2840050110, 190639246, 147241978, 2994256073, 4081014755,
- 3102401369, 3547397148, 1545029057, 895305733, 2689179461, 1593439337, 3960057302,
- 193068804, 2835123424, 4054880057, 4200258364,
+ 41, 25, 198, 240, 134, 206, 121, 57, 11, 5, 134, 192, 212, 77, 229, 197, 14, 78,
+ 85, 212, 190, 114, 179, 188, 21, 171, 174, 12, 104, 74, 15, 164, 136, 173, 62, 177,
+ 141, 213, 93, 102, 147, 83, 59, 124, 146, 59, 175, 213, 55, 27, 25, 248, 154, 29,
+ 39, 85, 50, 235, 134, 60, 203, 106, 186, 195, 190, 185, 71, 169, 142, 236, 92, 11,
+ 250, 187, 198, 8, 201, 184, 120, 178, 227, 87, 63, 243, 89, 227, 234, 184, 28, 252,
+ 112, 211, 193, 69, 23, 92, 5, 72, 93, 53, 69, 159, 73, 160, 105, 244, 249, 94, 214,
+ 173, 9, 236, 4, 255, 129, 11, 224, 140, 252, 168, 57, 143, 176, 241, 60, 219, 90,
+ 250,
]
.as_slice(),
);
@@ -5401,59 +5413,71 @@ mod tests {
);
// `publicKey` mismatch.
let bad_pub_key = RsaPrivateKey::from_components(
- BigUint::from_slice(
+ BigUint::from_bytes_le(
[
- 1268883887, 2823353396, 2015459101, 2565332483, 1399879646, 2924146141,
- 4220770383, 1927962357, 4262532606, 2135651080, 1832605590, 1515549926,
- 3644825611, 4206568969, 2754000866, 320264886, 3679698234, 1661964299,
- 959358615, 2210230033, 2052419982, 355790524, 3278273908, 2619188662,
- 2625484501, 48052312, 1943153506, 1483277344, 3973029557, 4043176610,
- 855443528, 2857170908, 3890300047, 301219953, 568959626, 3742057218,
- 3248023740, 888348692, 4077005632, 3902164232, 2136970349, 581060407,
- 881283894, 706789292, 3469945706, 3899549796, 3027774213, 3918538918,
- 1736861679, 3096109311, 612338128, 3388510141, 3895712258, 2085822048,
- 3004690797, 3572406263, 3744148684, 179106196, 1147050987, 3212056692,
- 595539286, 1003275909, 17854028, 2642908175,
+ 175, 161, 161, 75, 52, 244, 72, 168, 29, 119, 33, 120, 3, 222, 231, 152, 222,
+ 119, 112, 83, 221, 237, 74, 174, 79, 216, 147, 251, 245, 94, 234, 114, 254, 21,
+ 17, 254, 8, 115, 75, 127, 150, 87, 59, 109, 230, 116, 85, 90, 11, 160, 63, 217,
+ 9, 38, 187, 250, 226, 183, 38, 164, 182, 218, 22, 19, 58, 189, 83, 219, 11,
+ 144, 15, 99, 151, 166, 46, 57, 17, 111, 189, 131, 142, 113, 85, 122, 188, 238,
+ 52, 21, 116, 125, 102, 195, 182, 165, 29, 156, 213, 182, 125, 156, 88, 56, 221,
+ 2, 98, 43, 210, 115, 32, 4, 105, 88, 181, 158, 207, 236, 162, 250, 253, 240,
+ 72, 8, 253, 50, 220, 247, 76, 170, 143, 68, 225, 231, 113, 64, 244, 17, 138,
+ 162, 233, 33, 2, 67, 11, 223, 188, 232, 152, 193, 20, 32, 243, 52, 64, 43, 2,
+ 243, 8, 77, 150, 232, 109, 148, 95, 127, 55, 71, 162, 34, 54, 83, 135, 52, 172,
+ 191, 32, 42, 106, 43, 211, 206, 100, 104, 110, 232, 5, 43, 120, 180, 166, 40,
+ 144, 233, 239, 103, 134, 103, 255, 224, 138, 184, 208, 137, 127, 36, 189, 143,
+ 248, 201, 2, 218, 51, 232, 96, 30, 83, 124, 109, 241, 23, 179, 247, 151, 238,
+ 212, 204, 44, 43, 223, 148, 241, 172, 10, 235, 155, 94, 68, 116, 24, 116, 191,
+ 86, 53, 127, 35, 133, 198, 204, 59, 76, 110, 16, 1, 15, 148, 135, 157,
]
.as_slice(),
),
65537u32.into(),
- BigUint::from_slice(
+ BigUint::from_bytes_le(
[
- 4219166081, 3411287400, 3981141108, 1678549103, 2990099628, 1028778896,
- 672985971, 2520258231, 1054615108, 2922409705, 1844757795, 1160015252,
- 1910592069, 468649647, 4013057473, 772236922, 1958956898, 2475335323,
- 3977796915, 1829655286, 1576008336, 2187384383, 2445706978, 1642531745,
- 1610593494, 4268513438, 3095769587, 1486118748, 4109728823, 2030327380,
- 2959206188, 681254334, 1353008441, 725092776, 2634942185, 1480646512,
- 390137741, 1392955456, 4172679229, 2746438782, 2237328976, 2974223876,
- 2535267247, 3282201811, 1453825287, 3948348329, 3639451225, 1053160223,
- 3867366405, 204601530, 2268984413, 4053930420, 2331079437, 2795201243,
- 621559743, 1420993793, 693127368, 2379843661, 4078948854, 4130031519,
- 1957410463, 3951952652, 1514579162, 1261104787,
+ 129, 93, 123, 251, 104, 29, 84, 203, 116, 100, 75, 237, 111, 160, 12, 100, 172,
+ 76, 57, 178, 144, 235, 81, 61, 115, 243, 28, 40, 183, 22, 56, 150, 68, 38, 220,
+ 62, 233, 110, 48, 174, 35, 197, 244, 109, 148, 109, 36, 69, 69, 82, 225, 113,
+ 175, 6, 239, 27, 193, 101, 50, 239, 122, 102, 7, 46, 98, 79, 195, 116, 155,
+ 158, 138, 147, 51, 93, 24, 237, 246, 82, 14, 109, 144, 250, 239, 93, 63, 214,
+ 96, 130, 226, 134, 198, 145, 161, 11, 231, 97, 214, 180, 255, 95, 158, 88, 108,
+ 254, 243, 177, 133, 184, 92, 95, 148, 88, 55, 124, 245, 244, 84, 86, 4, 121,
+ 44, 231, 97, 176, 190, 29, 155, 40, 57, 69, 165, 80, 168, 9, 56, 43, 233, 6,
+ 14, 157, 112, 223, 64, 88, 141, 7, 65, 23, 64, 208, 6, 83, 61, 8, 182, 248,
+ 126, 84, 179, 163, 80, 238, 90, 133, 4, 14, 71, 177, 175, 27, 29, 151, 211,
+ 108, 162, 195, 7, 157, 167, 86, 169, 3, 87, 235, 89, 158, 237, 216, 31, 243,
+ 197, 62, 5, 84, 131, 230, 186, 248, 49, 12, 93, 244, 61, 135, 180, 17, 162,
+ 241, 13, 115, 241, 138, 219, 98, 155, 166, 191, 63, 12, 37, 1, 165, 178, 84,
+ 200, 72, 80, 41, 77, 136, 217, 141, 246, 209, 31, 243, 159, 71, 43, 246, 159,
+ 182, 171, 116, 12, 3, 142, 235, 218, 164, 70, 90, 147, 238, 42, 75,
]
.as_slice(),
),
vec![
- BigUint::from_slice(
+ BigUint::from_bytes_le(
[
- 477022167, 1829769280, 2090244202, 1551476276, 1157631474, 2890438663,
- 3030138742, 490022796, 816963781, 1097260329, 1043839249, 132356315,
- 2333006670, 2559626311, 4109838094, 1022025893, 518867669, 2331160934,
- 796532648, 1910610894, 4103647079, 3748718875, 3000444664, 2030629908,
- 2051410714, 1470584080, 3823425600, 150616493, 3406571229, 728760788,
- 1642158920, 3248110052,
+ 215, 199, 110, 28, 64, 16, 16, 109, 106, 152, 150, 124, 52, 166, 121, 92,
+ 242, 13, 0, 69, 7, 152, 72, 172, 118, 63, 156, 180, 140, 39, 53, 29, 197,
+ 224, 177, 48, 41, 221, 102, 65, 17, 185, 55, 62, 219, 152, 227, 7, 78, 219,
+ 14, 139, 71, 204, 144, 152, 14, 39, 247, 244, 165, 224, 234, 60, 213, 74,
+ 237, 30, 102, 177, 242, 138, 168, 31, 122, 47, 206, 155, 225, 113, 103,
+ 175, 152, 244, 27, 233, 112, 223, 248, 38, 215, 178, 20, 244, 8, 121, 26,
+ 11, 70, 122, 16, 85, 167, 87, 64, 216, 228, 227, 173, 57, 250, 8, 221, 38,
+ 12, 203, 212, 1, 112, 43, 72, 91, 225, 97, 228, 57, 154, 193,
]
.as_slice(),
),
- BigUint::from_slice(
+ BigUint::from_bytes_le(
[
- 2563529193, 1846080031, 2674900518, 1429039465, 4196332559, 1876681390,
- 2277818219, 2814016273, 3312979285, 3981345183, 451288984, 3552968165,
- 2390674537, 2887399418, 103653441, 3997324899, 2875328107, 2697584733,
- 2018692127, 116301540, 2576747710, 1194942447, 2615930724, 3775252553,
- 808368511, 2384549107, 387191569, 980553943, 2487815891, 4238343336,
- 3546626429, 3494710460,
+ 233, 89, 204, 152, 31, 242, 8, 110, 38, 190, 111, 159, 105, 105, 45, 85,
+ 15, 244, 30, 250, 174, 226, 219, 111, 107, 191, 196, 135, 17, 123, 186,
+ 167, 85, 13, 120, 197, 159, 129, 78, 237, 152, 31, 230, 26, 229, 253, 197,
+ 211, 105, 204, 126, 142, 250, 55, 26, 172, 65, 160, 45, 6, 99, 86, 66, 238,
+ 107, 6, 98, 171, 93, 224, 201, 160, 31, 204, 82, 120, 228, 158, 238, 6,
+ 190, 12, 150, 153, 239, 95, 57, 71, 100, 239, 235, 155, 73, 200, 5, 225,
+ 127, 185, 46, 48, 243, 84, 33, 142, 17, 19, 20, 23, 215, 16, 114, 58, 211,
+ 14, 73, 148, 168, 252, 159, 252, 125, 57, 101, 211, 188, 12, 77, 208,
]
.as_slice(),
),
diff --git a/src/response/register/ser_relaxed.rs b/src/response/register/ser_relaxed.rs
@@ -4491,23 +4491,29 @@ mod tests {
24, 245, 127, 122, 247, 152, 212, 75, 45, 59, 90, 184, 234, 31, 147, 36, 8, 212, 45,
50, 23, 3, 25, 253, 87, 227, 79, 119, 161,
];
- let p = BigUint::from_slice(
+ let p = BigUint::from_bytes_le(
[
- 352691927, 1294578443, 816143558, 690659917, 1161596366, 1544791087, 3999549486,
- 3319149924, 2349250979, 1304689381, 3959753736, 3377900978, 866506027, 1671521644,
- 3926847564, 898221388, 3448219846, 494454484, 3915534864, 2869735916, 2456511629,
- 3397234721, 3012775852, 3472309790, 1923617705, 2993441050, 3210302569, 3605331368,
- 3352563766, 688081007, 4104512503, 4145593376,
+ 215, 166, 5, 21, 11, 179, 41, 77, 198, 92, 165, 48, 77, 162, 42, 41, 206, 141, 60,
+ 69, 47, 164, 19, 92, 46, 72, 100, 238, 100, 53, 214, 197, 163, 185, 6, 140, 229,
+ 250, 195, 77, 8, 12, 5, 236, 178, 173, 86, 201, 43, 213, 165, 51, 108, 101, 161,
+ 99, 76, 240, 14, 234, 76, 197, 137, 53, 198, 168, 135, 205, 212, 198, 120, 29, 16,
+ 82, 98, 233, 236, 177, 12, 171, 141, 100, 107, 146, 33, 176, 125, 202, 172, 79,
+ 147, 179, 30, 62, 247, 206, 169, 19, 168, 114, 26, 73, 108, 178, 105, 84, 89, 191,
+ 168, 253, 228, 214, 54, 16, 212, 199, 111, 72, 3, 41, 247, 227, 165, 244, 32, 188,
+ 24, 247,
]
.as_slice(),
);
- let p_2 = BigUint::from_slice(
+ let p_2 = BigUint::from_bytes_le(
[
- 4039514409, 964284038, 3230008587, 3320139220, 3562360334, 3165876926, 212773653,
- 2752465512, 2973674888, 1717425549, 2084262803, 3585031058, 4162394935, 1428626842,
- 1015474994, 3283774155, 2840050110, 190639246, 147241978, 2994256073, 4081014755,
- 3102401369, 3547397148, 1545029057, 895305733, 2689179461, 1593439337, 3960057302,
- 193068804, 2835123424, 4054880057, 4200258364,
+ 41, 25, 198, 240, 134, 206, 121, 57, 11, 5, 134, 192, 212, 77, 229, 197, 14, 78,
+ 85, 212, 190, 114, 179, 188, 21, 171, 174, 12, 104, 74, 15, 164, 136, 173, 62, 177,
+ 141, 213, 93, 102, 147, 83, 59, 124, 146, 59, 175, 213, 55, 27, 25, 248, 154, 29,
+ 39, 85, 50, 235, 134, 60, 203, 106, 186, 195, 190, 185, 71, 169, 142, 236, 92, 11,
+ 250, 187, 198, 8, 201, 184, 120, 178, 227, 87, 63, 243, 89, 227, 234, 184, 28, 252,
+ 112, 211, 193, 69, 23, 92, 5, 72, 93, 53, 69, 159, 73, 160, 105, 244, 249, 94, 214,
+ 173, 9, 236, 4, 255, 129, 11, 224, 140, 252, 168, 57, 143, 176, 241, 60, 219, 90,
+ 250,
]
.as_slice(),
);
@@ -4636,59 +4642,71 @@ mod tests {
);
// `publicKey` mismatch.
let bad_pub_key = RsaPrivateKey::from_components(
- BigUint::from_slice(
+ BigUint::from_bytes_le(
[
- 1268883887, 2823353396, 2015459101, 2565332483, 1399879646, 2924146141,
- 4220770383, 1927962357, 4262532606, 2135651080, 1832605590, 1515549926,
- 3644825611, 4206568969, 2754000866, 320264886, 3679698234, 1661964299,
- 959358615, 2210230033, 2052419982, 355790524, 3278273908, 2619188662,
- 2625484501, 48052312, 1943153506, 1483277344, 3973029557, 4043176610,
- 855443528, 2857170908, 3890300047, 301219953, 568959626, 3742057218,
- 3248023740, 888348692, 4077005632, 3902164232, 2136970349, 581060407,
- 881283894, 706789292, 3469945706, 3899549796, 3027774213, 3918538918,
- 1736861679, 3096109311, 612338128, 3388510141, 3895712258, 2085822048,
- 3004690797, 3572406263, 3744148684, 179106196, 1147050987, 3212056692,
- 595539286, 1003275909, 17854028, 2642908175,
+ 175, 161, 161, 75, 52, 244, 72, 168, 29, 119, 33, 120, 3, 222, 231, 152, 222,
+ 119, 112, 83, 221, 237, 74, 174, 79, 216, 147, 251, 245, 94, 234, 114, 254, 21,
+ 17, 254, 8, 115, 75, 127, 150, 87, 59, 109, 230, 116, 85, 90, 11, 160, 63, 217,
+ 9, 38, 187, 250, 226, 183, 38, 164, 182, 218, 22, 19, 58, 189, 83, 219, 11,
+ 144, 15, 99, 151, 166, 46, 57, 17, 111, 189, 131, 142, 113, 85, 122, 188, 238,
+ 52, 21, 116, 125, 102, 195, 182, 165, 29, 156, 213, 182, 125, 156, 88, 56, 221,
+ 2, 98, 43, 210, 115, 32, 4, 105, 88, 181, 158, 207, 236, 162, 250, 253, 240,
+ 72, 8, 253, 50, 220, 247, 76, 170, 143, 68, 225, 231, 113, 64, 244, 17, 138,
+ 162, 233, 33, 2, 67, 11, 223, 188, 232, 152, 193, 20, 32, 243, 52, 64, 43, 2,
+ 243, 8, 77, 150, 232, 109, 148, 95, 127, 55, 71, 162, 34, 54, 83, 135, 52, 172,
+ 191, 32, 42, 106, 43, 211, 206, 100, 104, 110, 232, 5, 43, 120, 180, 166, 40,
+ 144, 233, 239, 103, 134, 103, 255, 224, 138, 184, 208, 137, 127, 36, 189, 143,
+ 248, 201, 2, 218, 51, 232, 96, 30, 83, 124, 109, 241, 23, 179, 247, 151, 238,
+ 212, 204, 44, 43, 223, 148, 241, 172, 10, 235, 155, 94, 68, 116, 24, 116, 191,
+ 86, 53, 127, 35, 133, 198, 204, 59, 76, 110, 16, 1, 15, 148, 135, 157,
]
.as_slice(),
),
65537u32.into(),
- BigUint::from_slice(
+ BigUint::from_bytes_le(
[
- 4219166081, 3411287400, 3981141108, 1678549103, 2990099628, 1028778896,
- 672985971, 2520258231, 1054615108, 2922409705, 1844757795, 1160015252,
- 1910592069, 468649647, 4013057473, 772236922, 1958956898, 2475335323,
- 3977796915, 1829655286, 1576008336, 2187384383, 2445706978, 1642531745,
- 1610593494, 4268513438, 3095769587, 1486118748, 4109728823, 2030327380,
- 2959206188, 681254334, 1353008441, 725092776, 2634942185, 1480646512,
- 390137741, 1392955456, 4172679229, 2746438782, 2237328976, 2974223876,
- 2535267247, 3282201811, 1453825287, 3948348329, 3639451225, 1053160223,
- 3867366405, 204601530, 2268984413, 4053930420, 2331079437, 2795201243,
- 621559743, 1420993793, 693127368, 2379843661, 4078948854, 4130031519,
- 1957410463, 3951952652, 1514579162, 1261104787,
+ 129, 93, 123, 251, 104, 29, 84, 203, 116, 100, 75, 237, 111, 160, 12, 100, 172,
+ 76, 57, 178, 144, 235, 81, 61, 115, 243, 28, 40, 183, 22, 56, 150, 68, 38, 220,
+ 62, 233, 110, 48, 174, 35, 197, 244, 109, 148, 109, 36, 69, 69, 82, 225, 113,
+ 175, 6, 239, 27, 193, 101, 50, 239, 122, 102, 7, 46, 98, 79, 195, 116, 155,
+ 158, 138, 147, 51, 93, 24, 237, 246, 82, 14, 109, 144, 250, 239, 93, 63, 214,
+ 96, 130, 226, 134, 198, 145, 161, 11, 231, 97, 214, 180, 255, 95, 158, 88, 108,
+ 254, 243, 177, 133, 184, 92, 95, 148, 88, 55, 124, 245, 244, 84, 86, 4, 121,
+ 44, 231, 97, 176, 190, 29, 155, 40, 57, 69, 165, 80, 168, 9, 56, 43, 233, 6,
+ 14, 157, 112, 223, 64, 88, 141, 7, 65, 23, 64, 208, 6, 83, 61, 8, 182, 248,
+ 126, 84, 179, 163, 80, 238, 90, 133, 4, 14, 71, 177, 175, 27, 29, 151, 211,
+ 108, 162, 195, 7, 157, 167, 86, 169, 3, 87, 235, 89, 158, 237, 216, 31, 243,
+ 197, 62, 5, 84, 131, 230, 186, 248, 49, 12, 93, 244, 61, 135, 180, 17, 162,
+ 241, 13, 115, 241, 138, 219, 98, 155, 166, 191, 63, 12, 37, 1, 165, 178, 84,
+ 200, 72, 80, 41, 77, 136, 217, 141, 246, 209, 31, 243, 159, 71, 43, 246, 159,
+ 182, 171, 116, 12, 3, 142, 235, 218, 164, 70, 90, 147, 238, 42, 75,
]
.as_slice(),
),
vec![
- BigUint::from_slice(
+ BigUint::from_bytes_le(
[
- 477022167, 1829769280, 2090244202, 1551476276, 1157631474, 2890438663,
- 3030138742, 490022796, 816963781, 1097260329, 1043839249, 132356315,
- 2333006670, 2559626311, 4109838094, 1022025893, 518867669, 2331160934,
- 796532648, 1910610894, 4103647079, 3748718875, 3000444664, 2030629908,
- 2051410714, 1470584080, 3823425600, 150616493, 3406571229, 728760788,
- 1642158920, 3248110052,
+ 215, 199, 110, 28, 64, 16, 16, 109, 106, 152, 150, 124, 52, 166, 121, 92,
+ 242, 13, 0, 69, 7, 152, 72, 172, 118, 63, 156, 180, 140, 39, 53, 29, 197,
+ 224, 177, 48, 41, 221, 102, 65, 17, 185, 55, 62, 219, 152, 227, 7, 78, 219,
+ 14, 139, 71, 204, 144, 152, 14, 39, 247, 244, 165, 224, 234, 60, 213, 74,
+ 237, 30, 102, 177, 242, 138, 168, 31, 122, 47, 206, 155, 225, 113, 103,
+ 175, 152, 244, 27, 233, 112, 223, 248, 38, 215, 178, 20, 244, 8, 121, 26,
+ 11, 70, 122, 16, 85, 167, 87, 64, 216, 228, 227, 173, 57, 250, 8, 221, 38,
+ 12, 203, 212, 1, 112, 43, 72, 91, 225, 97, 228, 57, 154, 193,
]
.as_slice(),
),
- BigUint::from_slice(
+ BigUint::from_bytes_le(
[
- 2563529193, 1846080031, 2674900518, 1429039465, 4196332559, 1876681390,
- 2277818219, 2814016273, 3312979285, 3981345183, 451288984, 3552968165,
- 2390674537, 2887399418, 103653441, 3997324899, 2875328107, 2697584733,
- 2018692127, 116301540, 2576747710, 1194942447, 2615930724, 3775252553,
- 808368511, 2384549107, 387191569, 980553943, 2487815891, 4238343336,
- 3546626429, 3494710460,
+ 233, 89, 204, 152, 31, 242, 8, 110, 38, 190, 111, 159, 105, 105, 45, 85,
+ 15, 244, 30, 250, 174, 226, 219, 111, 107, 191, 196, 135, 17, 123, 186,
+ 167, 85, 13, 120, 197, 159, 129, 78, 237, 152, 31, 230, 26, 229, 253, 197,
+ 211, 105, 204, 126, 142, 250, 55, 26, 172, 65, 160, 45, 6, 99, 86, 66, 238,
+ 107, 6, 98, 171, 93, 224, 201, 160, 31, 204, 82, 120, 228, 158, 238, 6,
+ 190, 12, 150, 153, 239, 95, 57, 71, 100, 239, 235, 155, 73, 200, 5, 225,
+ 127, 185, 46, 48, 243, 84, 33, 142, 17, 19, 20, 23, 215, 16, 114, 58, 211,
+ 14, 73, 148, 168, 252, 159, 252, 125, 57, 101, 211, 188, 12, 77, 208,
]
.as_slice(),
),