Skip to content

Commit

Permalink
chore: bump base64 crate to 0.22.0
Browse files Browse the repository at this point in the history
Signed-off-by: Sergio Correia <[email protected]>
  • Loading branch information
sergio-correia committed May 2, 2024
1 parent 6db05c8 commit 19e5c5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ tss-esapi = { version = "7.2", features = ["generate-bindings"] }
serde = "1.0"
josekit = "0.7.4"
serde_json = "1.0"
base64 = "0.12.1"
base64 = "0.22.0"
atty = "0.2.14"
tpm2-policy = "0.6.0"
7 changes: 5 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::fs;
use std::str::FromStr;

use anyhow::{Context as anyhow_context, Result};
use base64::Engine;
use serde::Deserialize;
use tpm2_policy::{PublicKey, SignedPolicyList, TPMPolicyStep};
use tss_esapi::{
Expand Down Expand Up @@ -68,15 +69,17 @@ pub(crate) fn serialize_as_base64_url_no_pad<S>(
where
S: serde::Serializer,
{
serializer.serialize_str(&base64::encode_config(bytes, base64::URL_SAFE_NO_PAD))
serializer.serialize_str(&base64::engine::general_purpose::URL_SAFE_NO_PAD.encode(bytes))
}

pub(crate) fn deserialize_as_base64_url_no_pad<'de, D>(deserializer: D) -> Result<Vec<u8>, D::Error>
where
D: serde::Deserializer<'de>,
{
String::deserialize(deserializer).and_then(|string| {
base64::decode_config(&string, base64::URL_SAFE_NO_PAD).map_err(serde::de::Error::custom)
base64::engine::general_purpose::URL_SAFE_NO_PAD
.decode(string)
.map_err(serde::de::Error::custom)
})
}

Expand Down

0 comments on commit 19e5c5e

Please sign in to comment.