Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust 1.78 fixups #1399

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions base16ct/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ impl fmt::Display for Error {
#[cfg(feature = "std")]
impl std::error::Error for Error {}

impl From<Error> for core::fmt::Error {
fn from(_: Error) -> core::fmt::Error {
core::fmt::Error
impl From<Error> for fmt::Error {
fn from(_: Error) -> fmt::Error {
fmt::Error
}
}
2 changes: 1 addition & 1 deletion base16ct/src/upper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn encode_string(input: &[u8]) -> String {
let res = encode(input, &mut dst).expect("dst length is correct");

debug_assert_eq!(elen, res.len());
unsafe { crate::String::from_utf8_unchecked(dst) }
unsafe { String::from_utf8_unchecked(dst) }
}

/// Decode a single nibble of upper hex
Expand Down
4 changes: 2 additions & 2 deletions cms/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl<'s> Builder for SignerInfoBuilder<'s> {
Some(content) => {
let mut hasher = get_hasher(&self.digest_algorithm).ok_or_else(|| {
// Unsupported hash algorithm: {}, &self.digest_algorithm.oid.to_string()
x509_cert::builder::Error::from(der::Error::from(ErrorKind::Failed))
builder::Error::from(der::Error::from(ErrorKind::Failed))
})?;
// Only the octets comprising the value of the eContent
// OCTET STRING are input to the message digest algorithm, not the tag
Expand Down Expand Up @@ -284,7 +284,7 @@ impl<'s> Builder for SignerInfoBuilder<'s> {
});

let signature_value =
SignatureValue::new(signature.raw_bytes()).map_err(x509_cert::builder::Error::from)?;
SignatureValue::new(signature.raw_bytes()).map_err(builder::Error::from)?;

let signature_algorithm = signer.signature_algorithm_identifier()?;

Expand Down
12 changes: 6 additions & 6 deletions pkcs1/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,18 @@ impl From<pkcs8::Error> for Error {
}

#[cfg(feature = "pkcs8")]
impl From<Error> for pkcs8::spki::Error {
fn from(err: Error) -> pkcs8::spki::Error {
impl From<Error> for spki::Error {
fn from(err: Error) -> spki::Error {
match err {
Error::Asn1(e) => pkcs8::spki::Error::Asn1(e),
_ => pkcs8::spki::Error::KeyMalformed,
Error::Asn1(e) => spki::Error::Asn1(e),
_ => spki::Error::KeyMalformed,
}
}
}

#[cfg(feature = "pkcs8")]
impl From<pkcs8::spki::Error> for Error {
fn from(err: pkcs8::spki::Error) -> Error {
impl From<spki::Error> for Error {
fn from(err: spki::Error) -> Error {
Error::Pkcs8(pkcs8::Error::PublicKey(err))
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkcs1/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ where
#[cfg(feature = "pkcs8")]
impl<T> DecodeRsaPublicKey for T
where
T: for<'a> TryFrom<pkcs8::SubjectPublicKeyInfoRef<'a>, Error = pkcs8::spki::Error>,
T: for<'a> TryFrom<pkcs8::SubjectPublicKeyInfoRef<'a>, Error = spki::Error>,
{
fn from_pkcs1_der(public_key: &[u8]) -> Result<Self> {
Ok(Self::try_from(pkcs8::SubjectPublicKeyInfoRef {
Expand Down
6 changes: 3 additions & 3 deletions pkcs5/src/pbes1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ impl<'a> TryFrom<AlgorithmIdentifierRef<'a>> for Algorithm {

fn try_from(alg: AlgorithmIdentifierRef<'a>) -> der::Result<Self> {
// Ensure that we have a supported PBES1 algorithm identifier
let encryption = EncryptionScheme::try_from(alg.oid)
.map_err(|_| der::Tag::ObjectIdentifier.value_error())?;
let encryption =
EncryptionScheme::try_from(alg.oid).map_err(|_| Tag::ObjectIdentifier.value_error())?;

let parameters = alg
.parameters
Expand Down Expand Up @@ -157,7 +157,7 @@ impl TryFrom<AnyRef<'_>> for Parameters {
salt: OctetStringRef::decode(reader)?
.as_bytes()
.try_into()
.map_err(|_| der::Tag::OctetString.value_error())?,
.map_err(|_| Tag::OctetString.value_error())?,
iteration_count: reader.decode()?,
})
})
Expand Down
16 changes: 5 additions & 11 deletions pkcs5/src/pbes2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,31 +391,25 @@ impl TryFrom<AlgorithmIdentifierRef<'_>> for EncryptionScheme {

match alg.oid {
AES_128_CBC_OID => Ok(Self::Aes128Cbc {
iv: iv
.try_into()
.map_err(|_| der::Tag::OctetString.value_error())?,
iv: iv.try_into().map_err(|_| Tag::OctetString.value_error())?,
}),
AES_192_CBC_OID => Ok(Self::Aes192Cbc {
iv: iv
.try_into()
.map_err(|_| der::Tag::OctetString.value_error())?,
iv: iv.try_into().map_err(|_| Tag::OctetString.value_error())?,
}),
AES_256_CBC_OID => Ok(Self::Aes256Cbc {
iv: iv
.try_into()
.map_err(|_| der::Tag::OctetString.value_error())?,
iv: iv.try_into().map_err(|_| Tag::OctetString.value_error())?,
}),
#[cfg(feature = "des-insecure")]
DES_CBC_OID => Ok(Self::DesCbc {
iv: iv[0..DES_BLOCK_SIZE]
.try_into()
.map_err(|_| der::Tag::OctetString.value_error())?,
.map_err(|_| Tag::OctetString.value_error())?,
}),
#[cfg(feature = "3des")]
DES_EDE3_CBC_OID => Ok(Self::DesEde3Cbc {
iv: iv[0..DES_BLOCK_SIZE]
.try_into()
.map_err(|_| der::Tag::OctetString.value_error())?,
.map_err(|_| Tag::OctetString.value_error())?,
}),
oid => Err(ErrorKind::OidUnknown { oid }.into()),
}
Expand Down
2 changes: 1 addition & 1 deletion sec1/src/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl<'a> DecodeValue<'a> for EcPrivateKey<'a> {
fn decode_value<R: Reader<'a>>(reader: &mut R, header: Header) -> der::Result<Self> {
reader.read_nested(header.length, |reader| {
if u8::decode(reader)? != VERSION {
return Err(der::Tag::Integer.value_error());
return Err(Tag::Integer.value_error());
}

let private_key = OctetStringRef::decode(reader)?.as_bytes();
Expand Down
Loading