Skip to content

Commit 2282fc0

Browse files
authored
Merge pull request #178 from hug-dev/import-interface
Import the newest Parsec interface
2 parents 4239ba3 + 296bd73 commit 2282fc0

File tree

19 files changed

+431
-416
lines changed

19 files changed

+431
-416
lines changed

Cargo.lock

Lines changed: 187 additions & 202 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ name = "parsec"
1818
path = "src/bin/main.rs"
1919

2020
[dependencies]
21-
parsec-interface = "0.14.2"
21+
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs" }
2222
rand = "0.7.2"
2323
base64 = "0.10.1"
2424
uuid = "0.7.4"

ci.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,17 @@ else
143143
if [ "$PROVIDER_NAME" = "mbed-crypto" ]; then
144144
echo "Create a fake mapping file for Mbed Provider"
145145
mkdir -p mappings/cm9vdA==/1
146-
printf '\x04\x00\x00\x00\x00\x00\x00\x00\xd6\xcb\xf8\x23\x09\x00\x00\x00' > mappings/cm9vdA==/1/VGVzdCBLZXk\=
147-
printf '\x00\x04\x00\x00\x01\x00\x00\x00\x00\x01\x01\x01\x01\x00\x05\x00' >> mappings/cm9vdA==/1/VGVzdCBLZXk\=
148-
printf '\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00' >> mappings/cm9vdA==/1/VGVzdCBLZXk\=
146+
printf '\x04\x00\x00\x00\x00\x00\x00\x00\xd8\x9e\xa3\x05\x01\x00\x00\x00' > mappings/cm9vdA==/1/VGVzdCBLZXk\=
147+
printf '\x09\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00' >> mappings/cm9vdA==/1/VGVzdCBLZXk\=
148+
printf '\x00\x01\x01\x01\x01\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00' >> mappings/cm9vdA==/1/VGVzdCBLZXk\=
149+
printf '\x00\x00\x06\x00\x00\x00' >> mappings/cm9vdA==/1/VGVzdCBLZXk\=
149150
elif [ "$PROVIDER_NAME" = "pkcs11" ]; then
150151
echo "Create a fake mapping file for PKCS 11 Provider"
151152
mkdir -p mappings/cm9vdA==/2
152-
printf '\x04\x00\x00\x00\x00\x00\x00\x00\xd6\xcb\xf8\x23\x09\x00\x00\x00' > mappings/cm9vdA==/2/VGVzdCBLZXk\=
153-
printf '\x00\x04\x00\x00\x01\x00\x00\x00\x00\x01\x01\x01\x01\x00\x05\x00' >> mappings/cm9vdA==/2/VGVzdCBLZXk\=
154-
printf '\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00' >> mappings/cm9vdA==/2/VGVzdCBLZXk\=
153+
printf '\x04\x00\x00\x00\x00\x00\x00\x00\xd8\x9e\xa3\x05\x01\x00\x00\x00' > mappings/cm9vdA==/2/VGVzdCBLZXk\=
154+
printf '\x09\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00' >> mappings/cm9vdA==/2/VGVzdCBLZXk\=
155+
printf '\x00\x01\x01\x01\x01\x00\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00' >> mappings/cm9vdA==/2/VGVzdCBLZXk\=
156+
printf '\x00\x00\x06\x00\x00\x00' >> mappings/cm9vdA==/2/VGVzdCBLZXk\=
155157
fi
156158

157159
echo "Trigger a configuration reload to load the new mappings"

e2e_tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ picky-asn1-der = "0.2.2"
1818
picky-asn1 = "0.2.1"
1919
serde = { version = "1.0", features = ["derive"] }
2020
sha2 = "0.8.1"
21-
parsec-client = { version = "0.3.0", features = ["testing"] }
21+
parsec-client = { git = "https://github.com/parallaxsecond/parsec-client-rust", features = ["testing"] }
2222
log = "0.4.8"
2323
rand = "0.7.3"
2424

e2e_tests/src/lib.rs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use parsec_client::core::interface::operations::psa_algorithm::{
1616
Algorithm, AsymmetricSignature, Hash,
1717
};
1818
use parsec_client::core::interface::operations::psa_key_attributes::{
19-
KeyAttributes, KeyPolicy, KeyType, UsageFlags,
19+
Attributes, Lifetime, Policy, Type, UsageFlags,
2020
};
2121
use parsec_client::core::interface::requests::{Opcode, ProviderID, ResponseStatus, Result};
2222
use parsec_client::error::Error;
@@ -107,7 +107,7 @@ impl TestClient {
107107
}
108108

