Skip to content

Commit

Permalink
Merge pull request #723 from tgonzalezorlandoarm/tg/tpm-testing-fix
Browse files Browse the repository at this point in the history
e2e_tests/wrong_permitted_algorithm: Change used sha for hw compatibi…
  • Loading branch information
tgonzalezorlandoarm authored Oct 19, 2023
2 parents e987290 + 3c4ea26 commit 85e4370
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
19 changes: 6 additions & 13 deletions e2e_tests/Cargo.lock

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

11 changes: 11 additions & 0 deletions e2e_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,17 @@ impl TestClient {
)
}

/// Signs a short digest with an RSA key.
pub fn sign_with_rsa_sha384(&mut self, key_name: String, hash: Vec<u8>) -> Result<Vec<u8>> {
self.sign(
key_name,
AsymmetricSignature::RsaPkcs1v15Sign {
hash_alg: Hash::Sha384.into(),
},
hash,
)
}

/// Signs a short digest with an ECDSA key.
pub fn sign_with_ecdsa_sha256(&mut self, key_name: String, hash: Vec<u8>) -> Result<Vec<u8>> {
self.sign(
Expand Down
4 changes: 2 additions & 2 deletions e2e_tests/tests/per_provider/normal_tests/key_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ fn wrong_permitted_algorithm() {
// Do not permit RSA PKCS 1v15 signing algorithm with SHA-256.
let permitted_algorithm =
Algorithm::AsymmetricSignature(AsymmetricSignature::RsaPkcs1v15Sign {
hash_alg: Hash::Sha512.into(),
hash_alg: Hash::Sha256.into(),
});
let mut usage_flags: UsageFlags = Default::default();
let _ = usage_flags.set_sign_hash();
Expand All @@ -159,7 +159,7 @@ fn wrong_permitted_algorithm() {
.unwrap();

let status = client
.sign_with_rsa_sha256(key_name, vec![0xDE; 32])
.sign_with_rsa_sha384(key_name, vec![0xDE; 32])
.unwrap_err();

assert_eq!(status, ResponseStatus::PsaErrorNotPermitted);
Expand Down

0 comments on commit 85e4370

Please sign in to comment.