Separate test for reading ed25519 key from bad cbor
This commit is contained in:
@@ -540,10 +540,9 @@ mod test {
|
|||||||
test_private_key_from_to_cbor(SignatureAlgorithm::EDDSA);
|
test_private_key_from_to_cbor(SignatureAlgorithm::EDDSA);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn test_private_key_from_bad_cbor(signature_algorithm: SignatureAlgorithm) {
|
||||||
fn test_private_key_from_bad_cbor() {
|
|
||||||
let cbor = cbor_array![
|
let cbor = cbor_array![
|
||||||
cbor_int!(SignatureAlgorithm::ES256 as i64),
|
cbor_int!(signature_algorithm as i64),
|
||||||
cbor_bytes!(vec![0x88; 32]),
|
cbor_bytes!(vec![0x88; 32]),
|
||||||
// The array is too long.
|
// The array is too long.
|
||||||
cbor_int!(0),
|
cbor_int!(0),
|
||||||
@@ -552,21 +551,21 @@ mod test {
|
|||||||
PrivateKey::try_from(cbor),
|
PrivateKey::try_from(cbor),
|
||||||
Err(Ctap2StatusCode::CTAP2_ERR_INVALID_CBOR),
|
Err(Ctap2StatusCode::CTAP2_ERR_INVALID_CBOR),
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ed25519")]
|
#[test]
|
||||||
{
|
fn test_ecdsa_private_key_from_bad_cbor() {
|
||||||
let cbor = cbor_array![
|
test_private_key_from_bad_cbor(SignatureAlgorithm::ES256);
|
||||||
cbor_int!(SignatureAlgorithm::EDDSA as i64),
|
}
|
||||||
cbor_bytes!(vec![0x88; 32]),
|
|
||||||
// The array is too long.
|
|
||||||
cbor_int!(0),
|
|
||||||
];
|
|
||||||
assert_eq!(
|
|
||||||
PrivateKey::try_from(cbor),
|
|
||||||
Err(Ctap2StatusCode::CTAP2_ERR_INVALID_CBOR),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(feature = "ed25519")]
|
||||||
|
fn test_ed25519_private_key_from_bad_cbor() {
|
||||||
|
test_private_key_from_bad_cbor(SignatureAlgorithm::EDDSA);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_private_key_from_bad_cbor_unsupported_algo() {
|
||||||
let cbor = cbor_array![
|
let cbor = cbor_array![
|
||||||
// This algorithms doesn't exist.
|
// This algorithms doesn't exist.
|
||||||
cbor_int!(-1),
|
cbor_int!(-1),
|
||||||
|
|||||||
Reference in New Issue
Block a user