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

Use data_encoding #3

Merged
merged 2 commits into from
Mar 9, 2024
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
8 changes: 7 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ repository = "https://github.com/paulgb/acme2"
edition = "2018"

[dependencies]
serde = {version = "1.0", features=["derive"]}
serde_json = "1.0"
base64 = "0.21"
data-encoding = "2.5.0"
hyper = "0.14"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "json"] }
openssl = "0.10"
reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "json"] }
serde = {version = "1.0", features=["derive"]}
serde_json = "1.0"
thiserror = "1.0.24"
tokio = { version = "1.0", features = [ "time", "fs" ] }
tracing = "0.1"
tracing-futures = "0.2"
thiserror = "1.0.24"

[dev-dependencies]
anyhow = "1.0.80"
Expand Down
9 changes: 2 additions & 7 deletions src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::error::*;
use base64::Engine;
use data_encoding::BASE64URL_NOPAD;
use openssl::ec::EcGroup;
use openssl::ec::EcKey;
use openssl::nid::Nid;
Expand All @@ -21,12 +21,7 @@ pub struct Identifier {
}

pub(crate) fn b64(data: &[u8]) -> String {
let engine = base64::engine::GeneralPurpose::new(
&base64::alphabet::URL_SAFE,
base64::engine::general_purpose::NO_PAD,
);

engine.encode(data)
BASE64URL_NOPAD.encode(data)
}

/// Generate a new RSA private key using the specified size,
Expand Down
6 changes: 2 additions & 4 deletions tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::common::chaltestsrv::TestServ;
use crate::common::pebble::PebbleBuilder;
use crate::common::test_env::TestEnv;
use acme2_eab::*;
use base64::Engine;
use common::pebble::Pebble;
use data_encoding::BASE64URL_NOPAD;
use openssl::pkey::PKey;
use serde_json::json;
use std::sync::Arc;
Expand Down Expand Up @@ -107,9 +107,7 @@ async fn test_account_creation_pebble_eab() {

let eab_key = {
let value_b64 = private_key;
let value = base64::engine::general_purpose::STANDARD
.decode(value_b64)
.unwrap();
let value = BASE64URL_NOPAD.decode(value_b64.as_bytes()).unwrap();
PKey::hmac(&value).unwrap()
};

Expand Down
Loading