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

Move PKCS#8 type to proper module #12311

Merged
merged 1 commit into from
Jan 19, 2025
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
1 change: 1 addition & 0 deletions src/rust/cryptography-x509/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ pub mod ocsp_resp;
pub mod oid;
pub mod pkcs12;
pub mod pkcs7;
pub mod pkcs8;
12 changes: 3 additions & 9 deletions src/rust/cryptography-x509/src/pkcs12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
// for complete details.

use crate::common::{AlgorithmIdentifier, Utf8StoredBMPString};
use crate::pkcs7;
use crate::common::Utf8StoredBMPString;
use crate::{pkcs7, pkcs8};

pub const CERT_BAG_OID: asn1::ObjectIdentifier = asn1::oid!(1, 2, 840, 113549, 1, 12, 10, 1, 3);
pub const KEY_BAG_OID: asn1::ObjectIdentifier = asn1::oid!(1, 2, 840, 113549, 1, 12, 10, 1, 1);
Expand Down Expand Up @@ -61,7 +61,7 @@ pub enum BagValue<'a> {
KeyBag(asn1::Tlv<'a>),

#[defined_by(SHROUDED_KEY_BAG_OID)]
ShroudedKeyBag(EncryptedPrivateKeyInfo<'a>),
ShroudedKeyBag(pkcs8::EncryptedPrivateKeyInfo<'a>),
}

#[derive(asn1::Asn1Write)]
Expand All @@ -76,9 +76,3 @@ pub enum CertType<'a> {
#[defined_by(X509_CERTIFICATE_OID)]
X509(asn1::OctetStringEncoded<crate::certificate::Certificate<'a>>),
}

#[derive(asn1::Asn1Write)]
pub struct EncryptedPrivateKeyInfo<'a> {
pub encryption_algorithm: AlgorithmIdentifier<'a>,
pub encrypted_data: &'a [u8],
}
12 changes: 12 additions & 0 deletions src/rust/cryptography-x509/src/pkcs8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// This file is dual licensed under the terms of the Apache License, Version
// 2.0, and the BSD License. See the LICENSE file in the root of this repository
// for complete details.

use crate::common::AlgorithmIdentifier;

// RFC 5208, Section 6
#[derive(asn1::Asn1Write)]
pub struct EncryptedPrivateKeyInfo<'a> {
pub encryption_algorithm: AlgorithmIdentifier<'a>,
pub encrypted_data: &'a [u8],
}
2 changes: 1 addition & 1 deletion src/rust/src/pkcs12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ fn serialize_key_and_certificates<'p>(
_bag_id: asn1::DefinedByMarker::marker(),
bag_value: asn1::Explicit::new(
cryptography_x509::pkcs12::BagValue::ShroudedKeyBag(
cryptography_x509::pkcs12::EncryptedPrivateKeyInfo {
cryptography_x509::pkcs8::EncryptedPrivateKeyInfo {
encryption_algorithm: e.algorithm_identifier(
cipher_kdf_iter,
&key_salt,
Expand Down
Loading