Replace binary cbor object with cppbor builders in oemcrypto tests
Now that the Cppbor library is in place. Test: opk_ta_p40 Change-Id: I0641e1598d30b178ea2b1feeaf8d4f328be0b23a
This commit is contained in:
@@ -377,21 +377,13 @@ TEST_F(OEMCryptoProv40Test, GetDeviceSignedCsrPayloadAPI18) {
|
|||||||
if (wvoec::global_features.api_version < 18) {
|
if (wvoec::global_features.api_version < 18) {
|
||||||
GTEST_SKIP() << "Test for versions 18 and up only.";
|
GTEST_SKIP() << "Test for versions 18 and up only.";
|
||||||
}
|
}
|
||||||
std::vector<uint8_t> challenge(64, 0xaa);
|
const std::vector<uint8_t> challenge(64, 0xaa);
|
||||||
// TODO: add cppbor support for oemcrypto tests for all targets. Before that,
|
const std::vector<uint8_t> device_info = cppbor::Map()
|
||||||
// use hex values which are equivalent of the commented cppbor statement.
|
.add("manufacturer", "google")
|
||||||
// std::vector<uint8_t> device_info = cppbor::Map()
|
.add("fused", 0)
|
||||||
// .add("manufacturer", "google")
|
.add("other", "ignored")
|
||||||
// .add("fused", 0)
|
.canonicalize()
|
||||||
// .add("other", "ignored")
|
.encode();
|
||||||
// .canonicalize()
|
|
||||||
// .encode();
|
|
||||||
//
|
|
||||||
std::vector<uint8_t> device_info = {
|
|
||||||
0xa3, 0x65, 0x66, 0x75, 0x73, 0x65, 0x64, 0x0, 0x65, 0x6f, 0x74,
|
|
||||||
0x68, 0x65, 0x72, 0x67, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x64,
|
|
||||||
0x6c, 0x6d, 0x61, 0x6e, 0x75, 0x66, 0x61, 0x63, 0x74, 0x75, 0x72,
|
|
||||||
0x65, 0x72, 0x66, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65};
|
|
||||||
std::vector<uint8_t> signed_csr_payload;
|
std::vector<uint8_t> signed_csr_payload;
|
||||||
size_t signed_csr_payload_length = 0;
|
size_t signed_csr_payload_length = 0;
|
||||||
OEMCryptoResult sts = OEMCrypto_GetDeviceSignedCsrPayload(
|
OEMCryptoResult sts = OEMCrypto_GetDeviceSignedCsrPayload(
|
||||||
@@ -416,12 +408,13 @@ TEST_F(OEMCryptoProv40Test, GetDeviceSignedCsrPayloadAPI18) {
|
|||||||
TEST_F(OEMCryptoProv40Test, GetDeviceSignedCsrPayloadInvalid) {
|
TEST_F(OEMCryptoProv40Test, GetDeviceSignedCsrPayloadInvalid) {
|
||||||
std::vector<uint8_t> signed_csr_payload;
|
std::vector<uint8_t> signed_csr_payload;
|
||||||
size_t signed_csr_payload_length = 0;
|
size_t signed_csr_payload_length = 0;
|
||||||
std::vector<uint8_t> challenge(64, 0xaa);
|
const std::vector<uint8_t> challenge(64, 0xaa);
|
||||||
std::vector<uint8_t> device_info = {
|
const std::vector<uint8_t> device_info = cppbor::Map()
|
||||||
0xa3, 0x65, 0x66, 0x75, 0x73, 0x65, 0x64, 0x0, 0x65, 0x6f, 0x74,
|
.add("manufacturer", "google")
|
||||||
0x68, 0x65, 0x72, 0x67, 0x69, 0x67, 0x6e, 0x6f, 0x72, 0x65, 0x64,
|
.add("fused", 0)
|
||||||
0x6c, 0x6d, 0x61, 0x6e, 0x75, 0x66, 0x61, 0x63, 0x74, 0x75, 0x72,
|
.add("other", "ignored")
|
||||||
0x65, 0x72, 0x66, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65};
|
.canonicalize()
|
||||||
|
.encode();
|
||||||
std::vector<uint8_t> challenge_empty;
|
std::vector<uint8_t> challenge_empty;
|
||||||
OEMCryptoResult sts = OEMCrypto_GetDeviceSignedCsrPayload(
|
OEMCryptoResult sts = OEMCrypto_GetDeviceSignedCsrPayload(
|
||||||
challenge_empty.data(), challenge_empty.size(), device_info.data(),
|
challenge_empty.data(), challenge_empty.size(), device_info.data(),
|
||||||
@@ -431,7 +424,7 @@ TEST_F(OEMCryptoProv40Test, GetDeviceSignedCsrPayloadInvalid) {
|
|||||||
ASSERT_EQ(sts, OEMCrypto_ERROR_INVALID_CONTEXT);
|
ASSERT_EQ(sts, OEMCrypto_ERROR_INVALID_CONTEXT);
|
||||||
|
|
||||||
// Oversized challenge
|
// Oversized challenge
|
||||||
std::vector<uint8_t> challenge_long(65, 0xaa);
|
const std::vector<uint8_t> challenge_long(65, 0xaa);
|
||||||
sts = OEMCrypto_GetDeviceSignedCsrPayload(
|
sts = OEMCrypto_GetDeviceSignedCsrPayload(
|
||||||
challenge_long.data(), challenge_long.size(), device_info.data(),
|
challenge_long.data(), challenge_long.size(), device_info.data(),
|
||||||
device_info.size(), signed_csr_payload.data(),
|
device_info.size(), signed_csr_payload.data(),
|
||||||
|
|||||||
Reference in New Issue
Block a user