Skip to content
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
3 changes: 1 addition & 2 deletions ffi/src/putty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ impl From<ffi::PuttyArgon2Flavour> for picky::putty::Argon2Flavour {
pub mod ffi {
use crate::error::ffi::PickyError;
use crate::key::ffi::{EcCurve, PrivateKey, PublicKey};
use crate::ssh::ffi::SshPrivateKey;
use crate::ssh::ffi::SshPublicKey;
use crate::ssh::ffi::{SshPrivateKey, SshPublicKey};
use crate::utils::ffi::VecU8;
use diplomat_runtime::DiplomatWriteable;
use std::fmt::Write;
Expand Down
11 changes: 4 additions & 7 deletions ffi/src/x509/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ pub mod ffi {
use crate::x509::extension::ffi::{Extension, ExtensionIterator};
use crate::x509::singer_info::ffi::{CmsVersion, SignerInfo, SignerInfoIterator};
use crate::x509::string::ffi::DirectoryString;
use crate::x509::time::ffi::Time;
use crate::x509::time::ffi::{UTCTime, UTCTimeIterator};
use crate::x509::time::ffi::{Time, UTCTime, UTCTimeIterator};
use diplomat_runtime::DiplomatWriteable;
use std::fmt::Write;

Expand Down Expand Up @@ -71,12 +70,10 @@ pub mod ffi {
pub fn to_extensions(&self) -> Option<Box<ExtensionIterator>> {
match &self.0 {
picky_asn1_x509::AttributeValues::Extensions(extensions) => {
// the set will always have 1 element in this variant
let Some(extetions) = extensions.0.first() else {
return None;
};
// The set will always have 1 element in this variant.
let extension = extensions.0.first()?;

let vec: Vec<Extension> = extetions.0.clone().into_iter().map(Extension).collect();
let vec: Vec<Extension> = extension.0.clone().into_iter().map(Extension).collect();

Some(Box::new(ExtensionIterator(vec)))
}
Expand Down
24 changes: 11 additions & 13 deletions ffi/src/x509/authenticode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@
pub mod ffi {
use picky::x509::pkcs7::timestamp::Timestamper;

use crate::{
date::ffi::UtcDate,
error::ffi::PickyError,
hash::ffi::HashAlgorithm,
key::ffi::PrivateKey,
pem::ffi::Pem,
pkcs7::ffi::Pkcs7,
utils::ffi::{RsString, VecU8},
x509::{
attribute::ffi::{Attribute, AttributeIterator, SignedData, UnsignedAttribute, UnsignedAttributeIterator},
ffi::{Cert, CertIterator},
name::ffi::DirectoryNameIterator,
},
use crate::date::ffi::UtcDate;
use crate::error::ffi::PickyError;
use crate::hash::ffi::HashAlgorithm;
use crate::key::ffi::PrivateKey;
use crate::pem::ffi::Pem;
use crate::pkcs7::ffi::Pkcs7;
use crate::utils::ffi::{RsString, VecU8};
use crate::x509::attribute::ffi::{
Attribute, AttributeIterator, SignedData, UnsignedAttribute, UnsignedAttributeIterator,
};
use crate::x509::ffi::{Cert, CertIterator};
use crate::x509::name::ffi::DirectoryNameIterator;

#[diplomat::opaque]
pub struct AuthenticodeSignature(pub picky::x509::pkcs7::authenticode::AuthenticodeSignature);
Expand Down
5 changes: 4 additions & 1 deletion picky-asn1-der/src/de/integer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ pub trait UInt: Sized + Copy {
/// Converts `num` into `Self`
fn from_u128(num: u128) -> Result<Self>;
}

macro_rules! impl_uint {
($type:ident) => {
impl UInt for $type {
fn from_u128(num: u128) -> Result<Self> {
const MAX: u128 = $type::max_value() as u128;
const MAX: u128 = $type::MAX as u128;
match num {
_ if num > MAX => Err(Asn1DerError::UnsupportedValue),
_ => Ok(num as Self)
Expand All @@ -19,10 +20,12 @@ macro_rules! impl_uint {
};
($($type:ident),+) => ($( impl_uint!($type); )+)
}

impl_uint!(usize, u128, u64, u32, u16, u8);

/// A deserializer for unsigned integers
pub struct UnsignedInteger;

impl UnsignedInteger {
/// The deserialized integer for `data`
pub fn deserialize<T: UInt>(data: &[u8]) -> Result<T> {
Expand Down
2 changes: 1 addition & 1 deletion picky-asn1-der/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<'de> Deserializer<'de> {
}
}

impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut Deserializer<'de> {
impl<'de> serde::de::Deserializer<'de> for &mut Deserializer<'de> {
type Error = Asn1DerError;

fn is_human_readable(&self) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion picky-asn1-der/src/de/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<'a, 'de> Sequence<'a, 'de> {
}
}

impl<'a, 'de> SeqAccess<'de> for Sequence<'a, 'de> {
impl<'de> SeqAccess<'de> for Sequence<'_, 'de> {
type Error = Asn1DerError;

fn next_element_seed<T: DeserializeSeed<'de>>(&mut self, seed: T) -> Result<Option<T::Value>> {
Expand Down
6 changes: 3 additions & 3 deletions picky-asn1-der/src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl<'a, 'se> serde::ser::Serializer for &'a mut Serializer<'se> {
}
}

impl<'a, 'se> serde::ser::SerializeTupleVariant for &'a mut Serializer<'se> {
impl serde::ser::SerializeTupleVariant for &mut Serializer<'_> {
type Ok = usize;
type Error = Asn1DerError;

Expand All @@ -403,7 +403,7 @@ impl<'a, 'se> serde::ser::SerializeTupleVariant for &'a mut Serializer<'se> {
}
}

impl<'a, 'se> serde::ser::SerializeMap for &'a mut Serializer<'se> {
impl serde::ser::SerializeMap for &mut Serializer<'_> {
type Ok = usize;
type Error = Asn1DerError;

Expand All @@ -420,7 +420,7 @@ impl<'a, 'se> serde::ser::SerializeMap for &'a mut Serializer<'se> {
}
}

impl<'a, 'se> serde::ser::SerializeStructVariant for &'a mut Serializer<'se> {
impl serde::ser::SerializeStructVariant for &mut Serializer<'_> {
type Ok = usize;
type Error = Asn1DerError;

Expand Down
8 changes: 4 additions & 4 deletions picky-asn1-der/src/ser/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'a, 'se> Sequence<'a, 'se> {
}
}

impl<'a, 'se> serde::ser::SerializeSeq for Sequence<'a, 'se> {
impl serde::ser::SerializeSeq for Sequence<'_, '_> {
type Ok = usize;
type Error = Asn1DerError;

Expand All @@ -52,7 +52,7 @@ impl<'a, 'se> serde::ser::SerializeSeq for Sequence<'a, 'se> {
}
}

impl<'a, 'se> serde::ser::SerializeTuple for Sequence<'a, 'se> {
impl serde::ser::SerializeTuple for Sequence<'_, '_> {
type Ok = usize;
type Error = Asn1DerError;

Expand All @@ -64,7 +64,7 @@ impl<'a, 'se> serde::ser::SerializeTuple for Sequence<'a, 'se> {
}
}

impl<'a, 'se> serde::ser::SerializeStruct for Sequence<'a, 'se> {
impl serde::ser::SerializeStruct for Sequence<'_, '_> {
type Ok = usize;
type Error = Asn1DerError;

Expand All @@ -76,7 +76,7 @@ impl<'a, 'se> serde::ser::SerializeStruct for Sequence<'a, 'se> {
}
}

impl<'a, 'se> serde::ser::SerializeTupleStruct for Sequence<'a, 'se> {
impl serde::ser::SerializeTupleStruct for Sequence<'_, '_> {
type Ok = usize;
type Error = Asn1DerError;

Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-der/tests/pki_tests/ocsp_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
// https://access.redhat.com/documentation/en-us/red_hat_certificate_system/9/html/administration_guide/online_certificate_status_protocol_responder
// https://lapo.it/asn1js/#MEIwQDA-MDwwOjAJBgUrDgMCGgUABBT4cyABkyiCIhU4JpmIBewdDnn8ZgQUbyBZ44kgy35o7xW5BMzM8FTvyTwCAQE

use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use oid::prelude::*;
use picky_asn1::wrapper::{ObjectIdentifierAsn1, OctetStringAsn1};
use serde::{Deserialize, Serialize};
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-der/tests/pki_tests/rsa_public_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// https://lapo.it/asn1js/#MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsiLoIxmXaZAFRBKtHYZhiF8m-pYR-xGIpupvsdDEvKO92D6fIccgVLIW6p6sSNkoXx5J6KDSMbA_chy5M6pRvJkaCXCI4zlCPMYvPhI8OxN3RYPfdQTLpgPywrlfdn2CAum7o4D8nR4NJacB3NfPnS9tsJ2L3p5iHviuTB4xm03IKmPPqsaJy-nXUFC1XS9E_PseVHRuNvKa7WmlwSZngQzKAVSIwqpgCc-oP1pKEeJ0M3LHFo8ao5SuzhfXUIGrPnkUKEE3m7B0b8xXZfP1N6ELoonWDK-RMgYIBaZdgBhPfHxF8KfTHvSzcUzWZojuR-ynaFL9AJK-8RiXnB4CJwIDAQAB

use super::ocsp_request::AlgorithmIdentifier;
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use num_bigint_dig::BigInt;
use oid::prelude::*;
use picky_asn1::wrapper::*;
Expand Down
2 changes: 1 addition & 1 deletion picky-asn1-der/tests/pki_tests/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl<'de> Deserialize<'de> for Version {
{
struct Visitor;

impl<'de> de::Visitor<'de> for Visitor {
impl de::Visitor<'_> for Visitor {
type Value = Version;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-der/tests/pki_tests/x509_v3_certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
use crate::pki_tests::ocsp_request::AlgorithmIdentifier;
use crate::pki_tests::rsa_public_key::{RSAPublicKey, SubjectPublicKeyInfoRsa};
use crate::pki_tests::version::{implicit_app0_version_is_default, Version};
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use num_bigint_dig::BigInt;
use oid::prelude::*;
use picky_asn1::bit_string::BitString;
Expand Down
2 changes: 1 addition & 1 deletion picky-asn1-der/tests/read_test_vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl ParseStr for Vec<u8> {
line
);
to_parse.as_bytes().chunks(2).fold(Self::new(), |mut vec, pair| {
vec.push(decode(pair[0]) << 4 | decode(pair[1]));
vec.push((decode(pair[0]) << 4) | decode(pair[1]));
vec
})
}
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ fn extensions_are_empty(extensions: &Extensions) -> bool {
mod tests {
use super::*;
use crate::{DirectoryName, Extension, KeyIdentifier, KeyUsage};
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use num_bigint_dig::BigInt;
use picky_asn1::bit_string::BitString;
use picky_asn1::date::UTCTime;
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/certification_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ mod tests {
use super::*;
use crate::name::*;
use crate::{DirectoryName, Extension, GeneralName};
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use picky_asn1::bit_string::BitString;
use picky_asn1::restricted_string::{Ia5String, PrintableString, Utf8String};
use picky_asn1::wrapper::IntegerAsn1;
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ impl ExtendedKeyUsage {
mod tests {
use super::*;
use crate::GeneralName;
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use picky_asn1::restricted_string::Ia5String;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ pub struct EdiPartyName {
#[cfg(test)]
mod tests {
use super::*;
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use oid::ObjectIdentifier;
use picky_asn1::restricted_string::Ia5String;
use picky_asn1_der::Asn1RawDer;
Expand Down
9 changes: 4 additions & 5 deletions picky-asn1-x509/src/pkcs12/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use crate::oids;
use core::fmt;
use oid::ObjectIdentifier;
use picky_asn1::{
restricted_string::BmpString,
wrapper::{Asn1SetOf, BmpStringAsn1, ObjectIdentifierAsn1, OctetStringAsn1},
};
use picky_asn1::restricted_string::BmpString;
use picky_asn1::wrapper::{Asn1SetOf, BmpStringAsn1, ObjectIdentifierAsn1, OctetStringAsn1};
use picky_asn1_der::Asn1RawDer;
use serde::{de, ser};

Expand Down Expand Up @@ -197,7 +195,8 @@ mod tests {
use super::test_data::*;
use super::*;

use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;

// "Close enough" UTF8 -> UCS2 conversion for testing purposes (works only with ASCII)
fn utf8_to_ucs2(s: &str) -> Vec<u8> {
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/pkcs12/authenticated_safe.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{oids, pkcs12::SafeContentsContentInfo};
use crate::oids;
use crate::pkcs12::SafeContentsContentInfo;
use core::fmt;
use oid::ObjectIdentifier;
use picky_asn1::wrapper::{ExplicitContextTag0, ObjectIdentifierAsn1, OctetStringAsn1, OctetStringAsn1Container};
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/pkcs12/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ mod tests {
use super::test_data::*;
use super::*;

use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use expect_test::expect;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/pkcs12/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ mod tests {
use super::test_data::*;
use super::*;
use crate::pkcs12::test_data::build_arbitrary_algorithm_identifier;
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use expect_test::expect;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/pkcs12/encryption/pbes2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ mod tests {
use super::test_data::*;
use super::*;
use crate::pkcs12::test_data::build_arbitrary_algorithm_identifier;
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use expect_test::expect;

#[test]
Expand Down
6 changes: 2 additions & 4 deletions picky-asn1-x509/src/pkcs12/encryption/pbes2/pbkdf2.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use crate::{oids, RawAlgorithmIdentifier};
use core::fmt;
use picky_asn1::tag::TagPeeker;
use picky_asn1::wrapper::{IntegerAsn1, OctetStringAsn1};
use picky_asn1::Asn1Type;
use picky_asn1::{
tag::TagPeeker,
wrapper::{IntegerAsn1, OctetStringAsn1},
};
use serde::{de, ser};

/// [PKCS #12: Personal Information Exchange Syntax Standard Version](https://tools.ietf.org/html/rfc7292#appendix-C)
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/pkcs12/mac_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ mod tests {
use super::test_data::*;
use super::*;

use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use expect_test::expect;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/pkcs12/safe_bag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ impl<'de> de::Deserialize<'de> for SafeBag {
#[cfg(test)]
mod tests {
use super::*;
use crate::pkcs12::{pbes2::test_data::build_expected_pbes2_params, Pkcs12EncryptionAlgorithm};
use crate::pkcs12::pbes2::test_data::build_expected_pbes2_params;
use crate::pkcs12::Pkcs12EncryptionAlgorithm;
use expect_test::expect;
use picky_asn1::wrapper::OctetStringAsn1;

Expand Down
2 changes: 1 addition & 1 deletion picky-asn1-x509/src/pkcs7/cmsversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'de> Deserialize<'de> for CmsVersion {
{
struct Visitor;

impl<'de> de::Visitor<'de> for Visitor {
impl de::Visitor<'_> for Visitor {
type Value = CmsVersion;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
3 changes: 2 additions & 1 deletion picky-asn1-x509/src/pkcs7/ctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ pub struct PolicyQualifier {
mod tests {
use super::*;
use crate::{AlgorithmIdentifier, ShaVariant};
use base64::{engine::general_purpose, Engine as _};
use base64::engine::general_purpose;
use base64::Engine as _;
use picky_asn1::date::UTCTime;

#[test]
Expand Down
10 changes: 4 additions & 6 deletions picky-asn1-x509/src/pkcs7/enveloped_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,10 @@ impl<'de> Deserialize<'de> for RecipientInfo {
})?,
}))
}
_ => {
return Err(de::Error::invalid_value(
de::Unexpected::Other("[RecipientInfo] unknown choice value"),
&"a supported RecipientInfo choice",
))
}
_ => Err(de::Error::invalid_value(
de::Unexpected::Other("[RecipientInfo] unknown choice value"),
&"a supported RecipientInfo choice",
)),
}
}
}
Expand Down
Loading