109109
/// Creates a key with specific attributes.
110-
pub fn generate_key(&mut self, key_name: String, attributes: KeyAttributes) -> Result<()> {
110+
pub fn generate_key(&mut self, key_name: String, attributes: Attributes) -> Result<()> {
111111
self.basic_client
112112
.psa_generate_key(key_name.clone(), attributes)
113113
.map_err(convert_error)?;
@@ -127,11 +127,12 @@ impl TestClient {
127127
pub fn generate_rsa_sign_key(&mut self, key_name: String) -> Result<()> {
128128
self.generate_key(
129129
key_name,
130-
KeyAttributes {
131-
key_type: KeyType::RsaKeyPair,
132-
key_bits: 1024,
133-
key_policy: KeyPolicy {
134-
key_usage_flags: UsageFlags {
130+
Attributes {
131+
lifetime: Lifetime::Persistent,
132+
key_type: Type::RsaKeyPair,
133+
bits: 1024,
134+
policy: Policy {
135+
usage_flags: UsageFlags {
135136
sign_hash: true,
136137
verify_hash: true,
137138
sign_message: true,
@@ -143,9 +144,9 @@ impl TestClient {
143144
copy: false,
144145
derive: false,
145146
},
146-
key_algorithm: Algorithm::AsymmetricSignature(
147+
permitted_algorithms: Algorithm::AsymmetricSignature(
147148
AsymmetricSignature::RsaPkcs1v15Sign {
148-
hash_alg: Hash::Sha256,
149+
hash_alg: Hash::Sha256.into(),
149150
},
150151
),
151152
},
@@ -157,7 +158,7 @@ impl TestClient {
157158
pub fn import_key(
158159
&mut self,
159160
key_name: String,
160-
attributes: KeyAttributes,
161+
attributes: Attributes,
161162
data: Vec<u8>,
162163
) -> Result<()> {
163164
self.basic_client
@@ -179,11 +180,12 @@ impl TestClient {
179180
pub fn import_rsa_public_key(&mut self, key_name: String, data: Vec<u8>) -> Result<()> {
180181
self.import_key(
181182
key_name,
182-
KeyAttributes {
183-
key_type: KeyType::RsaPublicKey,
184-
key_bits: 1024,
185-
key_policy: KeyPolicy {
186-
key_usage_flags: UsageFlags {
183+
Attributes {
184+
lifetime: Lifetime::Persistent,
185+
key_type: Type::RsaPublicKey,
186+
bits: 1024,
187+
policy: Policy {
188+
usage_flags: UsageFlags {
187189
sign_hash: false,
188190
verify_hash: true,
189191
sign_message: false,
@@ -195,9 +197,9 @@ impl TestClient {
195197
copy: false,
196198
derive: false,
197199
},
198-
key_algorithm: Algorithm::AsymmetricSignature(
200+
permitted_algorithms: Algorithm::AsymmetricSignature(
199201
AsymmetricSignature::RsaPkcs1v15Sign {
200-
hash_alg: Hash::Sha256,
202+
hash_alg: Hash::Sha256.into(),
201203
},
202204
),
203205
},
@@ -246,7 +248,7 @@ impl TestClient {
246248
self.sign(
247249
key_name,
248250
AsymmetricSignature::RsaPkcs1v15Sign {
249-
hash_alg: Hash::Sha256,
251+
hash_alg: Hash::Sha256.into(),
250252
},
251253
hash,
252254
)
@@ -275,7 +277,7 @@ impl TestClient {
275277
self.verify(
276278
key_name,
277279
AsymmetricSignature::RsaPkcs1v15Sign {
278-
hash_alg: Hash::Sha256,
280+
hash_alg: Hash::Sha256.into(),
279281
},
280282
hash,
281283
signature,

e2e_tests/tests/per_provider/normal_tests/asym_sign_verify.rs

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,12 @@ fn sign_hash_not_permitted() -> Result<()> {
134134
hasher.input(b"Bob wrote this message.");
135135
let hash = hasher.result().to_vec();
136136

137-
let attributes = KeyAttributes {
138-
key_type: KeyType::RsaKeyPair,
139-
key_bits: 1024,
140-
key_policy: KeyPolicy {
141-
key_usage_flags: UsageFlags {
137+
let attributes = Attributes {
138+
lifetime: Lifetime::Persistent,
139+
key_type: Type::RsaKeyPair,
140+
bits: 1024,
141+
policy: Policy {
142+
usage_flags: UsageFlags {
142143
sign_hash: false,
143144
verify_hash: true,
144145
sign_message: true,
@@ -150,9 +151,11 @@ fn sign_hash_not_permitted() -> Result<()> {
150151
copy: false,
151152
derive: false,
152153
},
153-
key_algorithm: Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign {
154-
hash_alg: Hash::Sha256,
155-
}),
154+
permitted_algorithms: Algorithm::AsymmetricSignature(
155+
AsymmetricSignature::RsaPkcs1v15Sign {
156+
hash_alg: Hash::Sha256.into(),
157+
},
158+
),
156159
},
157160
};
158161

@@ -207,11 +210,12 @@ fn verify_hash_not_permitted() -> Result<()> {
207210
hasher.input(b"Bob wrote this message.");
208211
let hash = hasher.result().to_vec();
209212

210-
let attributes = KeyAttributes {
211-
key_type: KeyType::RsaKeyPair,
212-
key_bits: 1024,
213-
key_policy: KeyPolicy {
214-
key_usage_flags: UsageFlags {
213+
let attributes = Attributes {
214+
lifetime: Lifetime::Persistent,
215+
key_type: Type::RsaKeyPair,
216+
bits: 1024,
217+
policy: Policy {
218+
usage_flags: UsageFlags {
215219
sign_hash: true,
216220
verify_hash: false,
217221
sign_message: true,
@@ -223,9 +227,11 @@ fn verify_hash_not_permitted() -> Result<()> {
223227
copy: false,
224228
derive: false,
225229
},
226-
key_algorithm: Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign {
227-
hash_alg: Hash::Sha256,
228-
}),
230+
permitted_algorithms: Algorithm::AsymmetricSignature(
231+
AsymmetricSignature::RsaPkcs1v15Sign {
232+
hash_alg: Hash::Sha256.into(),
233+
},
234+
),
229235
},
230236
};
231237

e2e_tests/tests/per_provider/normal_tests/create_destroy_key.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use parsec_client::core::interface::operations::psa_algorithm::{
55
Algorithm, AsymmetricSignature, Hash,
66
};
77
use parsec_client::core::interface::operations::psa_key_attributes::{
8-
KeyAttributes, KeyPolicy, KeyType, UsageFlags,
8+
Attributes, Lifetime, Policy, Type, UsageFlags,
99
};
1010
use parsec_client::core::interface::requests::ResponseStatus;
1111
use parsec_client::core::interface::requests::Result;
@@ -111,11 +111,12 @@ fn failed_created_key_should_be_removed() -> Result<()> {
111111
let mut client = TestClient::new();
112112
let key_name = String::from("failed_created_key_should_be_removed");
113113

114-
let attributes = KeyAttributes {
115-
key_type: KeyType::Arc4,
116-
key_bits: 1024,
117-
key_policy: KeyPolicy {
118-
key_usage_flags: UsageFlags {
114+
let attributes = Attributes {
115+
lifetime: Lifetime::Persistent,
116+
key_type: Type::Arc4,
117+
bits: 1024,
118+
policy: Policy {
119+
usage_flags: UsageFlags {
119120
sign_hash: false,
120121
verify_hash: true,
121122
sign_message: false,
@@ -127,9 +128,11 @@ fn failed_created_key_should_be_removed() -> Result<()> {
127128
copy: false,
128129
derive: false,
129130
},
130-
key_algorithm: Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign {
131-
hash_alg: Hash::Sha256,
132-
}),
131+
permitted_algorithms: Algorithm::AsymmetricSignature(
132+
AsymmetricSignature::RsaPkcs1v15Sign {
133+
hash_alg: Hash::Sha256.into(),
134+
},
135+
),
133136
},
134137
};
135138

e2e_tests/tests/per_provider/normal_tests/export_public_key.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,12 @@ fn check_export_public_possible() -> Result<()> {
8080
let mut client = TestClient::new();
8181
let key_name = String::from("check_export_public_possible");
8282

83-
let key_attributes = KeyAttributes {
84-
key_type: KeyType::RsaKeyPair,
85-
key_bits: 1024,
86-
key_policy: KeyPolicy {
87-
key_usage_flags: UsageFlags {
83+
let key_attributes = Attributes {
84+
lifetime: Lifetime::Persistent,
85+
key_type: Type::RsaKeyPair,
86+
bits: 1024,
87+
policy: Policy {
88+
usage_flags: UsageFlags {
8889
sign_hash: false,
8990
verify_hash: false,
9091
sign_message: false,
@@ -96,9 +97,11 @@ fn check_export_public_possible() -> Result<()> {
9697
copy: false,
9798
derive: false,
9899
},
99-
key_algorithm: Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign {
100-
hash_alg: Hash::Sha256,
101-
}),
100+
permitted_algorithms: Algorithm::AsymmetricSignature(
101+
AsymmetricSignature::RsaPkcs1v15Sign {
102+
hash_alg: Hash::Sha256.into(),
103+
},
104+
),
102105
},
103106
};
104107

0 commit comments

Comments
 (0)