Skip to content

Commit

Permalink
Bump base64 dependency to 0.21.0
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuele Rocca <emanuele.rocca@arm.com>
  • Loading branch information
ema authored and Emanuele Rocca committed Sep 27, 2023
1 parent 0849a43 commit d3d2a90
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "src/bin/main.rs"
[dependencies]
parsec-interface = "0.28.0"
rand = { version = "0.8.3", features = ["small_rng"], optional = true }
base64 = "0.13.0"
base64 = "0.21.0"
uuid = "0.8.2"
threadpool = "1.8.1"
signal-hook = "0.3.4"
Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tss-esapi = { version = "7.3.0", optional = true }
ring = "0.16.20"
rsa = "0.3.0"
picky-asn1-x509 = "0.6.1"
base64 = "0.13.0"
base64 = "0.21.0"
num_cpus = "1.13.0"
picky-asn1-der = "0.2.4"
picky-asn1 = "0.3.1"
Expand Down
16 changes: 13 additions & 3 deletions e2e_tests/tests/per_provider/normal_tests/asym_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
#![allow(unused, dead_code)]

use base64::Engine;
use e2e_tests::auto_test_keyname;
use e2e_tests::TestClient;
use parsec_client::core::interface::operations::can_do_crypto::CheckType;
Expand Down Expand Up @@ -388,9 +389,16 @@ fn asym_verify_decrypt_with_internet() {
}

client
.import_rsa_key_pair_for_encryption(key_name.clone(), base64::decode(PRIVATE_KEY).unwrap())
.import_rsa_key_pair_for_encryption(
key_name.clone(),
base64::engine::general_purpose::STANDARD
.decode(PRIVATE_KEY)
.unwrap(),
)
.unwrap();
let encrypt_bytes = base64::engine::general_purpose::STANDARD
.decode(ENCRYPTED_MESSAGE)
.unwrap();
let encrypt_bytes = base64::decode(ENCRYPTED_MESSAGE).unwrap();
let plaintext_bytes = client
.asymmetric_decrypt_message_with_rsapkcs1v15(key_name, encrypt_bytes)
.unwrap();
Expand Down Expand Up @@ -449,7 +457,9 @@ fn asym_decrypt_not_permitted() {

client.generate_key(key_name.clone(), attributes).unwrap();

let encrypt_bytes = base64::decode(ENCRYPTED_MESSAGE).unwrap();
let encrypt_bytes = base64::engine::general_purpose::STANDARD
.decode(ENCRYPTED_MESSAGE)
.unwrap();
let error = client
.asymmetric_decrypt_message_with_rsapkcs1v15(key_name, encrypt_bytes)
.unwrap_err();
Expand Down
5 changes: 4 additions & 1 deletion e2e_tests/tests/per_provider/normal_tests/export_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
#![allow(unused_imports, unused)]
use crate::per_provider::normal_tests::import_key::ECC_PUBLIC_KEY;
use base64::Engine;
use e2e_tests::auto_test_keyname;
use e2e_tests::TestClient;
use parsec_client::core::interface::operations::psa_algorithm::*;
Expand Down Expand Up @@ -365,7 +366,9 @@ fn export_rsa_private_key_matches_import() {
let _ = usage_flags.set_encrypt().set_decrypt().set_export();
let key_name = auto_test_keyname!();

let decoded_key = base64::decode(PRIVATE_KEY).unwrap();
let decoded_key = base64::engine::general_purpose::STANDARD
.decode(PRIVATE_KEY)
.unwrap();
client
.import_key(
key_name.clone(),
Expand Down
7 changes: 4 additions & 3 deletions src/key_info_managers/on_disk_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::providers::tpm::Provider as TpmProvider;
#[cfg(feature = "trusted-service-provider")]
use crate::providers::trusted_service::Provider as TrustedServiceProvider;
use anyhow::{Context, Result};
use base64::Engine;
use log::{error, info, warn};
use parsec_interface::requests::{AuthType, ProviderId};
use std::collections::HashMap;
Expand Down Expand Up @@ -240,9 +241,9 @@ pub struct OnDiskKeyInfoManager {
#[allow(deprecated)]
fn key_triple_to_base64_filenames(key_triple: &KeyTriple) -> (String, String, String) {
(
base64::encode_config(key_triple.app_name.as_bytes(), base64::URL_SAFE),
base64::engine::general_purpose::URL_SAFE.encode(key_triple.app_name.as_bytes()),
(key_triple.provider_id as u8).to_string(),
base64::encode_config(key_triple.key_name.as_bytes(), base64::URL_SAFE),
base64::engine::general_purpose::URL_SAFE.encode(key_triple.key_name.as_bytes()),
)
}

Expand All @@ -252,7 +253,7 @@ fn key_triple_to_base64_filenames(key_triple: &KeyTriple) -> (String, String, St
///
/// Returns an error as a string if either the decoding or the bytes conversion to UTF-8 failed.
fn base64_data_to_string(base64_bytes: &[u8]) -> Result<String, String> {
match base64::decode_config(base64_bytes, base64::URL_SAFE) {
match base64::engine::general_purpose::URL_SAFE.decode(base64_bytes) {
Ok(decode_bytes) => match String::from_utf8(decode_bytes) {
Ok(string) => Ok(string),
Err(error) => Err(error.to_string()),
Expand Down

0 comments on commit d3d2a90

Please sign in to comment.