Skip to content

Commit 79f0628

Browse files
authored
cms: remove the direct dependency on std (#2395)
`cms` has a strong dependency on `liballoc`, this replaces the various `std::vec` with `alloc::vec` and drops the std feature. The `std` feature is kept only to forward the feature to `der`, `spki`, and `x509-cert` crates.
1 parent de3a2c0 commit 79f0628

5 files changed

Lines changed: 14 additions & 16 deletions

File tree

‎cms/src/builder/kari.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ where
395395

396396
#[cfg(test)]
397397
mod tests {
398+
extern crate std;
399+
398400
use std::eprintln;
399401

400402
use super::*;

‎cms/src/enveloped_data.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::content_info::CmsVersion;
55
use crate::revocation::RevocationInfoChoices;
66
use crate::signed_data::CertificateSet;
77

8+
use alloc::vec;
89
use core::cmp::Ordering;
910
use der::asn1::{BitString, GeneralizedTime, ObjectIdentifier, OctetString, SetOfVec};
1011
use der::{Any, Choice, Sequence, ValueOrd};
@@ -88,11 +89,10 @@ pub struct OriginatorInfo {
8889
pub struct RecipientInfos(pub SetOfVec<RecipientInfo>);
8990
impl_newtype!(RecipientInfos, SetOfVec<RecipientInfo>);
9091

91-
#[cfg(feature = "std")]
92-
impl TryFrom<std::vec::Vec<RecipientInfo>> for RecipientInfos {
92+
impl TryFrom<vec::Vec<RecipientInfo>> for RecipientInfos {
9393
type Error = der::Error;
9494

95-
fn try_from(vec: std::vec::Vec<RecipientInfo>) -> der::Result<RecipientInfos> {
95+
fn try_from(vec: vec::Vec<RecipientInfo>) -> der::Result<RecipientInfos> {
9696
Ok(RecipientInfos(SetOfVec::try_from(vec)?))
9797
}
9898
}
@@ -268,7 +268,7 @@ pub struct OriginatorPublicKey {
268268
/// ```
269269
///
270270
/// [RFC 5652 Section 6.2.2]: https://www.rfc-editor.org/rfc/rfc5652#section-6.2.2
271-
pub type RecipientEncryptedKeys = alloc::vec::Vec<RecipientEncryptedKey>;
271+
pub type RecipientEncryptedKeys = vec::Vec<RecipientEncryptedKey>;
272272

273273
/// The `RecipientEncryptedKey` type is defined in [RFC 5652 Section 6.2.2].
274274
///

‎cms/src/lib.rs‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
2525
extern crate alloc;
2626

27-
#[cfg(feature = "std")]
28-
extern crate std;
29-
3027
pub mod attr;
3128
pub mod authenticated_data;
3229
pub mod authenveloped_data;

‎cms/src/revocation.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Revocation-related types
2+
use alloc::vec;
23
use core::cmp::Ordering;
34

45
use der::asn1::SetOfVec;
@@ -47,11 +48,10 @@ impl ValueOrd for RevocationInfoChoice {
4748
}
4849
}
4950

50-
#[cfg(feature = "std")]
51-
impl TryFrom<std::vec::Vec<RevocationInfoChoice>> for RevocationInfoChoices {
51+
impl TryFrom<vec::Vec<RevocationInfoChoice>> for RevocationInfoChoices {
5252
type Error = der::Error;
5353

54-
fn try_from(vec: std::vec::Vec<RevocationInfoChoice>) -> der::Result<RevocationInfoChoices> {
54+
fn try_from(vec: vec::Vec<RevocationInfoChoice>) -> der::Result<RevocationInfoChoices> {
5555
Ok(RevocationInfoChoices(SetOfVec::try_from(vec)?))
5656
}
5757
}

‎cms/src/signed_data.rs‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use crate::cert::{CertificateChoices, IssuerAndSerialNumber};
44
use crate::content_info::CmsVersion;
55
use crate::revocation::RevocationInfoChoices;
66

7+
use alloc::vec;
78
use core::cmp::Ordering;
89
use der::asn1::{ObjectIdentifier, OctetString, SetOfVec};
910
use der::{Any, Choice, DerOrd, Sequence, ValueOrd};
@@ -59,11 +60,10 @@ pub type DigestAlgorithmIdentifiers = SetOfVec<AlgorithmIdentifierOwned>;
5960
pub struct CertificateSet(pub SetOfVec<CertificateChoices>);
6061
impl_newtype!(CertificateSet, SetOfVec<CertificateChoices>);
6162

62-
#[cfg(feature = "std")]
63-
impl TryFrom<std::vec::Vec<CertificateChoices>> for CertificateSet {
63+
impl TryFrom<vec::Vec<CertificateChoices>> for CertificateSet {
6464
type Error = der::Error;
6565

66-
fn try_from(vec: std::vec::Vec<CertificateChoices>) -> der::Result<CertificateSet> {
66+
fn try_from(vec: vec::Vec<CertificateChoices>) -> der::Result<CertificateSet> {
6767
Ok(CertificateSet(SetOfVec::try_from(vec)?))
6868
}
6969
}
@@ -79,11 +79,10 @@ impl TryFrom<std::vec::Vec<CertificateChoices>> for CertificateSet {
7979
pub struct SignerInfos(pub SetOfVec<SignerInfo>);
8080
impl_newtype!(SignerInfos, SetOfVec<SignerInfo>);
8181

82-
#[cfg(feature = "std")]
83-
impl TryFrom<std::vec::Vec<SignerInfo>> for SignerInfos {
82+
impl TryFrom<vec::Vec<SignerInfo>> for SignerInfos {
8483
type Error = der::Error;
8584

86-
fn try_from(vec: std::vec::Vec<SignerInfo>) -> der::Result<SignerInfos> {
85+
fn try_from(vec: vec::Vec<SignerInfo>) -> der::Result<SignerInfos> {
8786
Ok(SignerInfos(SetOfVec::try_from(vec)?))
8887
}
8988
}

0 commit comments

Comments
 (0)