From 177d3e8b869431477b101e268c3ebdf6d77a9852 Mon Sep 17 00:00:00 2001 From: Dario Gonzalez Date: Wed, 12 Feb 2020 13:48:39 -0800 Subject: [PATCH] address some review comments --- Cargo.toml | 1 - src/lib.rs | 6 +----- src/pem.rs | 35 ----------------------------------- 3 files changed, 1 insertion(+), 41 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1879f259..dc705d4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/src/lib.rs b/src/lib.rs index ac460213..ef3130de 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 @@ -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; diff --git a/src/pem.rs b/src/pem.rs index 0d30ef7e..fe41e7ca 100644 --- a/src/pem.rs +++ b/src/pem.rs @@ -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> {