Skip to content

Commit

Permalink
address some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Goirad committed Feb 12, 2020
1 parent 28eade4 commit 177d3e8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 41 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ vendored = ["openssl/vendored"]

[dependencies]
lazy_static = "1.0"
rustc-serialize = "0.3"

[target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies]
security-framework = "0.3.1"
Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
//! * TLS/SSL client communication
//! * TLS/SSL server communication
//! * PKCS#12 encoded identities
//! * PKCS#8 encoded identities
//! * X.509/PKCS#8 encoded identities
//! * Secure-by-default for client and server
//! * Includes hostname verification for clients
//! * Supports asynchronous I/O for both the server and the client
Expand Down Expand Up @@ -97,13 +97,9 @@
#![doc(html_root_url = "https://docs.rs/native-tls/0.2")]
#![warn(missing_docs)]

#[macro_use]
extern crate lazy_static;

#[cfg(test)]
extern crate hex;

extern crate rustc_serialize;
mod pem;

use std::any::Any;
Expand Down
35 changes: 0 additions & 35 deletions src/pem.rs
Original file line number Diff line number Diff line change
@@ -1,39 +1,4 @@
#![allow(unused)]
use rustc_serialize::base64::{self, FromBase64, ToBase64};

/// Type of the various `PEM_*` constants supplied to `pem_to_der` / `der_to_pem`.
pub struct PemGuard {
begin: &'static str,
end: &'static str,
}

macro_rules! pem_guard {
($n:expr) => {
&PemGuard {
begin: concat!("-----BEGIN ", $n, "-----"),
end: concat!("-----END ", $n, "-----"),
}
}
}

// Ref. RFC7468, although these are not universally respected.
pub const PEM_CERTIFICATE: &'static PemGuard = pem_guard!("CERTIFICATE");
pub const PEM_CERTIFICATE_REQUEST: &'static PemGuard = pem_guard!("CERTIFICATE REQUEST");
pub const PEM_ENCRYPTED_PRIVATE_KEY: &'static PemGuard = pem_guard!("ENCRYPTED PRIVATE KEY");
pub const PEM_PRIVATE_KEY: &'static PemGuard = pem_guard!("PRIVATE KEY");
pub const PEM_PUBLIC_KEY: &'static PemGuard = pem_guard!("PUBLIC KEY");
pub const PEM_CMS: &'static PemGuard = pem_guard!("CMS");

const BASE64_PEM_WRAP: usize = 64;

lazy_static!{
static ref BASE64_PEM: base64::Config = base64::Config {
char_set: base64::CharacterSet::Standard,
newline: base64::Newline::LF,
pad: true,
line_length: Some(BASE64_PEM_WRAP),
};
}

/// Split data by PEM guard lines
pub struct PemBlock<'a> {
Expand Down

0 comments on commit 177d3e8

Please sign in to comment.