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

pem-rfc7468: rename PemLabel::TYPE_LABEL => ::PEM_LABEL #568

Merged
merged 1 commit into from
Mar 30, 2022
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
4 changes: 2 additions & 2 deletions der/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub trait Document<'a>: AsRef<[u8]> + Sized + TryFrom<Vec<u8>, Error = Error> {
{
let (label, der_bytes) = pem::decode_vec(s.as_bytes())?;

if label != Self::TYPE_LABEL {
if label != Self::PEM_LABEL {
return Err(pem::Error::Label.into());
}

Expand All @@ -76,7 +76,7 @@ pub trait Document<'a>: AsRef<[u8]> + Sized + TryFrom<Vec<u8>, Error = Error> {
Self: pem::PemLabel,
{
Ok(pem::encode_string(
Self::TYPE_LABEL,
Self::PEM_LABEL,
line_ending,
self.as_ref(),
)?)
Expand Down
6 changes: 3 additions & 3 deletions pem-rfc7468/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ pub type Base64Encoder<'o> = base64ct::Encoder<'o, base64ct::Base64>;
/// Marker trait for types with an associated PEM type label.
pub trait PemLabel {
/// Expected PEM type label for a given document, e.g. `"PRIVATE KEY"`
const TYPE_LABEL: &'static str;
const PEM_LABEL: &'static str;

/// Validate that a given label matches the expected label.
fn validate_pem_label(actual: &str) -> Result<()> {
if Self::TYPE_LABEL == actual {
if Self::PEM_LABEL == actual {
Ok(())
} else {
Err(Error::UnexpectedTypeLabel {
expected: Self::TYPE_LABEL,
expected: Self::PEM_LABEL,
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkcs1/src/private_key/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ impl FromStr for RsaPrivateKeyDocument {
#[cfg(feature = "pem")]
#[cfg_attr(docsrs, doc(cfg(feature = "pem")))]
impl pem::PemLabel for RsaPrivateKeyDocument {
const TYPE_LABEL: &'static str = "RSA PRIVATE KEY";
const PEM_LABEL: &'static str = "RSA PRIVATE KEY";
}
2 changes: 1 addition & 1 deletion pkcs1/src/public_key/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,5 @@ impl FromStr for RsaPublicKeyDocument {
#[cfg(feature = "pem")]
#[cfg_attr(docsrs, doc(cfg(feature = "pem")))]
impl pem::PemLabel for RsaPublicKeyDocument {
const TYPE_LABEL: &'static str = "RSA PUBLIC KEY";
const PEM_LABEL: &'static str = "RSA PUBLIC KEY";
}
2 changes: 1 addition & 1 deletion pkcs8/src/document/encrypted_private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ impl FromStr for EncryptedPrivateKeyDocument {
#[cfg(feature = "pem")]
#[cfg_attr(docsrs, doc(cfg(feature = "pem")))]
impl pem::PemLabel for EncryptedPrivateKeyDocument {
const TYPE_LABEL: &'static str = "ENCRYPTED PRIVATE KEY";
const PEM_LABEL: &'static str = "ENCRYPTED PRIVATE KEY";
}
2 changes: 1 addition & 1 deletion pkcs8/src/document/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,5 +198,5 @@ impl FromStr for PrivateKeyDocument {
#[cfg(feature = "pem")]
#[cfg_attr(docsrs, doc(cfg(feature = "pem")))]
impl pem::PemLabel for PrivateKeyDocument {
const TYPE_LABEL: &'static str = "PRIVATE KEY";
const PEM_LABEL: &'static str = "PRIVATE KEY";
}
2 changes: 1 addition & 1 deletion sec1/src/private_key/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ impl FromStr for EcPrivateKeyDocument {
#[cfg(feature = "pem")]
#[cfg_attr(docsrs, doc(cfg(feature = "pem")))]
impl pem::PemLabel for EcPrivateKeyDocument {
const TYPE_LABEL: &'static str = "EC PRIVATE KEY";
const PEM_LABEL: &'static str = "EC PRIVATE KEY";
}
2 changes: 1 addition & 1 deletion spki/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,5 @@ impl FromStr for PublicKeyDocument {
#[cfg(feature = "pem")]
#[cfg_attr(docsrs, doc(cfg(feature = "pem")))]
impl pem::PemLabel for PublicKeyDocument {
const TYPE_LABEL: &'static str = "PUBLIC KEY";
const PEM_LABEL: &'static str = "PUBLIC KEY";
}
6 changes: 3 additions & 3 deletions ssh-key/src/private.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl PrivateKey {
out: &'o mut [u8],
) -> Result<&'o str> {
let mut pem_encoder =
pem::Encoder::new_wrapped(Self::TYPE_LABEL, PEM_LINE_WIDTH, line_ending, out)?;
pem::Encoder::new_wrapped(Self::PEM_LABEL, PEM_LINE_WIDTH, line_ending, out)?;

pem_encoder.encode(Self::AUTH_MAGIC)?;
self.cipher.encode(&mut pem_encoder)?;
Expand Down Expand Up @@ -527,7 +527,7 @@ impl PrivateKey {
.ok_or(Error::Length)?;

Ok(pem::encapsulated_len(
Self::TYPE_LABEL,
Self::PEM_LABEL,
line_ending,
[base64_len, newline_len].checked_sum()?,
)?)
Expand Down Expand Up @@ -562,7 +562,7 @@ impl From<&PrivateKey> for PublicKey {
}

impl PemLabel for PrivateKey {
const TYPE_LABEL: &'static str = "OPENSSH PRIVATE KEY";
const PEM_LABEL: &'static str = "OPENSSH PRIVATE KEY";
}

impl str::FromStr for PrivateKey {
Expand Down
2 changes: 1 addition & 1 deletion x509/src/certificate/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ impl FromStr for CertificateDocument {
#[cfg(feature = "pem")]
#[cfg_attr(docsrs, doc(cfg(feature = "pem")))]
impl pem::PemLabel for CertificateDocument {
const TYPE_LABEL: &'static str = "CERTIFICATE";
const PEM_LABEL: &'static str = "CERTIFICATE";
}