diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d64f10d4..f693f6c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: v0.9.0 hooks: - id: astyle_py - files: '^(man|include/oscore|src/oscore|src/coap_oscore|examples/riot|examples/lwip|examples/contiki).*\.(c|cpp|cxx|h|h.in|h.riot|h.riot.in|h.windows|h.windows.in|h.contiki|hpp|inc)$' + files: '^(man|include/oscore|src/oscore|src/coap_oscore|examples/riot|examples/lwip|examples/contiki|tests).*\.(c|cpp|cxx|h|h.in|h.riot|h.riot.in|h.windows|h.windows.in|h.contiki|hpp|inc)$' exclude: '^.*/(coap_uthash_internal.h|coap_utlist_internal.h)$' args: ['--style=google', '--align-pointer=name', diff --git a/tests/oss-fuzz/pdu_parse_tcp_target.c b/tests/oss-fuzz/pdu_parse_tcp_target.c index 8120b5bc..50f723ef 100644 --- a/tests/oss-fuzz/pdu_parse_tcp_target.c +++ b/tests/oss-fuzz/pdu_parse_tcp_target.c @@ -4,20 +4,20 @@ size_t coap_pdu_encode_header(coap_pdu_t *, coap_proto_t); int -LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size); - if (pdu) { - coap_set_log_level(COAP_LOG_ERR); - if (coap_pdu_parse(COAP_PROTO_TCP, data, size, pdu)) { - coap_string_t *query = coap_get_query(pdu); - coap_string_t *uri_path = coap_get_uri_path(pdu); - coap_show_pdu(COAP_LOG_ERR, pdu); - coap_pdu_encode_header(pdu, COAP_PROTO_TCP); +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size); + if (pdu) { + coap_set_log_level(COAP_LOG_ERR); + if (coap_pdu_parse(COAP_PROTO_TCP, data, size, pdu)) { + coap_string_t *query = coap_get_query(pdu); + coap_string_t *uri_path = coap_get_uri_path(pdu); + coap_show_pdu(COAP_LOG_ERR, pdu); + coap_pdu_encode_header(pdu, COAP_PROTO_TCP); - coap_delete_string(query); - coap_delete_string(uri_path); - } - coap_delete_pdu(pdu); + coap_delete_string(query); + coap_delete_string(uri_path); } - return 0; + coap_delete_pdu(pdu); + } + return 0; } diff --git a/tests/oss-fuzz/pdu_parse_udp_target.c b/tests/oss-fuzz/pdu_parse_udp_target.c index 4c586c2b..956fdd9f 100644 --- a/tests/oss-fuzz/pdu_parse_udp_target.c +++ b/tests/oss-fuzz/pdu_parse_udp_target.c @@ -4,20 +4,20 @@ size_t coap_pdu_encode_header(coap_pdu_t *, coap_proto_t); int -LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size); - if (pdu) { - coap_set_log_level(COAP_LOG_ERR); - if (coap_pdu_parse(COAP_PROTO_UDP, data, size, pdu)) { - coap_string_t *query = coap_get_query(pdu); - coap_string_t *uri_path = coap_get_uri_path(pdu); - coap_show_pdu(COAP_LOG_ERR, pdu); - coap_pdu_encode_header(pdu, COAP_PROTO_UDP); +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size); + if (pdu) { + coap_set_log_level(COAP_LOG_ERR); + if (coap_pdu_parse(COAP_PROTO_UDP, data, size, pdu)) { + coap_string_t *query = coap_get_query(pdu); + coap_string_t *uri_path = coap_get_uri_path(pdu); + coap_show_pdu(COAP_LOG_ERR, pdu); + coap_pdu_encode_header(pdu, COAP_PROTO_UDP); - coap_delete_string(query); - coap_delete_string(uri_path); - } - coap_delete_pdu(pdu); + coap_delete_string(query); + coap_delete_string(uri_path); } - return 0; + coap_delete_pdu(pdu); + } + return 0; } diff --git a/tests/oss-fuzz/pdu_parse_ws_target.c b/tests/oss-fuzz/pdu_parse_ws_target.c index 04f2fc6a..c0232f91 100644 --- a/tests/oss-fuzz/pdu_parse_ws_target.c +++ b/tests/oss-fuzz/pdu_parse_ws_target.c @@ -4,20 +4,20 @@ size_t coap_pdu_encode_header(coap_pdu_t *, coap_proto_t); int -LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size); - if (pdu) { - coap_set_log_level(COAP_LOG_ERR); - if (coap_pdu_parse(COAP_PROTO_WS, data, size, pdu)) { - coap_string_t *query = coap_get_query(pdu); - coap_string_t *uri_path = coap_get_uri_path(pdu); - coap_show_pdu(COAP_LOG_ERR, pdu); - coap_pdu_encode_header(pdu, COAP_PROTO_WS); +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + coap_pdu_t *pdu = coap_pdu_init(0, 0, 0, size); + if (pdu) { + coap_set_log_level(COAP_LOG_ERR); + if (coap_pdu_parse(COAP_PROTO_WS, data, size, pdu)) { + coap_string_t *query = coap_get_query(pdu); + coap_string_t *uri_path = coap_get_uri_path(pdu); + coap_show_pdu(COAP_LOG_ERR, pdu); + coap_pdu_encode_header(pdu, COAP_PROTO_WS); - coap_delete_string(query); - coap_delete_string(uri_path); - } - coap_delete_pdu(pdu); + coap_delete_string(query); + coap_delete_string(uri_path); } - return 0; + coap_delete_pdu(pdu); + } + return 0; } diff --git a/tests/oss-fuzz/split_uri_target.c b/tests/oss-fuzz/split_uri_target.c index 7a8d0705..320f7722 100644 --- a/tests/oss-fuzz/split_uri_target.c +++ b/tests/oss-fuzz/split_uri_target.c @@ -1,8 +1,8 @@ #include int -LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - coap_uri_t uri; - coap_split_uri(data, size, &uri); - return 0; +LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + coap_uri_t uri; + coap_split_uri(data, size, &uri); + return 0; } diff --git a/tests/test_encode.c b/tests/test_encode.c index 75e47e60..3a15e0dd 100644 --- a/tests/test_encode.c +++ b/tests/test_encode.c @@ -242,10 +242,10 @@ t_init_encode_tests(void) { if ((suite[1] = CU_add_suite("byte value encoder", NULL, NULL))) { #define ENCODE_TEST(n,s) \ - if (!CU_add_test(suite[1], s, t_encode##n)) { \ - fprintf(stderr, "W: cannot add encoder test (%s)\n", \ - CU_get_error_msg()); \ - } + if (!CU_add_test(suite[1], s, t_encode##n)) { \ + fprintf(stderr, "W: cannot add encoder test (%s)\n", \ + CU_get_error_msg()); \ + } ENCODE_TEST(1, "encode value #1"); ENCODE_TEST(2, "encode value #2"); diff --git a/tests/test_error_response.c b/tests/test_error_response.c index d42ee71f..e4c6121e 100644 --- a/tests/test_error_response.c +++ b/tests/test_error_response.c @@ -124,10 +124,10 @@ t_error_response4(void) { }; uint8_t teststr[] = { 0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e', - 'n', 0xdc, 0x0c, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 'n', 0xdc, 0x0c, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 'B', - 'a', 'd', ' ', 'O', 'p', 't', 'i', 'o', - 'n' + 'a', 'd', ' ', 'O', 'p', 't', 'i', 'o', + 'n' }; coap_pdu_t *response; @@ -164,11 +164,11 @@ t_error_response5(void) { }; uint8_t teststr[] = { 0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e', - 'n', 0xdd, 0x0c, 0x06, 0x00, 0x01, 0x02, 0x03, 0x04, + 'n', 0xdd, 0x0c, 0x06, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0xff, 'B', - 'a', 'd', ' ', 'O', 'p', 't', 'i', 'o', - 'n' + 'a', 'd', ' ', 'O', 'p', 't', 'i', 'o', + 'n' }; coap_pdu_t *response; @@ -205,11 +205,11 @@ t_error_response6(void) { }; uint8_t teststr[] = { 0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e', - 'n', 0xdd, 0x0a, 0x06, 0x00, 0x01, 0x02, 0x03, + 'n', 0xdd, 0x0a, 0x06, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0xff, - 'B', 'a', 'd', ' ', 'O', 'p', 't', 'i', - 'o', 'n' + 'B', 'a', 'd', ' ', 'O', 'p', 't', 'i', + 'o', 'n' }; coap_pdu_t *response; @@ -246,11 +246,11 @@ t_error_response7(void) { }; uint8_t teststr[] = { 0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e', - 'n', 0xdd, 0x0a, 0x06, 0x00, 0x01, 0x02, 0x03, + 'n', 0xdd, 0x0a, 0x06, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0xff, - 'B', 'a', 'd', ' ', 'O', 'p', 't', 'i', - 'o', 'n' + 'B', 'a', 'd', ' ', 'O', 'p', 't', 'i', + 'o', 'n' }; coap_pdu_t *response; @@ -283,10 +283,10 @@ t_error_response8(void) { const uint8_t code = COAP_RESPONSE_CODE(503); uint8_t teststr[] = { 0x65, code, 0x00, 0x00, 't', 'o', 'k', 'e', - 'n', 0xe0, 0x02, 0xdc, 0xd0, 0x00, 0xff, 'S', - 'e', 'r', 'v', 'i', 'c', 'e', ' ', 'U', - 'n', 'a', 'v', 'a', 'i', 'l', 'a', 'b', - 'l', 'e' + 'n', 0xe0, 0x02, 0xdc, 0xd0, 0x00, 0xff, 'S', + 'e', 'r', 'v', 'i', 'c', 'e', ' ', 'U', + 'n', 'a', 'v', 'a', 'i', 'l', 'a', 'b', + 'l', 'e' }; coap_pdu_t *response; diff --git a/tests/test_options.c b/tests/test_options.c index 435238a4..5746bec7 100644 --- a/tests/test_options.c +++ b/tests/test_options.c @@ -54,7 +54,8 @@ static void t_parse_option3(void) { /* delta == 3, length == 12, value == 0 */ coap_str_const_t teststr = { 13, (const uint8_t *)"\x3c\x00\x01\x02\x03\x04" - "\x05\x06\x07\x08\x09\x0a\x0b" }; + "\x05\x06\x07\x08\x09\x0a\x0b" + }; size_t result; coap_option_t option; @@ -383,9 +384,9 @@ t_access_option2(void) { static void t_access_option3(void) { const uint8_t teststr[] = { 0xed, 0x18, 0x0a, 0x00, 'a', 'b', 'c', 'd', - 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', - 'm' - }; + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', + 'm' + }; coap_option_t opt; CU_ASSERT(sizeof(teststr) == coap_opt_parse((const coap_opt_t *)teststr, @@ -965,10 +966,10 @@ t_init_option_tests(void) { if ((suite[1] = CU_add_suite("option encoder", NULL, NULL))) { #define OPTION_ENCODER_TEST(n,s) \ - if (!CU_add_test(suite[1], s, t_encode_option##n)) { \ - fprintf(stderr, "W: cannot add option encoder test (%s)\n", \ - CU_get_error_msg()); \ - } + if (!CU_add_test(suite[1], s, t_encode_option##n)) { \ + fprintf(stderr, "W: cannot add option encoder test (%s)\n", \ + CU_get_error_msg()); \ + } OPTION_ENCODER_TEST(1, "encode option #1"); OPTION_ENCODER_TEST(2, "encode option #2"); @@ -987,10 +988,10 @@ t_init_option_tests(void) { if ((suite[2] = CU_add_suite("option accessors", NULL, NULL))) { #define OPTION_ACCESSOR_TEST(n,s) \ - if (!CU_add_test(suite[2], s, t_access_option##n)) { \ - fprintf(stderr, "W: cannot add option accessor function test (%s)\n", \ - CU_get_error_msg()); \ - } + if (!CU_add_test(suite[2], s, t_access_option##n)) { \ + fprintf(stderr, "W: cannot add option accessor function test (%s)\n", \ + CU_get_error_msg()); \ + } OPTION_ACCESSOR_TEST(1, "access option #1"); OPTION_ACCESSOR_TEST(2, "access option #2"); @@ -1007,10 +1008,10 @@ t_init_option_tests(void) { if ((suite[3] = CU_add_suite("option iterator", NULL, NULL))) { #define OPTION_ITERATOR_TEST(n,s) \ - if (!CU_add_test(suite[3], s, t_iterate_option##n)) { \ - fprintf(stderr, "W: cannot add option iterator test (%s)\n", \ - CU_get_error_msg()); \ - } + if (!CU_add_test(suite[3], s, t_iterate_option##n)) { \ + fprintf(stderr, "W: cannot add option iterator test (%s)\n", \ + CU_get_error_msg()); \ + } OPTION_ITERATOR_TEST(1, "option iterator #1"); OPTION_ITERATOR_TEST(2, "option iterator #2"); @@ -1030,10 +1031,10 @@ t_init_option_tests(void) { if ((suite[4] = CU_add_suite("option filter", NULL, NULL))) { #define OPTION_FILTER_TEST(n,s) \ - if (!CU_add_test(suite[4], s, t_filter_option##n)) { \ - fprintf(stderr, "W: cannot add option filter test (%s)\n", \ - CU_get_error_msg()); \ - } + if (!CU_add_test(suite[4], s, t_filter_option##n)) { \ + fprintf(stderr, "W: cannot add option filter test (%s)\n", \ + CU_get_error_msg()); \ + } OPTION_FILTER_TEST(1, "option filter #1"); OPTION_FILTER_TEST(2, "option filter #2"); diff --git a/tests/test_oscore.c b/tests/test_oscore.c index d6ff6d35..dfd9d9c5 100644 --- a/tests/test_oscore.c +++ b/tests/test_oscore.c @@ -22,7 +22,7 @@ #include #define CHECK_SAME(a,b) \ - (sizeof((a)) == (b)->length && memcmp((a), (b)->s, (b)->length) == 0) + (sizeof((a)) == (b)->length && memcmp((a), (b)->s, (b)->length) == 0) #define Return_CU_ASSERT_PTR_NOT_NULL(value) CU_ASSERT_PTR_NOT_NULL(value); if ((void*)value == NULL) return @@ -33,28 +33,34 @@ /* C.1.1. Test Vector 1: Key Derivation with Master Salt, Client */ static void t_oscore_c_1_1(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "sender_id,hex,\"\"\n" - "recipient_id,hex,\"01\"\n"; - static const uint8_t sender_key[] = - { 0xf0, 0x91, 0x0e, 0xd7, 0x29, 0x5e, 0x6a, 0xd4, - 0xb5, 0x4f, 0xc7, 0x93, 0x15, 0x43, 0x02, 0xff }; - static const uint8_t recipient_key[] = - { 0xff, 0xb1, 0x4e, 0x09, 0x3c, 0x94, 0xc9, 0xca, - 0xc9, 0x47, 0x16, 0x48, 0xb4, 0xf9, 0x87, 0x10 }; - static const uint8_t common_iv[] = - { 0x46, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x68, - 0xee, 0xfb, 0x54, 0x98, 0x7c }; - static const uint8_t sender_nonce[] = - { 0x46, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x68, - 0xee, 0xfb, 0x54, 0x98, 0x7c }; - static const uint8_t recipient_nonce[] = - { 0x47, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x69, - 0xee, 0xfb, 0x54, 0x98, 0x7c }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "sender_id,hex,\"\"\n" + "recipient_id,hex,\"01\"\n"; + static const uint8_t sender_key[] = { + 0xf0, 0x91, 0x0e, 0xd7, 0x29, 0x5e, 0x6a, 0xd4, + 0xb5, 0x4f, 0xc7, 0x93, 0x15, 0x43, 0x02, 0xff + }; + static const uint8_t recipient_key[] = { + 0xff, 0xb1, 0x4e, 0x09, 0x3c, 0x94, 0xc9, 0xca, + 0xc9, 0x47, 0x16, 0x48, 0xb4, 0xf9, 0x87, 0x10 + }; + static const uint8_t common_iv[] = { + 0x46, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x68, + 0xee, 0xfb, 0x54, 0x98, 0x7c + }; + static const uint8_t sender_nonce[] = { + 0x46, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x68, + 0xee, 0xfb, 0x54, 0x98, 0x7c + }; + static const uint8_t recipient_nonce[] = { + 0x47, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x69, + 0xee, 0xfb, 0x54, 0x98, 0x7c + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; cose_encrypt0_t cose[1]; @@ -90,28 +96,34 @@ t_oscore_c_1_1(void) { /* C.1.2. Test Vector 1: Key Derivation with Master Salt, Server */ static void t_oscore_c_1_2(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "sender_id,hex,\"01\"\n" - "recipient_id,hex,\"\"\n"; - static const uint8_t sender_key[] = - { 0xff, 0xb1, 0x4e, 0x09, 0x3c, 0x94, 0xc9, 0xca, - 0xc9, 0x47, 0x16, 0x48, 0xb4, 0xf9, 0x87, 0x10 }; - static const uint8_t recipient_key[] = - { 0xf0, 0x91, 0x0e, 0xd7, 0x29, 0x5e, 0x6a, 0xd4, - 0xb5, 0x4f, 0xc7, 0x93, 0x15, 0x43, 0x02, 0xff }; - static const uint8_t common_iv[] = - { 0x46, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x68, - 0xee, 0xfb, 0x54, 0x98, 0x7c }; - static const uint8_t sender_nonce[] = - { 0x47, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x69, - 0xee, 0xfb, 0x54, 0x98, 0x7c }; - static const uint8_t recipient_nonce[] = - { 0x46, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x68, - 0xee, 0xfb, 0x54, 0x98, 0x7c }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "sender_id,hex,\"01\"\n" + "recipient_id,hex,\"\"\n"; + static const uint8_t sender_key[] = { + 0xff, 0xb1, 0x4e, 0x09, 0x3c, 0x94, 0xc9, 0xca, + 0xc9, 0x47, 0x16, 0x48, 0xb4, 0xf9, 0x87, 0x10 + }; + static const uint8_t recipient_key[] = { + 0xf0, 0x91, 0x0e, 0xd7, 0x29, 0x5e, 0x6a, 0xd4, + 0xb5, 0x4f, 0xc7, 0x93, 0x15, 0x43, 0x02, 0xff + }; + static const uint8_t common_iv[] = { + 0x46, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x68, + 0xee, 0xfb, 0x54, 0x98, 0x7c + }; + static const uint8_t sender_nonce[] = { + 0x47, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x69, + 0xee, 0xfb, 0x54, 0x98, 0x7c + }; + static const uint8_t recipient_nonce[] = { + 0x46, 0x22, 0xd4, 0xdd, 0x6d, 0x94, 0x41, 0x68, + 0xee, 0xfb, 0x54, 0x98, 0x7c + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; cose_encrypt0_t cose[1]; @@ -147,27 +159,33 @@ t_oscore_c_1_2(void) { /* C.2.1. Test Vector 2: Key Derivation without Master Salt, Client */ static void t_oscore_c_2_1(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "sender_id,hex,\"00\"\n" - "recipient_id,hex,\"01\"\n"; - static const uint8_t sender_key[] = - { 0x32, 0x1b, 0x26, 0x94, 0x32, 0x53, 0xc7, 0xff, - 0xb6, 0x00, 0x3b, 0x0b, 0x64, 0xd7, 0x40, 0x41 }; - static const uint8_t recipient_key[] = - { 0xe5, 0x7b, 0x56, 0x35, 0x81, 0x51, 0x77, 0xcd, - 0x67, 0x9a, 0xb4, 0xbc, 0xec, 0x9d, 0x7d, 0xda }; - static const uint8_t common_iv[] = - { 0xbe, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe9, - 0x10, 0xc5, 0x2e, 0x99, 0xf9 }; - static const uint8_t sender_nonce[] = - { 0xbf, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe9, - 0x10, 0xc5, 0x2e, 0x99, 0xf9 }; - static const uint8_t recipient_nonce[] = - { 0xbf, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe8, - 0x10, 0xc5, 0x2e, 0x99, 0xf9 }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "sender_id,hex,\"00\"\n" + "recipient_id,hex,\"01\"\n"; + static const uint8_t sender_key[] = { + 0x32, 0x1b, 0x26, 0x94, 0x32, 0x53, 0xc7, 0xff, + 0xb6, 0x00, 0x3b, 0x0b, 0x64, 0xd7, 0x40, 0x41 + }; + static const uint8_t recipient_key[] = { + 0xe5, 0x7b, 0x56, 0x35, 0x81, 0x51, 0x77, 0xcd, + 0x67, 0x9a, 0xb4, 0xbc, 0xec, 0x9d, 0x7d, 0xda + }; + static const uint8_t common_iv[] = { + 0xbe, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe9, + 0x10, 0xc5, 0x2e, 0x99, 0xf9 + }; + static const uint8_t sender_nonce[] = { + 0xbf, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe9, + 0x10, 0xc5, 0x2e, 0x99, 0xf9 + }; + static const uint8_t recipient_nonce[] = { + 0xbf, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe8, + 0x10, 0xc5, 0x2e, 0x99, 0xf9 + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; cose_encrypt0_t cose[1]; @@ -203,27 +221,33 @@ t_oscore_c_2_1(void) { /* C.2.2. Test Vector 2: Key Derivation without Master Salt, Server */ static void t_oscore_c_2_2(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "sender_id,hex,\"01\"\n" - "recipient_id,hex,\"00\"\n"; - static const uint8_t sender_key[] = - { 0xe5, 0x7b, 0x56, 0x35, 0x81, 0x51, 0x77, 0xcd, - 0x67, 0x9a, 0xb4, 0xbc, 0xec, 0x9d, 0x7d, 0xda }; - static const uint8_t recipient_key[] = - { 0x32, 0x1b, 0x26, 0x94, 0x32, 0x53, 0xc7, 0xff, - 0xb6, 0x00, 0x3b, 0x0b, 0x64, 0xd7, 0x40, 0x41 }; - static const uint8_t common_iv[] = - { 0xbe, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe9, - 0x10, 0xc5, 0x2e, 0x99, 0xf9 }; - static const uint8_t sender_nonce[] = - { 0xbf, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe8, - 0x10, 0xc5, 0x2e, 0x99, 0xf9 }; - static const uint8_t recipient_nonce[] = - { 0xbf, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe9, - 0x10, 0xc5, 0x2e, 0x99, 0xf9 }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "sender_id,hex,\"01\"\n" + "recipient_id,hex,\"00\"\n"; + static const uint8_t sender_key[] = { + 0xe5, 0x7b, 0x56, 0x35, 0x81, 0x51, 0x77, 0xcd, + 0x67, 0x9a, 0xb4, 0xbc, 0xec, 0x9d, 0x7d, 0xda + }; + static const uint8_t recipient_key[] = { + 0x32, 0x1b, 0x26, 0x94, 0x32, 0x53, 0xc7, 0xff, + 0xb6, 0x00, 0x3b, 0x0b, 0x64, 0xd7, 0x40, 0x41 + }; + static const uint8_t common_iv[] = { + 0xbe, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe9, + 0x10, 0xc5, 0x2e, 0x99, 0xf9 + }; + static const uint8_t sender_nonce[] = { + 0xbf, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe8, + 0x10, 0xc5, 0x2e, 0x99, 0xf9 + }; + static const uint8_t recipient_nonce[] = { + 0xbf, 0x35, 0xae, 0x29, 0x7d, 0x2d, 0xac, 0xe9, + 0x10, 0xc5, 0x2e, 0x99, 0xf9 + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; cose_encrypt0_t cose[1]; @@ -259,29 +283,35 @@ t_oscore_c_2_2(void) { /* C.3.1. Test Vector 3: Key Derivation with ID Context, Client */ static void t_oscore_c_3_1(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "id_context,hex,\"37cbf3210017a2d3\"\n" - "sender_id,hex,\"\"\n" - "recipient_id,hex,\"01\"\n"; - static const uint8_t sender_key[] = - { 0xaf, 0x2a, 0x13, 0x00, 0xa5, 0xe9, 0x57, 0x88, - 0xb3, 0x56, 0x33, 0x6e, 0xee, 0xcd, 0x2b, 0x92 }; - static const uint8_t recipient_key[] = - { 0xe3, 0x9a, 0x0c, 0x7c, 0x77, 0xb4, 0x3f, 0x03, - 0xb4, 0xb3, 0x9a, 0xb9, 0xa2, 0x68, 0x69, 0x9f }; - static const uint8_t common_iv[] = - { 0x2c, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1c, - 0x0b, 0x71, 0x81, 0xb8, 0x5e }; - static const uint8_t sender_nonce[] = - { 0x2c, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1c, - 0x0b, 0x71, 0x81, 0xb8, 0x5e }; - static const uint8_t recipient_nonce[] = - { 0x2d, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1d, - 0x0b, 0x71, 0x81, 0xb8, 0x5e }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "id_context,hex,\"37cbf3210017a2d3\"\n" + "sender_id,hex,\"\"\n" + "recipient_id,hex,\"01\"\n"; + static const uint8_t sender_key[] = { + 0xaf, 0x2a, 0x13, 0x00, 0xa5, 0xe9, 0x57, 0x88, + 0xb3, 0x56, 0x33, 0x6e, 0xee, 0xcd, 0x2b, 0x92 + }; + static const uint8_t recipient_key[] = { + 0xe3, 0x9a, 0x0c, 0x7c, 0x77, 0xb4, 0x3f, 0x03, + 0xb4, 0xb3, 0x9a, 0xb9, 0xa2, 0x68, 0x69, 0x9f + }; + static const uint8_t common_iv[] = { + 0x2c, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1c, + 0x0b, 0x71, 0x81, 0xb8, 0x5e + }; + static const uint8_t sender_nonce[] = { + 0x2c, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1c, + 0x0b, 0x71, 0x81, 0xb8, 0x5e + }; + static const uint8_t recipient_nonce[] = { + 0x2d, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1d, + 0x0b, 0x71, 0x81, 0xb8, 0x5e + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; cose_encrypt0_t cose[1]; @@ -317,29 +347,35 @@ t_oscore_c_3_1(void) { /* C.3.2. Test Vector 3: Key Derivation with ID Context, Server */ static void t_oscore_c_3_2(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "id_context,hex,\"37cbf3210017a2d3\"\n" - "sender_id,hex,\"01\"\n" - "recipient_id,hex,\"\"\n"; - static const uint8_t sender_key[] = - { 0xe3, 0x9a, 0x0c, 0x7c, 0x77, 0xb4, 0x3f, 0x03, - 0xb4, 0xb3, 0x9a, 0xb9, 0xa2, 0x68, 0x69, 0x9f }; - static const uint8_t recipient_key[] = - { 0xaf, 0x2a, 0x13, 0x00, 0xa5, 0xe9, 0x57, 0x88, - 0xb3, 0x56, 0x33, 0x6e, 0xee, 0xcd, 0x2b, 0x92 }; - static const uint8_t common_iv[] = - { 0x2c, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1c, - 0x0b, 0x71, 0x81, 0xb8, 0x5e }; - static const uint8_t sender_nonce[] = - { 0x2d, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1d, - 0x0b, 0x71, 0x81, 0xb8, 0x5e }; - static const uint8_t recipient_nonce[] = - { 0x2c, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1c, - 0x0b, 0x71, 0x81, 0xb8, 0x5e }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "id_context,hex,\"37cbf3210017a2d3\"\n" + "sender_id,hex,\"01\"\n" + "recipient_id,hex,\"\"\n"; + static const uint8_t sender_key[] = { + 0xe3, 0x9a, 0x0c, 0x7c, 0x77, 0xb4, 0x3f, 0x03, + 0xb4, 0xb3, 0x9a, 0xb9, 0xa2, 0x68, 0x69, 0x9f + }; + static const uint8_t recipient_key[] = { + 0xaf, 0x2a, 0x13, 0x00, 0xa5, 0xe9, 0x57, 0x88, + 0xb3, 0x56, 0x33, 0x6e, 0xee, 0xcd, 0x2b, 0x92 + }; + static const uint8_t common_iv[] = { + 0x2c, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1c, + 0x0b, 0x71, 0x81, 0xb8, 0x5e + }; + static const uint8_t sender_nonce[] = { + 0x2d, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1d, + 0x0b, 0x71, 0x81, 0xb8, 0x5e + }; + static const uint8_t recipient_nonce[] = { + 0x2c, 0xa5, 0x8f, 0xb8, 0x5f, 0xf1, 0xb8, 0x1c, + 0x0b, 0x71, 0x81, 0xb8, 0x5e + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; cose_encrypt0_t cose[1]; @@ -375,23 +411,26 @@ t_oscore_c_3_2(void) { /* C.4. Test Vector 4: OSCORE Request, Client */ static void t_oscore_c_4(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "sender_id,hex,\"\"\n" - "recipient_id,hex,\"01\"\n"; - static const uint8_t unprotected_coap_request[] = - { 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 }; - static const uint8_t protected_coap_request[] = - { 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, - 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, - 0xb3, 0x82, 0x5e }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "sender_id,hex,\"\"\n" + "recipient_id,hex,\"01\"\n"; + static const uint8_t unprotected_coap_request[] = { + 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 + }; + static const uint8_t protected_coap_request[] = { + 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, + 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, + 0xb3, 0x82, 0x5e + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; int result; @@ -424,7 +463,7 @@ t_oscore_c_4(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(protected_coap_request)); + sizeof(protected_coap_request)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], protected_coap_request, osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); @@ -439,22 +478,25 @@ t_oscore_c_4(void) { /* C.5. Test Vector 5: OSCORE Request, Client */ static void t_oscore_c_5(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "sender_id,hex,\"00\"\n" - "recipient_id,hex,\"01\"\n"; - static const uint8_t unprotected_coap_request[] = - { 0x44, 0x01, 0x71, 0xc3, 0x00, 0x00, 0xb9, 0x32, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 }; - static const uint8_t protected[] = - { 0x44, 0x02, 0x71, 0xc3, 0x00, 0x00, 0xb9, 0x32, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x63, 0x09, 0x14, 0x00, 0xff, 0x4e, - 0xd3, 0x39, 0xa5, 0xa3, 0x79, 0xb0, 0xb8, 0xbc, - 0x73, 0x1f, 0xff, 0xb0 }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "sender_id,hex,\"00\"\n" + "recipient_id,hex,\"01\"\n"; + static const uint8_t unprotected_coap_request[] = { + 0x44, 0x01, 0x71, 0xc3, 0x00, 0x00, 0xb9, 0x32, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 + }; + static const uint8_t protected[] = { + 0x44, 0x02, 0x71, 0xc3, 0x00, 0x00, 0xb9, 0x32, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x63, 0x09, 0x14, 0x00, 0xff, 0x4e, + 0xd3, 0x39, 0xa5, 0xa3, 0x79, 0xb0, 0xb8, 0xbc, + 0x73, 0x1f, 0xff, 0xb0 + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; int result; @@ -488,7 +530,7 @@ t_oscore_c_5(void) { CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == sizeof(protected)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], protected, - osc_pdu->hdr_size + osc_pdu->used_size); + osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); oscore_free_contexts(ctx); @@ -501,25 +543,28 @@ t_oscore_c_5(void) { /* C.6. Test Vector 6: OSCORE Request, Client */ static void t_oscore_c_6(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "id_context,hex,\"37cbf3210017a2d3\"\n" - "sender_id,hex,\"\"\n" - "recipient_id,hex,\"01\"\n"; - static const uint8_t unprotected_coap_request[] = - { 0x44, 0x01, 0x2f, 0x8e, 0xef, 0x9b, 0xbf, 0x7a, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 }; - static const uint8_t protected[] = - { 0x44, 0x02, 0x2f, 0x8e, 0xef, 0x9b, 0xbf, 0x7a, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x6b, 0x19, 0x14, 0x08, 0x37, 0xcb, - 0xf3, 0x21, 0x00, 0x17, 0xa2, 0xd3, 0xff, 0x72, - 0xcd, 0x72, 0x73, 0xfd, 0x33, 0x1a, 0xc4, 0x5c, - 0xff, 0xbe, 0x55, 0xc3 }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "id_context,hex,\"37cbf3210017a2d3\"\n" + "sender_id,hex,\"\"\n" + "recipient_id,hex,\"01\"\n"; + static const uint8_t unprotected_coap_request[] = { + 0x44, 0x01, 0x2f, 0x8e, 0xef, 0x9b, 0xbf, 0x7a, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 + }; + static const uint8_t protected[] = { + 0x44, 0x02, 0x2f, 0x8e, 0xef, 0x9b, 0xbf, 0x7a, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x6b, 0x19, 0x14, 0x08, 0x37, 0xcb, + 0xf3, 0x21, 0x00, 0x17, 0xa2, 0xd3, 0xff, 0x72, + 0xcd, 0x72, 0x73, 0xfd, 0x33, 0x1a, 0xc4, 0x5c, + 0xff, 0xbe, 0x55, 0xc3 + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; int result; @@ -553,7 +598,7 @@ t_oscore_c_6(void) { CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == sizeof(protected)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], protected, - osc_pdu->hdr_size + osc_pdu->used_size); + osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); oscore_free_contexts(ctx); @@ -566,32 +611,37 @@ t_oscore_c_6(void) { /* C.7. Test Vector 7: OSCORE Response, Server */ static void t_oscore_c_7(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "sender_id,hex,\"01\"\n" - "recipient_id,hex,\"\"\n"; - static const uint8_t protected_coap_request[] = - { 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, - 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, - 0xb3, 0x82, 0x5e }; - static const uint8_t unprotected_coap_request[] = - { 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 }; - static const uint8_t unprotected_coap_response[] = - { 0x64, 0x45, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, - 0x6f, 0x72, 0x6c, 0x64, 0x21 }; - static const uint8_t protected_coap_response[] = - { 0x64, 0x44, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x90, 0xff, 0xdb, 0xaa, 0xd1, 0xe9, 0xa7, 0xe7, - 0xb2, 0xa8, 0x13, 0xd3, 0xc3, 0x15, 0x24, 0x37, - 0x83, 0x03, 0xcd, 0xaf, 0xae, 0x11, 0x91, 0x06 }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "sender_id,hex,\"01\"\n" + "recipient_id,hex,\"\"\n"; + static const uint8_t protected_coap_request[] = { + 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, + 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, + 0xb3, 0x82, 0x5e + }; + static const uint8_t unprotected_coap_request[] = { + 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 + }; + static const uint8_t unprotected_coap_response[] = { + 0x64, 0x45, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, + 0x6f, 0x72, 0x6c, 0x64, 0x21 + }; + static const uint8_t protected_coap_response[] = { + 0x64, 0x44, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x90, 0xff, 0xdb, 0xaa, 0xd1, 0xe9, 0xa7, 0xe7, + 0xb2, 0xa8, 0x13, 0xd3, 0xc3, 0x15, 0x24, 0x37, + 0x83, 0x03, 0xcd, 0xaf, 0xae, 0x11, 0x91, 0x06 + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; int result; @@ -633,9 +683,9 @@ t_oscore_c_7(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(unprotected_coap_request)); + sizeof(unprotected_coap_request)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], unprotected_coap_request, - osc_pdu->hdr_size + osc_pdu->used_size); + osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); coap_delete_pdu(osc_pdu); coap_delete_pdu(incoming_pdu); @@ -647,9 +697,9 @@ t_oscore_c_7(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(protected_coap_response)); + sizeof(protected_coap_response)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], protected_coap_response, - osc_pdu->hdr_size + osc_pdu->used_size); + osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); oscore_free_contexts(ctx); @@ -664,32 +714,37 @@ t_oscore_c_7(void) { */ static void t_oscore_c_7_2(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "sender_id,hex,\"\"\n" - "recipient_id,hex,\"01\"\n"; - static const uint8_t unprotected_coap_request[] = - { 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 }; - static const uint8_t protected_coap_request[] = - { 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, - 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, - 0xb3, 0x82, 0x5e }; - static const uint8_t unprotected_coap_response[] = - { 0x64, 0x45, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, - 0x6f, 0x72, 0x6c, 0x64, 0x21 }; - static const uint8_t protected_coap_response[] = - { 0x64, 0x44, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x90, 0xff, 0xdb, 0xaa, 0xd1, 0xe9, 0xa7, 0xe7, - 0xb2, 0xa8, 0x13, 0xd3, 0xc3, 0x15, 0x24, 0x37, - 0x83, 0x03, 0xcd, 0xaf, 0xae, 0x11, 0x91, 0x06 }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "sender_id,hex,\"\"\n" + "recipient_id,hex,\"01\"\n"; + static const uint8_t unprotected_coap_request[] = { + 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 + }; + static const uint8_t protected_coap_request[] = { + 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, + 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, + 0xb3, 0x82, 0x5e + }; + static const uint8_t unprotected_coap_response[] = { + 0x64, 0x45, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, + 0x6f, 0x72, 0x6c, 0x64, 0x21 + }; + static const uint8_t protected_coap_response[] = { + 0x64, 0x44, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x90, 0xff, 0xdb, 0xaa, 0xd1, 0xe9, 0xa7, 0xe7, + 0xb2, 0xa8, 0x13, 0xd3, 0xc3, 0x15, 0x24, 0x37, + 0x83, 0x03, 0xcd, 0xaf, 0xae, 0x11, 0x91, 0x06 + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; int result; @@ -731,7 +786,7 @@ t_oscore_c_7_2(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(protected_coap_request)); + sizeof(protected_coap_request)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], protected_coap_request, osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); @@ -746,7 +801,7 @@ t_oscore_c_7_2(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(unprotected_coap_response)); + sizeof(unprotected_coap_response)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], unprotected_coap_response, osc_pdu->hdr_size + osc_pdu->used_size); @@ -761,33 +816,38 @@ t_oscore_c_7_2(void) { /* C.8. Test Vector 8: OSCORE Response with Partial IV, Server */ static void t_oscore_c_8(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "sender_id,hex,\"01\"\n" - "recipient_id,hex,\"\"\n"; - static const uint8_t protected_coap_request[] = - { 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, - 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, - 0xb3, 0x82, 0x5e }; - static const uint8_t unprotected_coap_request[] = - { 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 }; - static const uint8_t unprotected_coap_response[] = - { 0x64, 0x45, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, - 0x6f, 0x72, 0x6c, 0x64, 0x21 }; - static const uint8_t protected_coap_response[] = - { 0x64, 0x44, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x92, 0x01, 0x00, 0xff, 0x4d, 0x4c, 0x13, 0x66, - 0x93, 0x84, 0xb6, 0x73, 0x54, 0xb2, 0xb6, 0x17, - 0x5f, 0xf4, 0xb8, 0x65, 0x8c, 0x66, 0x6a, 0x6c, - 0xf8, 0x8e }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "sender_id,hex,\"01\"\n" + "recipient_id,hex,\"\"\n"; + static const uint8_t protected_coap_request[] = { + 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, + 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, + 0xb3, 0x82, 0x5e + }; + static const uint8_t unprotected_coap_request[] = { + 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 + }; + static const uint8_t unprotected_coap_response[] = { + 0x64, 0x45, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, + 0x6f, 0x72, 0x6c, 0x64, 0x21 + }; + static const uint8_t protected_coap_response[] = { + 0x64, 0x44, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x92, 0x01, 0x00, 0xff, 0x4d, 0x4c, 0x13, 0x66, + 0x93, 0x84, 0xb6, 0x73, 0x54, 0xb2, 0xb6, 0x17, + 0x5f, 0xf4, 0xb8, 0x65, 0x8c, 0x66, 0x6a, 0x6c, + 0xf8, 0x8e + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; int result; @@ -829,9 +889,9 @@ t_oscore_c_8(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(unprotected_coap_request)); + sizeof(unprotected_coap_request)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], unprotected_coap_request, - osc_pdu->hdr_size + osc_pdu->used_size); + osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); coap_delete_pdu(osc_pdu); coap_delete_pdu(incoming_pdu); @@ -843,9 +903,9 @@ t_oscore_c_8(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(protected_coap_response)); + sizeof(protected_coap_response)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], protected_coap_response, - osc_pdu->hdr_size + osc_pdu->used_size); + osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); oscore_free_contexts(ctx); @@ -860,33 +920,38 @@ t_oscore_c_8(void) { */ static void t_oscore_c_8_2(void) { - static const char conf_data[] = - "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" - "master_salt,hex,\"9e7ca92223786340\"\n" - "sender_id,hex,\"\"\n" - "recipient_id,hex,\"01\"\n"; - static const uint8_t unprotected_coap_request[] = - { 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 }; - static const uint8_t protected_coap_request[] = - { 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, - 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, - 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, - 0xb3, 0x82, 0x5e }; - static const uint8_t unprotected_coap_response[] = - { 0x64, 0x45, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, - 0x6f, 0x72, 0x6c, 0x64, 0x21 }; - static const uint8_t protected_coap_response[] = - { 0x64, 0x44, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, - 0x92, 0x01, 0x00, 0xff, 0x4d, 0x4c, 0x13, 0x66, - 0x93, 0x84, 0xb6, 0x73, 0x54, 0xb2, 0xb6, 0x17, - 0x5f, 0xf4, 0xb8, 0x65, 0x8c, 0x66, 0x6a, 0x6c, - 0xf8, 0x8e }; + static const char conf_data[] = + "master_secret,hex,\"0102030405060708090a0b0c0d0e0f10\"\n" + "master_salt,hex,\"9e7ca92223786340\"\n" + "sender_id,hex,\"\"\n" + "recipient_id,hex,\"01\"\n"; + static const uint8_t unprotected_coap_request[] = { + 0x44, 0x01, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x83, 0x74, 0x76, 0x31 + }; + static const uint8_t protected_coap_request[] = { + 0x44, 0x02, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x39, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f, + 0x73, 0x74, 0x62, 0x09, 0x14, 0xff, 0x61, 0x2f, + 0x10, 0x92, 0xf1, 0x77, 0x6f, 0x1c, 0x16, 0x68, + 0xb3, 0x82, 0x5e + }; + static const uint8_t unprotected_coap_response[] = { + 0x64, 0x45, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0xff, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, + 0x6f, 0x72, 0x6c, 0x64, 0x21 + }; + static const uint8_t protected_coap_response[] = { + 0x64, 0x44, 0x5d, 0x1f, 0x00, 0x00, 0x39, 0x74, + 0x92, 0x01, 0x00, 0xff, 0x4d, 0x4c, 0x13, 0x66, + 0x93, 0x84, 0xb6, 0x73, 0x54, 0xb2, 0xb6, 0x17, + 0x5f, 0xf4, 0xb8, 0x65, 0x8c, 0x66, 0x6a, 0x6c, + 0xf8, 0x8e + }; const coap_str_const_t conf = { sizeof(conf_data)-1, - (const uint8_t *)conf_data }; + (const uint8_t *)conf_data + }; coap_context_t ctx[1]; coap_oscore_conf_t *oscore_conf; int result; @@ -927,7 +992,7 @@ t_oscore_c_8_2(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(protected_coap_request)); + sizeof(protected_coap_request)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], protected_coap_request, osc_pdu->hdr_size + osc_pdu->used_size); CU_ASSERT(result == 0); @@ -942,7 +1007,7 @@ t_oscore_c_8_2(void) { result = coap_pdu_encode_header(osc_pdu, session->proto); CU_ASSERT(result != 0); CU_ASSERT(osc_pdu->hdr_size + osc_pdu->used_size == - sizeof(unprotected_coap_response)); + sizeof(unprotected_coap_response)); result = memcmp(&osc_pdu->token[-osc_pdu->hdr_size], unprotected_coap_response, osc_pdu->hdr_size + osc_pdu->used_size); @@ -1003,7 +1068,8 @@ t_init_oscore_tests(void) { */ #pragma GCC diagnostic ignored "-Wunused-function" #endif -static inline void dummy(void) { +static inline void +dummy(void) { } #endif /* COAP_OSCORE_SUPPORT && COAP_SERVER_SUPPORT */ diff --git a/tests/test_pdu.c b/tests/test_pdu.c index 21c8b3be..70753c20 100644 --- a/tests/test_pdu.c +++ b/tests/test_pdu.c @@ -68,7 +68,8 @@ static void t_parse_pdu4(void) { /* illegal token length (token only 8 bytes) */ uint8_t teststr[] = { 0x59, 0x69, 0x12, 0x34, - 't', 'o', 'k', 'e', 'n', '1', '2', '3' }; + 't', 'o', 'k', 'e', 'n', '1', '2', '3' + }; int result; result = coap_pdu_parse(COAP_PROTO_UDP, teststr, sizeof(teststr), pdu); @@ -85,8 +86,8 @@ static void t_parse_pdu5(void) { /* PDU with options */ uint8_t teststr[] = { 0x55, 0x73, 0x12, 0x34, 't', 'o', 'k', 'e', - 'n', 0x00, 0xc1, 0x00 - }; + 'n', 0x00, 0xc1, 0x00 + }; int result; result = coap_pdu_parse(COAP_PROTO_UDP, teststr, sizeof(teststr), pdu); @@ -107,8 +108,8 @@ static void t_parse_pdu6(void) { /* PDU with options that exceed the PDU */ uint8_t teststr[] = { 0x55, 0x73, 0x12, 0x34, 't', 'o', 'k', 'e', - 'n', 0x00, 0xc1, 0x00, 0xae, 0xf0, 0x03 - }; + 'n', 0x00, 0xc1, 0x00, 0xae, 0xf0, 0x03 + }; int result; result = coap_pdu_parse(COAP_PROTO_UDP, teststr, sizeof(teststr), pdu); @@ -119,9 +120,9 @@ static void t_parse_pdu7(void) { /* PDU with options and payload */ uint8_t teststr[] = { 0x55, 0x73, 0x12, 0x34, 't', 'o', 'k', 'e', - 'n', 0x00, 0xc1, 0x00, 0xff, 'p', 'a', 'y', - 'l', 'o', 'a', 'd' - }; + 'n', 0x00, 0xc1, 0x00, 0xff, 'p', 'a', 'y', + 'l', 'o', 'a', 'd' + }; int result; result = coap_pdu_parse(COAP_PROTO_UDP, teststr, sizeof(teststr), pdu); @@ -144,9 +145,9 @@ static void t_parse_pdu8(void) { /* PDU without options but with payload */ uint8_t teststr[] = { 0x50, 0x73, 0x12, 0x34, - 0xff, 'p', 'a', 'y', 'l', 'o', 'a', - 'd' - }; + 0xff, 'p', 'a', 'y', 'l', 'o', 'a', + 'd' + }; int result; result = coap_pdu_parse(COAP_PROTO_UDP, teststr, sizeof(teststr), pdu); @@ -178,8 +179,8 @@ static void t_parse_pdu10(void) { /* PDU without payload but with options and payload start marker */ uint8_t teststr[] = { 0x53, 0x73, 0x12, 0x34, 't', 'o', 'k', - 0x31, 'a', 0xc1, 0x00, 0xff - }; + 0x31, 'a', 0xc1, 0x00, 0xff + }; int result; result = coap_pdu_parse(COAP_PROTO_UDP, teststr, sizeof(teststr), pdu); @@ -221,8 +222,8 @@ static void t_parse_pdu13(void) { /* RST with content */ uint8_t teststr[] = { 0x70, 0x00, 0x12, 0x34, - 0xff, 'c', 'o', 'n', 't', 'e', 'n', 't' - }; + 0xff, 'c', 'o', 'n', 't', 'e', 'n', 't' + }; int result; result = coap_pdu_parse(COAP_PROTO_UDP, teststr, sizeof(teststr), pdu); @@ -233,8 +234,8 @@ static void t_parse_pdu14(void) { /* ACK with content */ uint8_t teststr[] = { 0x60, 0x00, 0x12, 0x34, - 0xff, 'c', 'o', 'n', 't', 'e', 'n', 't' - }; + 0xff, 'c', 'o', 'n', 't', 'e', 'n', 't' + }; int result; result = coap_pdu_parse(COAP_PROTO_UDP, teststr, sizeof(teststr), pdu); @@ -251,23 +252,24 @@ static void t_parse_pdu15(void) { int result; uint8_t teststr[] = { - 64, 91, 91, 91, 139, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 91, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 1, 0, 0, 0, - 0, 0, 0, 0, 224, 192, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 228, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, - 91, 91, 91, 91, 91, 91, 91, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 1, 0, 0, 0, 0, 0, 0, 0, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224}; + 64, 91, 91, 91, 139, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 91, 91, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 1, 0, 0, 0, + 0, 0, 0, 0, 224, 192, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, 228, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, 224, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 91, 91, 91, 91, 91, 91, 224, 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 1, 0, 0, 0, 0, 0, 0, 0, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224 + }; coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ @@ -277,8 +279,8 @@ t_parse_pdu15(void) { CU_ASSERT(result == 0); } -static void log_handler(coap_log_t level, const char *message) -{ +static void +log_handler(coap_log_t level, const char *message) { (void)level; (void)message; } @@ -389,12 +391,12 @@ static void t_encode_pdu4(void) { /* PDU with options */ uint8_t teststr[] = { 0x60, 0x99, 0x12, 0x34, 0x3d, 0x05, 0x66, 0x61, - 0x6e, 0x63, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, - 0x2e, 0x63, 0x6f, 0x61, 0x70, 0x2e, 0x6d, 0x65, - 0x84, 0x70, 0x61, 0x74, 0x68, 0x00, 0xe8, 0x1e, - 0x28, 0x66, 0x61, 0x6e, 0x63, 0x79, 0x6f, 0x70, - 0x74 - }; + 0x6e, 0x63, 0x79, 0x70, 0x72, 0x6f, 0x78, 0x79, + 0x2e, 0x63, 0x6f, 0x61, 0x70, 0x2e, 0x6d, 0x65, + 0x84, 0x70, 0x61, 0x74, 0x68, 0x00, 0xe8, 0x1e, + 0x28, 0x66, 0x61, 0x6e, 0x63, 0x79, 0x6f, 0x70, + 0x74 + }; int result; coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ @@ -406,7 +408,7 @@ t_encode_pdu4(void) { CU_ASSERT(pdu->used_size == 0); result = coap_add_option(pdu, COAP_OPTION_URI_HOST, - 18, (const uint8_t *)"fancyproxy.coap.me"); + 18, (const uint8_t *)"fancyproxy.coap.me"); CU_ASSERT(result == 20); CU_ASSERT(pdu->max_opt == 3); @@ -443,9 +445,9 @@ static void t_encode_pdu5(void) { /* PDU with token and options */ uint8_t teststr[] = { 0x68, 0x84, 0x12, 0x34, '1', '2', '3', '4', - '5', '6', '7', '8', 0x18, 0x41, 0x42, 0x43, - 0x44, 0x45, 0x46, 0x47, 0x48, 0xd1, 0x03, 0x12 - }; + '5', '6', '7', '8', 0x18, 0x41, 0x42, 0x43, + 0x44, 0x45, 0x46, 0x47, 0x48, 0xd1, 0x03, 0x12 + }; int result; coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ @@ -484,8 +486,8 @@ static void t_encode_pdu6(void) { /* PDU with data */ uint8_t teststr[] = { 0x50, 0x02, 0x12, 0x34, 0xff, '1', '2', '3', - '4', '5', '6', '7', '8' - }; + '4', '5', '6', '7', '8' + }; coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ pdu->type = COAP_MESSAGE_NON; @@ -556,11 +558,11 @@ static void t_encode_pdu9(void) { /* PDU with options and data */ uint8_t teststr[] = { 0x60, 0x44, 0x12, 0x34, 0x48, 's', 'o', 'm', - 'e', 'e', 't', 'a', 'g', 0x10, 0xdd, 0x11, - 0x04, 's', 'o', 'm', 'e', 'r', 'a', 't', - 'h', 'e', 'r', 'l', 'o', 'n', 'g', 'u', - 'r', 'i', 0xff, 'd', 'a', 't', 'a' - }; + 'e', 'e', 't', 'a', 'g', 0x10, 0xdd, 0x11, + 0x04, 's', 'o', 'm', 'e', 'r', 'a', 't', + 'h', 'e', 'r', 'l', 'o', 'n', 'g', 'u', + 'r', 'i', 0xff, 'd', 'a', 't', 'a' + }; int result; coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ @@ -607,42 +609,42 @@ static void t_encode_pdu10(void) { /* PDU with token, options and data */ uint8_t teststr[] = { 0x62, 0x44, 0x12, 0x34, 0x00, 0x00, 0x8d, 0xf2, - 'c', 'o', 'a', 'p', ':', '/', '/', 'e', - 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', - 'o', 'm', '/', '1', '2', '3', '4', '5', - '/', '%', '3', 'F', 'x', 'y', 'z', '/', - '3', '0', '4', '8', '2', '3', '4', '2', - '3', '4', '/', '2', '3', '4', '0', '2', - '3', '4', '8', '2', '3', '4', '/', '2', - '3', '9', '0', '8', '4', '2', '3', '4', - '-', '2', '3', '/', '%', 'A', 'B', '%', - '3', '0', '%', 'a', 'f', '/', '+', '1', - '2', '3', '/', 'h', 'f', 'k', 's', 'd', - 'h', '/', '2', '3', '4', '8', '0', '-', - '2', '3', '4', '-', '9', '8', '2', '3', - '5', '/', '1', '2', '0', '4', '/', '2', - '4', '3', '5', '4', '6', '3', '4', '5', - '3', '4', '5', '2', '4', '3', '/', '0', - '1', '9', '8', 's', 'd', 'n', '3', '-', - 'a', '-', '3', '/', '/', '/', 'a', 'f', - 'f', '0', '9', '3', '4', '/', '9', '7', - 'u', '2', '1', '4', '1', '/', '0', '0', - '0', '2', '/', '3', '9', '3', '2', '4', - '2', '3', '5', '3', '2', '/', '5', '6', - '2', '3', '4', '0', '2', '3', '/', '-', - '-', '-', '-', '/', '=', '1', '2', '3', - '4', '=', '/', '0', '9', '8', '1', '4', - '1', '-', '9', '5', '6', '4', '6', '4', - '3', '/', '2', '1', '9', '7', '0', '-', - '-', '-', '-', '-', '/', '8', '2', '3', - '6', '4', '9', '2', '3', '4', '7', '2', - 'w', 'e', 'r', 'e', 'r', 'e', 'w', 'r', - '0', '-', '9', '2', '1', '-', '3', '9', - '1', '2', '3', '-', '3', '4', '/', 0x0d, - 0x01, '/', '/', '4', '9', '2', '4', '0', - '3', '-', '-', '0', '9', '8', '/', 0xc1, - '*', 0xff, 'd', 'a', 't', 'a' - }; + 'c', 'o', 'a', 'p', ':', '/', '/', 'e', + 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', + 'o', 'm', '/', '1', '2', '3', '4', '5', + '/', '%', '3', 'F', 'x', 'y', 'z', '/', + '3', '0', '4', '8', '2', '3', '4', '2', + '3', '4', '/', '2', '3', '4', '0', '2', + '3', '4', '8', '2', '3', '4', '/', '2', + '3', '9', '0', '8', '4', '2', '3', '4', + '-', '2', '3', '/', '%', 'A', 'B', '%', + '3', '0', '%', 'a', 'f', '/', '+', '1', + '2', '3', '/', 'h', 'f', 'k', 's', 'd', + 'h', '/', '2', '3', '4', '8', '0', '-', + '2', '3', '4', '-', '9', '8', '2', '3', + '5', '/', '1', '2', '0', '4', '/', '2', + '4', '3', '5', '4', '6', '3', '4', '5', + '3', '4', '5', '2', '4', '3', '/', '0', + '1', '9', '8', 's', 'd', 'n', '3', '-', + 'a', '-', '3', '/', '/', '/', 'a', 'f', + 'f', '0', '9', '3', '4', '/', '9', '7', + 'u', '2', '1', '4', '1', '/', '0', '0', + '0', '2', '/', '3', '9', '3', '2', '4', + '2', '3', '5', '3', '2', '/', '5', '6', + '2', '3', '4', '0', '2', '3', '/', '-', + '-', '-', '-', '/', '=', '1', '2', '3', + '4', '=', '/', '0', '9', '8', '1', '4', + '1', '-', '9', '5', '6', '4', '6', '4', + '3', '/', '2', '1', '9', '7', '0', '-', + '-', '-', '-', '-', '/', '8', '2', '3', + '6', '4', '9', '2', '3', '4', '7', '2', + 'w', 'e', 'r', 'e', 'r', 'e', 'w', 'r', + '0', '-', '9', '2', '1', '-', '3', '9', + '1', '2', '3', '-', '3', '4', '/', 0x0d, + 0x01, '/', '/', '4', '9', '2', '4', '0', + '3', '-', '-', '0', '9', '8', '/', 0xc1, + '*', 0xff, 'd', 'a', 't', 'a' + }; int result; coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ @@ -657,7 +659,8 @@ t_encode_pdu10(void) { CU_ASSERT(result > 0); result = coap_add_option(pdu, COAP_OPTION_LOCATION_PATH, 255, - (const uint8_t *)"coap://example.com/12345/%3Fxyz/3048234234/23402348234/239084234-23/%AB%30%af/+123/hfksdh/23480-234-98235/1204/243546345345243/0198sdn3-a-3///aff0934/97u2141/0002/3932423532/56234023/----/=1234=/098141-9564643/21970-----/82364923472wererewr0-921-39123-34/"); + (const uint8_t *) + "coap://example.com/12345/%3Fxyz/3048234234/23402348234/239084234-23/%AB%30%af/+123/hfksdh/23480-234-98235/1204/243546345345243/0198sdn3-a-3///aff0934/97u2141/0002/3932423532/56234023/----/=1234=/098141-9564643/21970-----/82364923472wererewr0-921-39123-34/"); CU_ASSERT(result == 257); CU_ASSERT(pdu->max_opt == 8); @@ -727,7 +730,7 @@ t_encode_pdu12(void) { for (n = 0; n < (int)sizeof(opt_num); n++) { coap_insert_optlist(&optlist, coap_new_optlist(opt_num[n], - sizeof(opt_val[n]), &opt_val[n])); + sizeof(opt_val[n]), &opt_val[n])); } coap_add_optlist_pdu(pdu, &optlist); @@ -762,7 +765,7 @@ t_encode_pdu13(void) { for (n = 0; n < (int)sizeof(opt_num); n++) { coap_insert_optlist(&optlist, coap_new_optlist(opt_num[n], - sizeof(opt_val[n]), &opt_val[n])); + sizeof(opt_val[n]), &opt_val[n])); } coap_add_optlist_pdu(pdu, &optlist); @@ -797,7 +800,7 @@ t_encode_pdu14(void) { for (n = 0; n < (int)sizeof(opt_num); n++) { coap_insert_optlist(&optlist, coap_new_optlist(opt_num[n], - sizeof(opt_val[n]), &opt_val[n])); + sizeof(opt_val[n]), &opt_val[n])); } coap_add_optlist_pdu(pdu, &optlist); @@ -833,7 +836,7 @@ t_encode_pdu15(void) { for (n = 0; n < (sizeof(opt_num)/sizeof(opt_num[0])); n++) { coap_insert_option(pdu, opt_num[n], - sizeof(opt_val[n]), &opt_val[n]); + sizeof(opt_val[n]), &opt_val[n]); } /* Check options in pdu are in right order */ @@ -858,13 +861,17 @@ t_encode_pdu16(void) { uint8_t opt_val[] = { 53, 51, 50 }; uint8_t data[] = { 'd', 'a', 't', 'a' }; uint8_t data1[] = { 0x71, 0x32, 0x31, 0x33, 0xe1, 0x00, 0x15, 0x35, - 0xff, 0x64, 0x61, 0x74, 0x61 }; + 0xff, 0x64, 0x61, 0x74, 0x61 + }; uint8_t data2[] = { 0x71, 0x32, 0x33, 0x01, 0x23, 0x45, 0xe1, 0x00, - 0x15, 0x35, 0xff, 0x64, 0x61, 0x74, 0x61 }; + 0x15, 0x35, 0xff, 0x64, 0x61, 0x74, 0x61 + }; uint8_t data3[] = { 0x70, 0x31, 0x33, 0xe1, 0x00, 0x15, 0x35, 0xff, - 0x64, 0x61, 0x74, 0x61 }; + 0x64, 0x61, 0x74, 0x61 + }; uint8_t data4[] = { 0x71, 0x32, 0x31, 0x33, 0xe4, 0x00, 0x15, 0x06, - 0x54, 0x32, 0x10, 0xff, 0x64, 0x61, 0x74, 0x61 }; + 0x54, 0x32, 0x10, 0xff, 0x64, 0x61, 0x74, 0x61 + }; int new_val; unsigned char buf[4]; @@ -874,7 +881,7 @@ t_encode_pdu16(void) { for (n = 0; n < (sizeof(opt_num)/sizeof(opt_num[0])); n++) { coap_add_option(pdu, opt_num[n], - sizeof(opt_val[n]), &opt_val[n]); + sizeof(opt_val[n]), &opt_val[n]); } coap_add_data(pdu, sizeof(data), data); CU_ASSERT(memcmp(pdu->token, data1, pdu->used_size) == 0); @@ -918,12 +925,15 @@ t_encode_pdu17(void) { uint16_t opt_num[] = { 300, 10, 7 }; uint8_t opt_val[] = { 53, 51, 50 }; uint8_t data1[] = { 0x74, 0x71, 0x32, 0x31, 0x33, 0xe1, 0x00, 0x15, - 0x35 }; + 0x35 + }; uint8_t data2[] = { 0x74, 0x71, 0x32, 0x33, 0x01, 0x23, 0x45, 0xe1, - 0x00, 0x15, 0x35 }; + 0x00, 0x15, 0x35 + }; uint8_t data3[] = { 0x74, 0x70, 0x31, 0x33, 0xe1, 0x00, 0x15, 0x35 }; uint8_t data4[] = { 0x74, 0x71, 0x32, 0x31, 0x33, 0xe4, 0x00, 0x15, - 0x06, 0x54, 0x32, 0x10 }; + 0x06, 0x54, 0x32, 0x10 + }; int new_val; unsigned char buf[4]; @@ -934,7 +944,7 @@ t_encode_pdu17(void) { coap_add_token(pdu, sizeof(token), token); for (n = 0; n < (sizeof(opt_num)/sizeof(opt_num[0])); n++) { coap_add_option(pdu, opt_num[n], - sizeof(opt_val[n]), &opt_val[n]); + sizeof(opt_val[n]), &opt_val[n]); } CU_ASSERT(memcmp(pdu->token, data1, pdu->used_size) == 0); /* Now update an option in the middle */ @@ -973,42 +983,42 @@ static void t_encode_pdu18(void) { /* PDU with token, options and data */ uint8_t teststr[] = { 0x62, 0x44, 0x12, 0x34, 0x00, 0x00, 0x8d, 0xf2, - 'c', 'o', 'a', 'p', ':', '/', '/', 'e', - 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', - 'o', 'm', '/', '1', '2', '3', '4', '5', - '/', '%', '3', 'F', 'x', 'y', 'z', '/', - '3', '0', '4', '8', '2', '3', '4', '2', - '3', '4', '/', '2', '3', '4', '0', '2', - '3', '4', '8', '2', '3', '4', '/', '2', - '3', '9', '0', '8', '4', '2', '3', '4', - '-', '2', '3', '/', '%', 'A', 'B', '%', - '3', '0', '%', 'a', 'f', '/', '+', '1', - '2', '3', '/', 'h', 'f', 'k', 's', 'd', - 'h', '/', '2', '3', '4', '8', '0', '-', - '2', '3', '4', '-', '9', '8', '2', '3', - '5', '/', '1', '2', '0', '4', '/', '2', - '4', '3', '5', '4', '6', '3', '4', '5', - '3', '4', '5', '2', '4', '3', '/', '0', - '1', '9', '8', 's', 'd', 'n', '3', '-', - 'a', '-', '3', '/', '/', '/', 'a', 'f', - 'f', '0', '9', '3', '4', '/', '9', '7', - 'u', '2', '1', '4', '1', '/', '0', '0', - '0', '2', '/', '3', '9', '3', '2', '4', - '2', '3', '5', '3', '2', '/', '5', '6', - '2', '3', '4', '0', '2', '3', '/', '-', - '-', '-', '-', '/', '=', '1', '2', '3', - '4', '=', '/', '0', '9', '8', '1', '4', - '1', '-', '9', '5', '6', '4', '6', '4', - '3', '/', '2', '1', '9', '7', '0', '-', - '-', '-', '-', '-', '/', '8', '2', '3', - '6', '4', '9', '2', '3', '4', '7', '2', - 'w', 'e', 'r', 'e', 'r', 'e', 'w', 'r', - '0', '-', '9', '2', '1', '-', '3', '9', - '1', '2', '3', '-', '3', '4', '/', 0x0d, - 0x01, '/', '/', '4', '9', '2', '4', '0', - '3', '-', '-', '0', '9', '8', '/', 0xc1, - '*', 0xff, 'd', 'a', 't', 'a' - }; + 'c', 'o', 'a', 'p', ':', '/', '/', 'e', + 'x', 'a', 'm', 'p', 'l', 'e', '.', 'c', + 'o', 'm', '/', '1', '2', '3', '4', '5', + '/', '%', '3', 'F', 'x', 'y', 'z', '/', + '3', '0', '4', '8', '2', '3', '4', '2', + '3', '4', '/', '2', '3', '4', '0', '2', + '3', '4', '8', '2', '3', '4', '/', '2', + '3', '9', '0', '8', '4', '2', '3', '4', + '-', '2', '3', '/', '%', 'A', 'B', '%', + '3', '0', '%', 'a', 'f', '/', '+', '1', + '2', '3', '/', 'h', 'f', 'k', 's', 'd', + 'h', '/', '2', '3', '4', '8', '0', '-', + '2', '3', '4', '-', '9', '8', '2', '3', + '5', '/', '1', '2', '0', '4', '/', '2', + '4', '3', '5', '4', '6', '3', '4', '5', + '3', '4', '5', '2', '4', '3', '/', '0', + '1', '9', '8', 's', 'd', 'n', '3', '-', + 'a', '-', '3', '/', '/', '/', 'a', 'f', + 'f', '0', '9', '3', '4', '/', '9', '7', + 'u', '2', '1', '4', '1', '/', '0', '0', + '0', '2', '/', '3', '9', '3', '2', '4', + '2', '3', '5', '3', '2', '/', '5', '6', + '2', '3', '4', '0', '2', '3', '/', '-', + '-', '-', '-', '/', '=', '1', '2', '3', + '4', '=', '/', '0', '9', '8', '1', '4', + '1', '-', '9', '5', '6', '4', '6', '4', + '3', '/', '2', '1', '9', '7', '0', '-', + '-', '-', '-', '-', '/', '8', '2', '3', + '6', '4', '9', '2', '3', '4', '7', '2', + 'w', 'e', 'r', 'e', 'r', 'e', 'w', 'r', + '0', '-', '9', '2', '1', '-', '3', '9', + '1', '2', '3', '-', '3', '4', '/', 0x0d, + 0x01, '/', '/', '4', '9', '2', '4', '0', + '3', '-', '-', '0', '9', '8', '/', 0xc1, + '*', 0xff, 'd', 'a', 't', 'a' + }; int result; coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ @@ -1023,7 +1033,8 @@ t_encode_pdu18(void) { CU_ASSERT(result > 0); result = coap_add_option(pdu, COAP_OPTION_LOCATION_PATH, 255, - (const uint8_t *)"coap://example.com/12345/%3Fxyz/3048234234/23402348234/239084234-23/%AB%30%af/+123/hfksdh/23480-234-98235/1204/243546345345243/0198sdn3-a-3///aff0934/97u2141/0002/3932423532/56234023/----/=1234=/098141-9564643/21970-----/82364923472wererewr0-921-39123-34/"); + (const uint8_t *) + "coap://example.com/12345/%3Fxyz/3048234234/23402348234/239084234-23/%AB%30%af/+123/hfksdh/23480-234-98235/1204/243546345345243/0198sdn3-a-3///aff0934/97u2141/0002/3932423532/56234023/----/=1234=/098141-9564643/21970-----/82364923472wererewr0-921-39123-34/"); CU_ASSERT(result == 257); CU_ASSERT(pdu->max_opt == 8); @@ -1063,9 +1074,11 @@ t_encode_pdu19(void) { uint16_t opt_num[] = { 300, 7, 21, 25 }; uint8_t opt_val[] = { 54, 50, 52, 53 }; uint8_t data1[] = { 0x74, 0x71, 0x32, 0xd1, 0x01, 0x34, 0x41, 0x35, - 0xe1, 0x00, 0x06, 0x36 }; + 0xe1, 0x00, 0x06, 0x36 + }; uint8_t data2[] = { 0x74, 0x71, 0x32, 0xd1, 0x05, 0x35, 0xe1, 0x00, - 0x06, 0x36 }; + 0x06, 0x36 + }; uint8_t data3[] = { 0x74, 0xd1, 0x0c, 0x35, 0xe1, 0x00, 0x06, 0x36 }; uint8_t data4[] = { 0x74, 0xd1, 0x0c, 0x35 }; uint8_t data5[] = { 0x74 }; @@ -1080,7 +1093,7 @@ t_encode_pdu19(void) { coap_add_token(pdu, sizeof(token), token); for (n = 0; n < (sizeof(opt_num)/sizeof(opt_num[0])); n++) { coap_add_option(pdu, opt_num[n], - sizeof(opt_val[n]), &opt_val[n]); + sizeof(opt_val[n]), &opt_val[n]); } CU_ASSERT(memcmp(pdu->token, data1, pdu->used_size) == 0); @@ -1117,16 +1130,21 @@ t_encode_pdu20(void) { uint8_t data[] = { 'd', 'a', 't', 'a' }; uint8_t data1[] = { 0x74, 0x71, 0x32, 0xd1, 0x01, 0x34, 0x41, 0x35, 0xe1, 0x00, 0x06, 0x36, 0xff, 0x64, 0x61, 0x74, - 0x61 }; + 0x61 + }; uint8_t data2[] = { 0x74, 0x71, 0x32, 0xd1, 0x05, 0x35, 0xe1, 0x00, - 0x06, 0x36, 0xff, 0x64, 0x61, 0x74, 0x61 }; + 0x06, 0x36, 0xff, 0x64, 0x61, 0x74, 0x61 + }; uint8_t data3[] = { 0x74, 0xd1, 0x0c, 0x35, 0xe1, 0x00, 0x06, 0x36, - 0xff, 0x64, 0x61, 0x74, 0x61 }; + 0xff, 0x64, 0x61, 0x74, 0x61 + }; uint8_t data4[] = { 0x74, 0xd1, 0x0c, 0x35, 0xff, 0x64, 0x61, 0x74, - 0x61 }; + 0x61 + }; uint8_t data5[] = { 0x74, 0xff, 0x64, 0x61, 0x74, 0x61 }; uint8_t data6[] = { 0x74, 0xd1, 0x0c, 0x0a, 0xff, 0x64, 0x61, 0x74, - 0x61 }; + 0x61 + }; int new_val; unsigned char buf[4]; @@ -1137,7 +1155,7 @@ t_encode_pdu20(void) { coap_add_token(pdu, sizeof(token), token); for (n = 0; n < (sizeof(opt_num)/sizeof(opt_num[0])); n++) { coap_add_option(pdu, opt_num[n], - sizeof(opt_val[n]), &opt_val[n]); + sizeof(opt_val[n]), &opt_val[n]); } coap_add_data(pdu, sizeof(data), data); CU_ASSERT(memcmp(pdu->token, data1, pdu->used_size) == 0); @@ -1176,13 +1194,16 @@ t_encode_pdu21(void) { uint8_t data[] = { 'd', 'a', 't', 'a' }; uint8_t data1[] = { 0x74, 0x71, 0x32, 0x31, 0x33, 0xb1, 0x34, 0x41, 0x35, 0xe1, 0x00, 0x06, 0x36, 0xff, 0x64, 0x61, - 0x74, 0x61 }; + 0x74, 0x61 + }; uint8_t data2[] = { 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x71, 0x32, 0x31, 0x33, 0xb1, 0x34, 0x41, 0x35, 0xe1, 0x00, 0x06, - 0x36, 0xff, 0x64, 0x61, 0x74, 0x61 }; + 0x36, 0xff, 0x64, 0x61, 0x74, 0x61 + }; uint8_t data3[] = { 0x71, 0x32, 0x31, 0x33, 0xb1, 0x34, 0x41, 0x35, 0xe1, 0x00, 0x06, 0x36, 0xff, 0x64, 0x61, 0x74, - 0x61 }; + 0x61 + }; coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ @@ -1191,7 +1212,7 @@ t_encode_pdu21(void) { coap_add_token(pdu, sizeof(token), token); for (n = 0; n < (sizeof(opt_num)/sizeof(opt_num[0])); n++) { coap_add_option(pdu, opt_num[n], - sizeof(opt_val[n]), &opt_val[n]); + sizeof(opt_val[n]), &opt_val[n]); } coap_add_data(pdu, sizeof(data), data); CU_ASSERT(memcmp(pdu->token, data1, pdu->used_size) == 0); @@ -1218,18 +1239,26 @@ t_encode_pdu22(void) { uint16_t opt_num[] = { 28, 28, 28, 28 }; uint32_t opt_val[] = { 0x1, 0x100, 0x10000, 0x1000000 }; uint8_t data1[][8] = { - { 0x74, 0xd1, 0x0f, 0x01 }, - { 0x74, 0xd2, 0x0f, 0x01, 0x00 }, - { 0x74, 0xd3, 0x0f, 0x01, 0x00, 0x00 }, - { 0x74, 0xd4, 0x0f, 0x01, 0x00, 0x00, 0x00 }}; + { 0x74, 0xd1, 0x0f, 0x01 }, + { 0x74, 0xd2, 0x0f, 0x01, 0x00 }, + { 0x74, 0xd3, 0x0f, 0x01, 0x00, 0x00 }, + { 0x74, 0xd4, 0x0f, 0x01, 0x00, 0x00, 0x00 } + }; uint8_t data2[][16] = { - { 0x74, 0xd3, 0x0a, 0xff, 0xff, 0xf6, 0x51, 0x01 }, - { 0x74, 0xd3, 0x0a, 0xff, 0xff, 0xf6, 0x52, 0x01, - 0x00 }, - { 0x74, 0xd3, 0x0a, 0xff, 0xff, 0xf6, 0x53, 0x01, - 0x00, 0x00 }, - { 0x74, 0xd3, 0x0a, 0xff, 0xff, 0xf6, 0x54, 0x01, - 0x00, 0x00, 0x00 }}; + { 0x74, 0xd3, 0x0a, 0xff, 0xff, 0xf6, 0x51, 0x01 }, + { + 0x74, 0xd3, 0x0a, 0xff, 0xff, 0xf6, 0x52, 0x01, + 0x00 + }, + { + 0x74, 0xd3, 0x0a, 0xff, 0xff, 0xf6, 0x53, 0x01, + 0x00, 0x00 + }, + { + 0x74, 0xd3, 0x0a, 0xff, 0xff, 0xf6, 0x54, 0x01, + 0x00, 0x00, 0x00 + } + }; for (n = 0; n < (sizeof(opt_num)/sizeof(opt_num[0])); n++) { coap_pdu_clear(pdu, pdu->max_size); /* clear PDU */ diff --git a/tests/test_session.c b/tests/test_session.c index 1dc8c06a..b0bd15ae 100644 --- a/tests/test_session.c +++ b/tests/test_session.c @@ -34,7 +34,7 @@ static coap_session_t *session; /* Holds a reference-counted session object */ COAP_STATIC_INLINE int fpeq(const coap_fixed_point_t a, const coap_fixed_point_t b) { return (a.integer_part == b.integer_part) && - (a.fractional_part == b.fractional_part); + (a.fractional_part == b.fractional_part); } static void diff --git a/tests/test_tls.c b/tests/test_tls.c index f359e346..a9fa53e6 100644 --- a/tests/test_tls.c +++ b/tests/test_tls.c @@ -69,7 +69,7 @@ t_tls2(void) { version.version = 0; if (vers) { long int p1, p2 = 0, p3 = 0; - char* endptr; + char *endptr; p1 = strtol(vers, &endptr, 10); if (*endptr == '.') { diff --git a/tests/test_uri.c b/tests/test_uri.c index bc079a03..ac73438b 100644 --- a/tests/test_uri.c +++ b/tests/test_uri.c @@ -239,7 +239,7 @@ t_parse_uri10(void) { static void t_parse_uri11(void) { char teststr[] = - "coap://xn--18j4d.example/%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF"; + "coap://xn--18j4d.example/%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%81%AF"; int result; coap_uri_t uri; unsigned char buf[40]; @@ -349,13 +349,13 @@ t_parse_uri13(void) { CU_ASSERT(uri_path->length == sizeof(COAP_DEFAULT_URI_WELLKNOWN)-1); CU_ASSERT_NSTRING_EQUAL(uri_path->s, COAP_DEFAULT_URI_WELLKNOWN, sizeof(COAP_DEFAULT_URI_WELLKNOWN)-1); - coap_delete_string (uri_path); + coap_delete_string(uri_path); } static void t_parse_uri14(void) { char teststr[] = - "longerthan13lessthan270=0123456789012345678901234567890123456789"; + "longerthan13lessthan270=0123456789012345678901234567890123456789"; int result; /* buf is large enough to hold sizeof(teststr) - 1 bytes content and @@ -378,7 +378,7 @@ t_parse_uri14(void) { static void t_parse_uri15(void) { char teststr[] = - "longerthan13lessthan270=0123456789012345678901234567890123456789"; + "longerthan13lessthan270=0123456789012345678901234567890123456789"; int result; /* buf is too small to hold sizeof(teststr) - 1 bytes content and 2 @@ -394,7 +394,7 @@ t_parse_uri15(void) { static void t_parse_uri16(void) { char teststr[] = - "longerthan13lessthan270=0123456789012345678901234567890123456789"; + "longerthan13lessthan270=0123456789012345678901234567890123456789"; int result; /* buf is too small to hold the option header. */ @@ -409,12 +409,12 @@ t_parse_uri16(void) { static void t_parse_uri17(void) { char teststr[] = - "thisislongerthan269=" - "01234567890123456789012345678901234567890123456789" - "01234567890123456789012345678901234567890123456789" - "01234567890123456789012345678901234567890123456789" - "01234567890123456789012345678901234567890123456789" - "01234567890123456789012345678901234567890123456789"; + "thisislongerthan269=" + "01234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890123456789" + "01234567890123456789012345678901234567890123456789"; int result; /* buf is large enough to hold sizeof(teststr) - 1 bytes content and @@ -453,7 +453,7 @@ t_parse_uri18(void) { /* strings are stored with terminating zero */ CU_ASSERT_NSTRING_EQUAL(uri_path->s, "", 1); #endif - coap_delete_string (uri_path); + coap_delete_string(uri_path); } static void @@ -474,7 +474,7 @@ t_parse_uri19(void) { CU_ASSERT(uri_path->length == 4); CU_ASSERT_NSTRING_EQUAL(uri_path->s, "foo/", 4); - coap_delete_string (uri_path); + coap_delete_string(uri_path); } static void @@ -495,7 +495,7 @@ t_parse_uri20(void) { /* The leading '/' is stripped hence only one '/' remains. */ CU_ASSERT(uri_path->length == 1); CU_ASSERT_NSTRING_EQUAL(uri_path->s, "/", 1); - coap_delete_string (uri_path); + coap_delete_string(uri_path); } static void @@ -516,7 +516,7 @@ t_parse_uri21(void) { /* The leading '/' is stripped hence only one '/' remains. */ CU_ASSERT(uri_path->length == 4); CU_ASSERT_NSTRING_EQUAL(uri_path->s, "/foo", 4); - coap_delete_string (uri_path); + coap_delete_string(uri_path); } static void @@ -538,7 +538,7 @@ t_parse_uri22(void) { CU_ASSERT(uri_path->length == 16); CU_ASSERT_NSTRING_EQUAL(uri_path->s, "-._~!$&'()/*+,;=", 16); - coap_delete_string (uri_path); + coap_delete_string(uri_path); } static void @@ -559,7 +559,7 @@ t_parse_uri23(void) { CU_ASSERT(uri_path->length == 15); CU_ASSERT_NSTRING_EQUAL(uri_path->s, "%25%20%23%5B%5D", 15); - coap_delete_string (uri_path); + coap_delete_string(uri_path); } /* diff --git a/tests/test_wellknown.c b/tests/test_wellknown.c index a559c67b..63ebb8b0 100644 --- a/tests/test_wellknown.c +++ b/tests/test_wellknown.c @@ -67,7 +67,7 @@ t_wellknown1(void) { result = coap_print_link(r, buf, &buflen, &ofs); CU_ASSERT(result == 0); - CU_ASSERT(buflen == sizeof(teststr)); + CU_ASSERT(buflen == sizeof(teststr)); /* offset exceeds buffer */ buflen = sizeof(buf); @@ -159,7 +159,7 @@ t_wellknown3(void) { */ offset = num_resources * (TEST_URI_LEN + 4); result = coap_print_wellknown(ctx, buf, &buflen, offset, NULL); - CU_ASSERT((result & COAP_PRINT_STATUS_ERROR) == 0 ); + CU_ASSERT((result & COAP_PRINT_STATUS_ERROR) == 0); CU_ASSERT(COAP_PRINT_OUTPUT_LENGTH(result) > 0); } @@ -180,7 +180,7 @@ t_wellknown4(void) { CU_ASSERT(query != NULL); memcpy(query->s, "if=one", sizeof("if=one")-1); result = coap_print_wellknown(ctx, buf, &buflen, 0, query); - CU_ASSERT((result & COAP_PRINT_STATUS_ERROR) == 0 ); + CU_ASSERT((result & COAP_PRINT_STATUS_ERROR) == 0); CU_ASSERT(COAP_PRINT_OUTPUT_LENGTH(result) == sizeof(teststr)); CU_ASSERT(buflen == sizeof(teststr)); CU_ASSERT(memcmp(buf, teststr, buflen) == 0);