Skip to content

Commit

Permalink
Fix merge error; other clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurence Lundblade committed Nov 4, 2023
1 parent 9c54b38 commit 02e9244
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 35 deletions.
1 change: 0 additions & 1 deletion src/t_cose_recipient_dec_esdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ t_cose_recipient_dec_esdh_cb_private(struct t_cose_recipient_dec *me_x,
cose_result = t_cose_headers_decode(
cbor_decoder, /* in: decoder to read from */
loc, /* in: location in COSE message */
loc, /* in: location in COSE message */
false, /* in: no_protected headers */
decode_ephemeral_key, /* in: callback for specials */
NULL, /* in: context for specials callback */
Expand Down
9 changes: 8 additions & 1 deletion test/data/make_test_messages.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/bin/bash

rm -rf test_messages.[ch]
rm -f test_messages.[ch]


cat << EOM > test_messages.c
/* This file is created by make_test_messages.sh from CBOR diag files */
EOM

cp test_messages.c test_messages.h

for i in *.diag;
do
Expand Down
33 changes: 1 addition & 32 deletions test/data/test_messages.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* This file is created by make_test_messages.sh from CBOR diag files */
const unsigned char aead_in_error[] = {
0xd8, 0x60, 0x84, 0x43, 0xa1, 0x01, 0x03, 0xa1,
0x05, 0x4c, 0x02, 0xd1, 0xf7, 0xe6, 0xf2, 0x6c,
Expand Down Expand Up @@ -224,35 +225,3 @@ const unsigned char unprot_headers_wrong_type[] = {
0x85
};
const unsigned int unprot_headers_wrong_type_len = 225;
const unsigned char yy[] = {
0xd8, 0x60, 0x84, 0x43, 0xa1, 0x01, 0x03, 0xa1,
0x05, 0x4c, 0x02, 0xd1, 0xf7, 0xe6, 0xf2, 0x6c,
0x43, 0xd4, 0x86, 0x8d, 0x87, 0xce, 0x58, 0x24,
0x25, 0x6b, 0x74, 0x8d, 0xeb, 0x64, 0x71, 0x31,
0xc1, 0x2a, 0x10, 0xac, 0x26, 0x1d, 0xa0, 0x62,
0x8e, 0x42, 0x04, 0x92, 0xa3, 0x6f, 0x3d, 0xed,
0x86, 0x42, 0xb4, 0xb6, 0xfa, 0x1e, 0xb1, 0x5d,
0xce, 0xc8, 0x0a, 0x0f, 0x81, 0x83, 0x44, 0xa1,
0x01, 0x38, 0x1c, 0xa2, 0x20, 0xa4, 0x01, 0x02,
0x20, 0x01, 0x21, 0x58, 0x20, 0xe1, 0x2c, 0x93,
0x8b, 0x18, 0x22, 0x58, 0xc9, 0xd4, 0x47, 0xd4,
0x18, 0x21, 0x71, 0x52, 0x61, 0xae, 0x99, 0xad,
0x77, 0xd2, 0x41, 0x94, 0x3f, 0x4a, 0x12, 0xff,
0x20, 0xdd, 0x3c, 0xe4, 0x00, 0x22, 0x58, 0x20,
0x48, 0xb0, 0x58, 0x89, 0x03, 0x36, 0x57, 0x33,
0xb9, 0x8d, 0x38, 0x8c, 0x61, 0x36, 0xc0, 0x4b,
0x7f, 0xfd, 0x1a, 0x77, 0x0c, 0xd2, 0x61, 0x11,
0x89, 0xee, 0x84, 0xe9, 0x94, 0x1a, 0x7e, 0x26,
0x04, 0x58, 0x24, 0x6d, 0x65, 0x72, 0x69, 0x61,
0x64, 0x6f, 0x63, 0x2e, 0x62, 0x72, 0x61, 0x6e,
0x64, 0x79, 0x62, 0x75, 0x63, 0x6b, 0x40, 0x62,
0x75, 0x63, 0x6b, 0x6c, 0x61, 0x6e, 0x64, 0x2e,
0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x58,
0x28, 0x50, 0x8f, 0xad, 0x30, 0xa1, 0xa9, 0x5d,
0x13, 0x80, 0xb5, 0x16, 0x7d, 0x03, 0x27, 0x99,
0xc7, 0x24, 0x77, 0xab, 0x60, 0x25, 0x8a, 0xbf,
0xb7, 0x1c, 0x7a, 0xb6, 0x03, 0xa4, 0x89, 0x0e,
0xf4, 0x4f, 0x13, 0x63, 0xed, 0x9f, 0x56, 0x9e,
0x85
};
const unsigned int yy_len = 225;
2 changes: 1 addition & 1 deletion test/data/test_messages.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* This file is created by make_test_messages.sh from CBOR diag files */
extern const unsigned char aead_in_error[225];
extern const unsigned char cose_encrypt_junk_recipient[251];
extern const unsigned char cose_encrypt_p256_wrap_128[225];
extern const unsigned char cose_recipients_map_instead_of_array[231];
extern const unsigned char tstr_ciphertext[223];
extern const unsigned char unknown_symmetric_alg[225];
extern const unsigned char unprot_headers_wrong_type[225];
extern const unsigned char yy[225];
30 changes: 30 additions & 0 deletions test/t_cose_encrypt_decrypt_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,36 @@ int32_t run_decrypt_test(const struct decrypt_test *test)
}


/*
Unknown symmetric cipher alg
Unknown recipient alg
Unknown critical header
Wrong CBOR tag number
Header that is not valid CBOR
Top-level CBOR wrong -- a map, not an array
Ciphertext is not the right type -- a text string
Recipients area is a map, not an array
Extra stuff at end of array of 4
AEAD integrity check fails
IV header header is wrong type -- text string
Symmetric Algorithm ID is the wrong type -- a byte string
Recipient is the wrong type -- a map, not an array
The encrypted CEK is the wrong type -- text string, not byte string
Extra stuff at end of recipient array
Recipient header is not decodable CBOR
Ephemeral key is an array, not a map
Ephemeral key type is unknown
Ephemeral curve is unknown
Ephemeral key type is a byte string
Ephemeral x coordinate is an integer, not a byte string
Ephemeral y coordinate is an integer not a byte string
*/


/* Decided to use a function to initialize rather than attempt
* static initialization. It's only a test.
*/
static int32_t
init_decrypt_test_list(struct decrypt_test tests[], size_t size)
{
Expand Down

0 comments on commit 02e9244

Please sign in to comment.