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

Update base64 crate to 0.20 #11

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/rustls/pemfile"
categories = ["network-programming", "cryptography"]

[dependencies]
base64 = "0.13.0"
base64 = "0.20.0"

[dev-dependencies]
criterion = "0.3"
Expand Down
15 changes: 13 additions & 2 deletions src/pemfile.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
use std::io::{self, ErrorKind};

use base64;
use base64::{
alphabet,
engine::{
fast_portable::{FastPortable, FastPortableConfig},
DecodePaddingMode,
},
};

const DEFAULT_ENGINE_INDIFFERENT_PADDING: FastPortable = FastPortable::from(
&alphabet::STANDARD,
FastPortableConfig::new().with_decode_padding_mode(DecodePaddingMode::Indifferent),
);

/// The contents of a single recognised block in a PEM file.
#[non_exhaustive]
Expand Down Expand Up @@ -96,7 +107,7 @@ pub fn read_one(rd: &mut dyn io::BufRead) -> Result<Option<Item>, io::Error> {

if let Some((section_type, end_marker)) = section.as_ref() {
if line.starts_with(end_marker) {
let der = base64::decode(&b64buf)
let der = base64::decode_engine(&b64buf, &DEFAULT_ENGINE_INDIFFERENT_PADDING)
.map_err(|err| io::Error::new(ErrorKind::InvalidData, err))?;

if let Some(item) = Item::from_start_line(&section_type, der) {
Expand Down