From d3d2a90328f2ac28562dc253354820b6e3491e95 Mon Sep 17 00:00:00 2001 From: Emanuele Rocca Date: Tue, 20 Jun 2023 20:27:16 +0200 Subject: [PATCH] Bump base64 dependency to 0.21.0 Signed-off-by: Emanuele Rocca --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- e2e_tests/Cargo.toml | 2 +- .../per_provider/normal_tests/asym_encryption.rs | 16 +++++++++++++--- .../per_provider/normal_tests/export_key.rs | 5 ++++- src/key_info_managers/on_disk_manager/mod.rs | 7 ++++--- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e603f11f..f27433cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,7 +92,7 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" @@ -1025,7 +1025,7 @@ name = "parsec-service" version = "1.2.0" dependencies = [ "anyhow", - "base64 0.13.1", + "base64 0.21.0", "bincode", "bindgen 0.63.0", "cryptoki", diff --git a/Cargo.toml b/Cargo.toml index 90a50be2..091ce640 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/e2e_tests/Cargo.toml b/e2e_tests/Cargo.toml index d84703ba..eec3bec4 100644 --- a/e2e_tests/Cargo.toml +++ b/e2e_tests/Cargo.toml @@ -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" diff --git a/e2e_tests/tests/per_provider/normal_tests/asym_encryption.rs b/e2e_tests/tests/per_provider/normal_tests/asym_encryption.rs index 32390945..19f99d02 100644 --- a/e2e_tests/tests/per_provider/normal_tests/asym_encryption.rs +++ b/e2e_tests/tests/per_provider/normal_tests/asym_encryption.rs @@ -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; @@ -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(); @@ -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(); diff --git a/e2e_tests/tests/per_provider/normal_tests/export_key.rs b/e2e_tests/tests/per_provider/normal_tests/export_key.rs index e5901e25..068b945e 100644 --- a/e2e_tests/tests/per_provider/normal_tests/export_key.rs +++ b/e2e_tests/tests/per_provider/normal_tests/export_key.rs @@ -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::*; @@ -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(), diff --git a/src/key_info_managers/on_disk_manager/mod.rs b/src/key_info_managers/on_disk_manager/mod.rs index 632ae429..717b93d3 100644 --- a/src/key_info_managers/on_disk_manager/mod.rs +++ b/src/key_info_managers/on_disk_manager/mod.rs @@ -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; @@ -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()), ) } @@ -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 { - 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()),