From c8a05d33608e6f8f2893081ed10caaeac3eba4da Mon Sep 17 00:00:00 2001 From: Nick Hynes Date: Mon, 25 Jan 2021 22:19:51 +0300 Subject: [PATCH] Don't pad base64, as per spec --- src/byte_array.rs | 2 +- src/byte_vec.rs | 2 +- src/tests.rs | 4 ++-- src/utils.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/byte_array.rs b/src/byte_array.rs index 74d5a9e..6ea6485 100644 --- a/src/byte_array.rs +++ b/src/byte_array.rs @@ -61,7 +61,7 @@ mod tests { use generic_array::typenum::*; static BYTES: &[u8] = &[1, 2, 3, 4, 5, 6, 7]; - static BASE64_JSON: &str = "\"AQIDBAUGBw==\""; + static BASE64_JSON: &str = "\"AQIDBAUGBw\""; fn get_de() -> serde_json::Deserializer> { serde_json::Deserializer::from_str(&BASE64_JSON) diff --git a/src/byte_vec.rs b/src/byte_vec.rs index 2451881..b7b85e4 100644 --- a/src/byte_vec.rs +++ b/src/byte_vec.rs @@ -24,7 +24,7 @@ mod tests { use super::*; static BYTES: &[u8] = &[1, 2, 3, 4, 5, 6, 7]; - static BASE64_JSON: &str = "\"AQIDBAUGBw==\""; + static BASE64_JSON: &str = "\"AQIDBAUGBw\""; #[test] fn test_serde_byte_vec() { diff --git a/src/tests.rs b/src/tests.rs index 232a5ad..bdf74db 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -87,7 +87,7 @@ fn serialize_es256() { }; assert_eq!( jwk.to_string(), - r#"{"kty":"EC","crv":"P-256","x":"AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE=","y":"AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI="}"# + r#"{"kty":"EC","crv":"P-256","x":"AQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQE","y":"AgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgI"}"# ); } @@ -156,7 +156,7 @@ fn serialize_hs256() { }; assert_eq!( jwk.to_string(), - r#"{"kty":"oct","k":"KioqKioqKioqKioqKioqKg=="}"# + r#"{"kty":"oct","k":"KioqKioqKioqKioqKioqKg"}"# ); } diff --git a/src/utils.rs b/src/utils.rs index 2a75c17..426e1ea 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -5,7 +5,7 @@ use serde::{ use zeroize::Zeroizing; fn base64_config() -> base64::Config { - base64::Config::new(base64::CharacterSet::UrlSafe, true /* pad */) + base64::Config::new(base64::CharacterSet::UrlSafe, false /* pad */) } fn base64_encode(bytes: impl AsRef<[u8]>) -> String {