Skip to content

Commit

Permalink
Switch imports to crates.io
Browse files Browse the repository at this point in the history
This commit switches our imports from github-format to crates.io-format,
using the newly released crates.

Some fixes are also implemented for issues that have crawled in
recently via these imports.

Signed-off-by: Ionut Mihalcea <[email protected]>
  • Loading branch information
ionut-arm committed Aug 5, 2021
1 parent 1287ba9 commit 7068e53
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 126 deletions.
70 changes: 25 additions & 45 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ name = "parsec"
path = "src/bin/main.rs"

[dependencies]
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs.git", rev = "6b951390791b398b76eb02c942e24d7c91acc980"}
parsec-interface = "0.25.0"
rand = { version = "0.8.3", features = ["small_rng"], optional = true }
base64 = "0.13.0"
uuid = "0.8.2"
Expand All @@ -26,16 +26,16 @@ toml = "0.5.8"
serde = { version = "1.0.123", features = ["derive"] }
env_logger = "0.8.3"
log = { version = "0.4.14", features = ["serde"] }
cryptoki = { git = "https://github.com/parallaxsecond/rust-cryptoki", rev = "2cd54bba7a00db93b3e9e2acf50726558a1784fc", optional = true, features = ["psa-crypto-conversions"] }
cryptoki = { version = "0.2.0", optional = true, features = ["psa-crypto-conversions"] }
picky-asn1-der = { version = "<=0.2.4", optional = true }
picky-asn1 = { version = ">=0.3.1, <=0.3.1", optional = true }
tss-esapi = { git = "https://github.com/parallaxsecond/rust-tss-esapi", rev = "1f68655e278b0319c080b9804a7bf3f6e11ff721", optional = true }
tss-esapi = { version = "6.1.0", optional = true }
bincode = "1.3.1"
structopt = "0.3.21"
derivative = "2.2.0"
version = "3.0.0"
hex = { version = "0.4.2", optional = true }
psa-crypto = { git = "https://github.com/parallaxsecond/rust-psa-crypto.git", rev = "8605006d34944fa880edd3d4d347f460c5585747", default-features = false, features = ["operations"], optional = true }
psa-crypto = { version = "0.9.0", default-features = false, features = ["operations"], optional = true }
zeroize = { version = "1.2.0", features = ["zeroize_derive"] }
picky-asn1-x509 = { version = "0.4.0", optional = true }
users = "0.11.0"
Expand Down
2 changes: 1 addition & 1 deletion ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ run_old_e2e_tests() {
# /tmp/parsec/parsec.sock. This can not be created in the Dockerfile as this is where
# the repository is checked out.
ln -s /tmp/parsec.sock /tmp/parsec/parsec.sock
RUST_BACKTRACE=1 cargo test --manifest-path /tmp/old_e2e_tests/Cargo.toml normal_tests
RUST_BACKTRACE=1 cargo test --manifest-path /tmp/old_e2e_tests/Cargo.toml normal_tests -- --skip asym_verify_fail
fi
}

Expand Down
15 changes: 13 additions & 2 deletions e2e_tests/src/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ const KEY_DATA: [u8; 140] = [
39, 22, 141, 173, 85, 26, 58, 9, 128, 27, 57, 131, 2, 3, 1, 0, 1,
];

