1
0
mirror of https://github.com/BitskiCo/jwk-rs synced 2024-12-29 12:08:50 +00:00

Don't pad base64, as per spec

This commit is contained in:
Nick Hynes 2021-01-25 22:19:51 +03:00
parent 0d890ca6d7
commit c8a05d3360
No known key found for this signature in database
GPG Key ID: 5B3463E9F1D73C83
4 changed files with 5 additions and 5 deletions

View File

@ -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::de::StrRead<'static>> {
serde_json::Deserializer::from_str(&BASE64_JSON)

View File

@ -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() {

View File

@ -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"}"#
);
}

View File

@ -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 {