// This can be used with inconsistent parameters that make the verification fail. // In particular, the signing key does not match the certificate used to verify. fn test_verify_verification_fails(
payload: &[u8],
cert_chain: &[&[u8]],
params_vec: Vec<SignatureParameters>,
) {
test::setup(); let cose_signature = sign(payload, cert_chain, ¶ms_vec);
assert!(cose_signature.is_ok()); let cose_signature = cose_signature.unwrap();
fn test_cose_sign_verify() { let payload = b"This is the content.";
// P256 let certs: [&[u8]; 2] = [&test::P256_ROOT,
&test::P256_INT]; let params_vec = vec![P256_PARAMS];
test_verify(payload, &certs, params_vec);
// P256, no other certs. let certs: [&[u8]; 0] = []; let params_vec = vec![P256_PARAMS];
test_verify(payload, &certs, params_vec);
// P384 let params_vec = vec![P384_PARAMS];
test_verify(payload, &certs, params_vec);
// P521 let params_vec = vec![P521_PARAMS];
test_verify(payload, &certs, params_vec);
}
fn test_cose_verify_xpi_signature() { // This signature was created with sign_app.py from m-c.
test::setup();
assert!(verify_signature(&test::XPI_PAYLOAD, test::XPI_SIGNATURE.to_vec()).is_ok());
}
fn test_cose_sign_verify_modified_payload() { letmut payload = String::from_str("This is the content.")
.unwrap()
.into_bytes(); let certs: [&[u8]; 2] = [&test::P256_ROOT,
&test::P256_INT]; let params_vec = vec![P256_PARAMS];
test_verify_modified_payload(&mut payload, &certs, params_vec);
}
fn test_cose_sign_verify_wrong_cert() { let payload = b"This is the content."; let certs: [&[u8]; 2] = [&test::P256_ROOT,
&test::P256_INT]; let params = SignatureParameters {
certificate: &test::P384_EE,
algorithm: SignatureAlgorithm::ES256,
pkcs8: &test::PKCS8_P256_EE,
}; let params_vec = vec![params];
test_verify_verification_fails(payload, &certs, params_vec);
}
fn test_cose_sign_verify_tampered_signature() { let payload = b"This is the content."; let certs: [&[u8]; 2] = [&test::P256_ROOT,
&test::P256_INT]; let params_vec = vec![P256_PARAMS];
test_verify_modified_signature(payload, &certs, params_vec);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.