const SIGNATURE: [u8; 128] = [
0x8c, 0xf8, 0x87, 0x3a, 0xb2, 0x9a, 0x18, 0xf9, 0xe0, 0x2e, 0xb9, 0x2d, 0xe7, 0xc8, 0x32, 0x12,
0xd6, 0xd9, 0x2d, 0x98, 0xec, 0x9e, 0x47, 0xb7, 0x5b, 0x26, 0x86, 0x9d, 0xf5, 0xa2, 0x6b, 0x8b,
0x6f, 0x00, 0xd3, 0xbb, 0x68, 0x88, 0xe1, 0xad, 0xcf, 0x1c, 0x09, 0x81, 0x91, 0xbf, 0xee, 0xce,
0x4f, 0xb5, 0x83, 0x3c, 0xf5, 0xb0, 0xfa, 0x68, 0x69, 0xde, 0x7b, 0xe8, 0x49, 0x69, 0x40, 0xad,
0x90, 0xf1, 0x7f, 0x31, 0xf2, 0x75, 0x4e, 0x1c, 0x52, 0x92, 0x72, 0x2e, 0x0b, 0x06, 0xe7, 0x32,
0xb4, 0x5e, 0x82, 0x8b, 0x39, 0x72, 0x24, 0x5f, 0xee, 0x17, 0xae, 0x2d, 0x77, 0x53, 0xff, 0x1a,
0xad, 0x12, 0x83, 0x4f, 0xb5, 0x52, 0x92, 0x6e, 0xda, 0xb2, 0x55, 0x77, 0xa7, 0x58, 0xcc, 0x10,
0xa6, 0x7f, 0xc5, 0x26, 0x4e, 0x5b, 0x75, 0x9d, 0x83, 0x05, 0x9f, 0x99, 0xde, 0xc6, 0xf5, 0x12,
];

#[derive(Copy, Clone, Debug)]
pub struct StressTestConfig {
pub no_threads: usize,
Expand Down Expand Up @@ -209,7 +220,7 @@ impl StressTestWorker {
.verify_with_rsa_sha256(
self.sign_key_name.clone(),
HASH.to_vec(),
vec![0xff; 128],
SIGNATURE.to_vec(),
)
.expect_err("Verification should fail.");
if !(status == ResponseStatus::PsaErrorInvalidSignature
Expand Down Expand Up @@ -245,7 +256,7 @@ impl StressTestWorker {
.verify_with_ecdsa_sha256(
self.ecc_key_name.as_ref().unwrap().clone(),
HASH.to_vec(),
vec![0xff; 64],
SIGNATURE.to_vec(),
)
.expect_err("Verification should fail.");
if !(status == ResponseStatus::PsaErrorInvalidSignature
Expand Down
19 changes: 6 additions & 13 deletions src/key_info_managers/on_disk_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ impl OnDiskKeyInfoManager {
})?;

for app_name_dir_path in list_dirs(&mappings_dir_path)?.iter() {
for provider_dir_path in list_dirs(&app_name_dir_path)?.iter() {
for key_name_file_path in list_files(&provider_dir_path)?.iter() {
for provider_dir_path in list_dirs(app_name_dir_path)?.iter() {
for key_name_file_path in list_files(provider_dir_path)?.iter() {
let mut key_info = Vec::new();
let mut key_info_file = File::open(&key_name_file_path).with_context(|| {
format!(
Expand Down Expand Up @@ -399,17 +399,10 @@ mod test {
key_type: Type::Derive,
bits: 1024,
policy: Policy {
usage_flags: UsageFlags {
sign_hash: true,
verify_hash: false,
sign_message: false,
verify_message: false,
export: false,
encrypt: false,
decrypt: false,
cache: false,
copy: false,
derive: false,
usage_flags: {
let mut usage_flags = UsageFlags::default();
let _ = usage_flags.set_sign_hash();
usage_flags
},
permitted_algorithms: Algorithm::AsymmetricSignature(
AsymmetricSignature::RsaPkcs1v15Sign {
Expand Down
6 changes: 3 additions & 3 deletions src/providers/cryptoauthlib/key_management.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ impl Provider {
.find_suitable_slot(&key_attributes, Some(Opcode::PsaImportKey))?;
let key_data = raw_key_extract(key_attributes.key_type, &op.data)?;

let atca_error_status =
self.device
.import_key(key_type, &key_data.expose_secret(), slot_id);
let atca_error_status = self
.device
.import_key(key_type, key_data.expose_secret(), slot_id);

let psa_error_status: ResponseStatus = match atca_error_status {
rust_cryptoauthlib::AtcaStatus::AtcaSuccess => {
Expand Down
Loading

0 comments on commit 7068e53

Please sign in to comment.