Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/suit_manifest_encode_main_psa.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ int main(int argc, char *argv[])
key_pair.k.key_handle = key_handle;
key_pair.crypto_lib = T_COSE_CRYPTO_LIB_PSA;

result = suit_encode_envelope(&envelope, &key_pair, encode_buf, &encode_len);
uint8_t mode = SUIT_DECODE_MODE_STRICT;
result = suit_encode_envelope(mode, &envelope, &key_pair, encode_buf, &encode_len);
if (result != SUIT_SUCCESS) {
printf("Fail to encode. %d\n", result);
return( EXIT_FAILURE );
Expand Down
48 changes: 43 additions & 5 deletions examples/suit_manifest_parser_main_psa.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ static const uint8_t public_key[] =
//static const size_t public_key_len = sizeof(public_key);

static const uint8_t manifest[] =
{0xa2, 0x02, 0x58, 0x98, 0x82, 0x58, 0x24, 0x82, 0x02,
/*
{0xd8, 0x6b, 0xa2, 0x02, 0x58, 0x98, 0x82, 0x58, 0x24, 0x82, 0x2F,
0x58, 0x20, 0x40, 0x42, 0x6b, 0x53, 0xe5, 0x63, 0x2f,
0xd2, 0x5a, 0xce, 0xa2, 0x07, 0x0e, 0x1d, 0xcd, 0x93,
0x2f, 0xb7, 0xbe, 0xd7, 0x82, 0x23, 0xcd, 0x29, 0xc6,
Expand Down Expand Up @@ -71,6 +72,40 @@ static const uint8_t manifest[] =
0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x62, 0x69,
0x6e, 0x15, 0x0f, 0x03, 0x0f, 0x0a, 0x43, 0x82, 0x03,
0x0f};
*/
{
0xd8, 0x6b, 0xa2, 0x02, 0x58, 0x73, 0x82, 0x58, 0x24,
0x82, 0x2f, 0x58, 0x20, 0x40, 0x42, 0x6b, 0x53, 0xe5,
0x63, 0x2f, 0xd2, 0x5a, 0xce, 0xa2, 0x07, 0x0e, 0x1d,
0xcd, 0x93, 0x2f, 0xb7, 0xbe, 0xd7, 0x82, 0x23, 0xcd,
0x29, 0xc6, 0x69, 0x3b, 0x43, 0xa2, 0x77, 0x0b, 0x29,
0x58, 0x4a, 0xd2, 0x84, 0x43, 0xa1, 0x01, 0x26, 0xa0,
0xf6, 0x58, 0x40, 0x64, 0x50, 0x5f, 0xf5, 0xf1, 0x9d,
0x95, 0x46, 0x0c, 0x56, 0xf3, 0x08, 0x29, 0x97, 0xf6,
0x69, 0xfe, 0xde, 0x8f, 0x8a, 0x1e, 0x24, 0xa5, 0x70,
0xa5, 0x6d, 0xd4, 0xaa, 0x66, 0xbb, 0xa6, 0xa6, 0x19,
0x63, 0xa2, 0x05, 0x97, 0x04, 0x39, 0xdf, 0x4f, 0xff,
0x47, 0xb2, 0xd1, 0xa4, 0x8b, 0x16, 0x30, 0xd5, 0x55,
0x87, 0xd5, 0xe9, 0x0b, 0xa1, 0x2b, 0xce, 0x57, 0x25,
0x76, 0x3e, 0x53, 0xed, 0x03, 0x58, 0x94, 0xa5, 0x01,
0x01, 0x02, 0x02, 0x03, 0x58, 0x5f, 0xa2, 0x02, 0x81,
0x81, 0x41, 0x00, 0x04, 0x58, 0x56, 0x86, 0x14, 0xa4,
0x01, 0x50, 0xfa, 0x6b, 0x4a, 0x53, 0xd5, 0xad, 0x5f,
0xdf, 0xbe, 0x9d, 0xe6, 0x63, 0xe4, 0xd4, 0x1f, 0xfe,
0x02, 0x50, 0x14, 0x92, 0xaf, 0x14, 0x25, 0x69, 0x5e,
0x48, 0xbf, 0x42, 0x9b, 0x2d, 0x51, 0xf2, 0xab, 0x45,
0x03, 0x58, 0x24, 0x82, 0x02, 0x58, 0x20, 0x00, 0x11,
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa,
0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x01, 0x23, 0x45, 0x67,
0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc, 0xba, 0x98, 0x76,
0x54, 0x32, 0x10, 0x0e, 0x19, 0x87, 0xd0, 0x01, 0x0f,
0x02, 0x0f, 0x09, 0x58, 0x25, 0x86, 0x13, 0xa1, 0x15,
0x78, 0x1b, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f,
0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x62,
0x69, 0x6e, 0x15, 0x0f, 0x03, 0x0f, 0x0a, 0x43, 0x82,
0x03, 0x0f
};

static const size_t manifest_len = sizeof(manifest);

Expand Down Expand Up @@ -105,20 +140,23 @@ int main(int argc, char *argv[])

*/

#ifdef SKIP_ERROR
//#ifdef SKIP_ERROR
mode = SUIT_DECODE_MODE_SKIP_ANY_ERROR;
#endif
//#endif

suit_envelope_t envelope = (suit_envelope_t){ 0 };
suit_buf_t buf = {.ptr = manifest, .len = manifest_len};

struct t_cose_key cose_public_key;
result = suit_create_es256_public_key((char *)public_key, &cose_public_key);
if (result != SUIT_SUCCESS) {
printf("Can't create Key. %d\n", result);
return EXIT_FAILURE;
}

result = suit_decode_envelope(mode, &buf, &envelope, &cose_public_key);

if (result != SUIT_SUCCESS) {
printf("Can't parse Manifest.\n");
printf("Can't parse Manifest. %d\n", result);
return EXIT_FAILURE;
}

Expand Down
2 changes: 1 addition & 1 deletion inc/suit_cose.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ suit_err_t suit_verify_cose_mac(const UsefulBufC *signed_cose, const struct t_co
suit_err_t suit_verify_cose_mac0(const UsefulBufC *signed_cose, const struct t_cose_key *public_key, UsefulBufC *returned_payload);
#else
suit_err_t suit_create_es256_public_key(const char *public_key, struct t_cose_key *cose_public_key);
suit_err_t suit_verify_cose_sign1(const UsefulBufC *signed_cose, const struct t_cose_key *public_key, UsefulBufC *returned_payload);
suit_err_t suit_verify_cose_sign1(const UsefulBufC *signed_cose, const struct t_cose_key *public_key, UsefulBufC returned_payload);
#endif /* LIBCSUIT_PSA_CRYPTO_C */

#endif /* SUIT_COSE_H */
Expand Down