From d18ae43123fcd7604d1c36a1ec8450dbe6071824 Mon Sep 17 00:00:00 2001 From: Luca Muscariello Date: Thu, 23 Feb 2017 20:44:26 +0100 Subject: Initial commit: ccnxlibs. Change-Id: I1b376527a7dd01a6b9e083a6cb646955902f45c0 Signed-off-by: Luca Muscariello --- .../common/codec/schema_v1/testdata/CMakeLists.txt | 27 +++ .../common/codec/schema_v1/testdata/v1_CPISchema.h | 50 ++++++ .../schema_v1/testdata/v1_ContentObjectSchema.h | 74 +++++++++ .../codec/schema_v1/testdata/v1_InterestSchema.h | 54 ++++++ .../schema_v1/testdata/v1_content_nameA_crc32c.h | 114 +++++++++++++ .../testdata/v1_content_nameA_keyid1_rsasha256.h | 181 +++++++++++++++++++++ .../schema_v1/testdata/v1_content_nameless_nosig.h | 65 ++++++++ .../schema_v1/testdata/v1_content_no_payload.h | 55 +++++++ .../schema_v1/testdata/v1_content_zero_payload.h | 57 +++++++ .../codec/schema_v1/testdata/v1_cpi_add_route.h | 50 ++++++ .../schema_v1/testdata/v1_cpi_add_route_crc32c.h | 78 +++++++++ .../schema_v1/testdata/v1_interest_all_fields.h | 102 ++++++++++++ .../testdata/v1_interest_bad_message_length.h | 57 +++++++ .../testdata/v1_interest_bad_validation_alg.h | 74 +++++++++ .../codec/schema_v1/testdata/v1_interest_nameA.h | 75 +++++++++ .../testdata/v1_interest_nameA_badcrc32c.h | 76 +++++++++ .../schema_v1/testdata/v1_interest_nameA_crc32c.h | 102 ++++++++++++ .../testdata/v1_interest_validation_alg_overrun.h | 74 +++++++++ .../codec/schema_v1/testdata/v1_testrig_truthSet.h | 68 ++++++++ .../schema_v1/testdata/v1_testrig_truthTable.h | 34 ++++ 20 files changed, 1467 insertions(+) create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/CMakeLists.txt create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_CPISchema.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_ContentObjectSchema.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_InterestSchema.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameA_crc32c.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameA_keyid1_rsasha256.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameless_nosig.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_no_payload.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_zero_payload.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_cpi_add_route.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_cpi_add_route_crc32c.h create mode 100755 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_all_fields.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_bad_message_length.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_bad_validation_alg.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA_badcrc32c.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA_crc32c.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_validation_alg_overrun.h create mode 100644 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_testrig_truthSet.h create mode 100755 libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_testrig_truthTable.h (limited to 'libccnx-common/ccnx/common/codec/schema_v1/testdata') diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/CMakeLists.txt b/libccnx-common/ccnx/common/codec/schema_v1/testdata/CMakeLists.txt new file mode 100644 index 00000000..c5c70ce4 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/CMakeLists.txt @@ -0,0 +1,27 @@ +# Enable gcov output for the tests +add_definitions(--coverage) +set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} " --coverage") + +set(TestsExpectedToPass + test_ccnxCodecSchemaV1_CryptoSuite + test_ccnxCodecSchemaV1_FixedHeaderDecoder + test_ccnxCodecSchemaV1_FixedHeaderEncoder + test_ccnxCodecSchemaV1_LinkCodec + test_ccnxCodecSchemaV1_MessageDecoder + test_ccnxCodecSchemaV1_MessageEncoder + test_ccnxCodecSchemaV1_NameCodec + test_ccnxCodecSchemaV1_NameSegmentCodec + test_ccnxCodecSchemaV1_OptionalHeadersDecoder + test_ccnxCodecSchemaV1_OptionalHeadersEncoder + test_ccnxCodecSchemaV1_PacketDecoder + test_ccnxCodecSchemaV1_PacketEncoder + test_ccnxCodecSchemaV1_TlvDictionary + test_ccnxCodecSchemaV1_ValidationDecoder + test_ccnxCodecSchemaV1_ValidationEncoder +) + + +foreach(test ${TestsExpectedToPass}) + AddTest(${test}) +endforeach() + diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_CPISchema.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_CPISchema.h new file mode 100644 index 00000000..70899d13 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_CPISchema.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Defines the truthtable manifest constants used by the version 1 test vectors. + * + */ + +/** + * Schema for Control Plane Interface packets. These packets are a TLV wrapping + * the control JSON. + * + * Example: + * @code + * <#example#> + * @endcode + */ + +#ifndef Libccnx_v1_CPISchema_h +#define Libccnx_v1_CPISchema_h + +#include + +// ----------------------------------------------------- +// these are the array indicies used to store the TlvExtent for the item +typedef enum { + V1_MANIFEST_CPI_PAYLOAD = 0, + V1_MANIFEST_CPI_SIGBITS = 5, // the payload of the signature + V1_MANIFEST_CPI_ValidationAlg = 6, // start of validation algorithm + V1_MANIFEST_CPI_ValidationPayload = 7, // start of validation payload + V1_MANIFEST_CPI_BODYEND = 8 +} V1_ManifestCPIBody; + +typedef enum { + V1_MANIFEST_CPI_HEADEND = 0 +} V1_ManifestCPIHeaders; + +#endif // Libccnx_tlv_CPISchema_h diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_ContentObjectSchema.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_ContentObjectSchema.h new file mode 100644 index 00000000..cb59d937 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_ContentObjectSchema.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is from the version 1 codec. All the test vectors in this directory (e.g. interest_nameA.h) + * are encoded using these constants. These are no longer used for any functional code, only to interpret the test vectors. + * + */ + +#ifndef Libccnx_v1_ContentObjectSchema_h +#define Libccnx_v1_ContentObjectSchema_h + +#include + +#define T_CONTENTOBJECT 0x0002 + +// these are the array indicies used to store the TlvExtent for the item +typedef enum { + // top level entities + V1_MANIFEST_OBJ_NAME = 0, + V1_MANIFEST_OBJ_CONTENTOBJECT = 1, // the top container + V1_MANIFEST_OBJ_NAMEAUTH = 2, + V1_MANIFEST_OBJ_PAYLOADTYPE = 3, + V1_MANIFEST_OBJ_PAYLOAD = 4, + V1_MANIFEST_OBJ_SIGBITS = 5, + + // inside the name authenticator + V1_MANIFEST_OBJ_KEYID = 6, + V1_MANIFEST_OBJ_CRYPTO_SUITE = 7, + V1_MANIFEST_OBJ_KEY = 8, + V1_MANIFEST_OBJ_CERT = 9, + V1_MANIFEST_OBJ_KEYNAME = 10, + V1_MANIFEST_OBJ_KEYNAME_NAME = 11, + V1_MANIFEST_OBJ_KEYNAME_OBJHASH = 12, + + // inside the protocol information + V1_MANIFEST_OBJ_METADATA = 13, + + // inside metadata + V1_MANIFEST_OBJ_OBJ_TYPE = 14, + V1_MANIFEST_OBJ_CREATE_TIME = 15, + V1_MANIFEST_OBJ_EXPIRY_TIME = 16, + + // inside signature block + V1_MANIFEST_OBJ_ValidationPayload = 17, + V1_MANIFEST_OBJ_ENDSEGMENT = 18, + V1_MANIFEST_OBJ_PUBKEY = 19, + + V1_MANIFEST_OBJ_ValidationAlg = 20, + V1_MANIFEST_OBJ_SigningTime = 21, + V1_MANIFEST_OBJ_BODYEND = 22 +} SchemaV1ManifestContentObjectBody; + +typedef enum { + V1_MANIFEST_OBJ_OPTHEAD = 0, + V1_MANIFEST_OBJ_E2EFRAG = 2, + V1_MANIFEST_OBJ_FIXEDHEADER = 3, + V1_MANIFEST_OBJ_RecommendedCacheTime = 4, + V1_MANIFEST_OBJ_HEADEND = 5 +} SchemaV1ManifestContentObjectHeaders; + +#endif // Libccnx_tlv_ContentObjectSchema_h diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_InterestSchema.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_InterestSchema.h new file mode 100644 index 00000000..894b3cc7 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_InterestSchema.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This is from the version 0 codec. All the test vectors in this directory (e.g. interest_nameA.h) + * are encoded using these constants. These are no longer used for any functional code, only to interpret the test vectors. + * + */ + +#ifndef Libccnx_v1_InterestSchema_h +#define Libccnx_v1_InterestSchema_h + +#include + +// ----------------------------------------------------- +// these are the array indicies used to store the TlvExtent for the item +typedef enum { + V1_MANIFEST_INT_INTEREST = 0, // start of Interest body to end + + V1_MANIFEST_INT_NAME = 1, + V1_MANIFEST_INT_KEYID = 2, + V1_MANIFEST_INT_OBJHASH = 3, + V1_MANIFEST_INT_PAYLOAD = 4, + V1_MANIFEST_INT_IPIDM = 5, + + V1_MANIFEST_INT_ValidationAlg = 6, // start of validation algorithm + V1_MANIFEST_INT_ValidationPayload = 7, // start of validation payload + + V1_MANIFEST_INT_BODYEND = 7 +} ScheamV1ManifestInterestBody; + +typedef enum { + V1_MANIFEST_INT_OPTHEAD = 0, // the start of the optional headers + V1_MANIFEST_INT_LIFETIME = 1, + V1_MANIFEST_INT_E2EFRAG = 2, + V1_MANIFEST_INT_HEADEND = 3, +} ScheamV1ManifestInterestHeaders; + + +#define T_INTEREST 0x0001 + +#endif // Libccnx_tlv_InterestSchema_h diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameA_crc32c.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameA_crc32c.h new file mode 100644 index 00000000..e4695849 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameA_crc32c.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file interest_nameA_crc32c.h + * @brief Interest with CRC validation + * + * Ground truth set derived from CRC RevEng http://reveng.sourceforge.net + * e.g. reveng -c -m CRC-32C 313233343536373839 gives the canonical check value 0xe306928e + * + * You can also calcaulate CRC32C online at http://www.zorc.breitbandkatze.de/crc.html using + * CRC polynomial 0x1EDC6F41, init 0xFFFFFFFF, final 0xFFFFFFFF, reverse data bytes (check), + * and reverse CRC result before final XOR (check). + * + * you can get the packet dump from the "write_packets" command. here's the detailed steps. + * The -c size of 4 in steps 4 and 7 are chosen to make it easy to delete the right number of lines. + * there's nothing magic about the "4". + * + * 1) execute ./write_packets + * 2) xxd -r -c 8 v1_content_nameA_crc32c.txt > y + * 3) vim -b y + * 4) :%!xxd -p -c 4 + * 5) Delete the frist 44 bytes (11 lines). The first line should now be: + * 00020015 + * 6) Delete the last 8 bytes + * The last line two lines should be: + * 04000200 + * 00 + * What's left is the part to be signed. + * 7) :%!xxd -r -p -c 4 + * 8) :wq + * 9) dump the file to one long URL-escaped hex string with + * xxd -p -c 256 y | sed 's/[0-9a-f]\{2\}/%&/g' + * 10) Copy the hex string to the website and use the settings specified above (don't use 0x in front + * of any hex strings). Click "compute!" + * 11) The answer should be 2C3CC0Af + * 12) Put the byte array from (11) in the Validation Payload. + * + */ + +#ifndef v1_content_nameA_crc32c_h +#define v1_content_nameA_crc32c_h + +#include +#include + +/** + * A well formed interest with only a name + */ + +__attribute__((unused)) +static uint8_t v1_content_nameA_crc32c[] = { + 0x01, 0x01, 0x00, 85, // ver = 1, type = content object, length = 85 + 0x00, 0x00, 0x00, 44, // HopLimit = 31, reserved = 0, header length = 44 + // ------------------------ + 0x00, 0x04, 0x00, 20, // ContentObject Fragment, length = 20 + 0x12, 0x23, 0x34, 0x45, + 0x56, 0x67, 0x78, 0x89, // fragid 0x1223344556677889 + 0x05, 0xDC, 0x01, 0x00, // MTU 1500, fragcnt 1, fragnum 0 + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, // interest fragment 0x0102030405060708 + // ------------------------ + 0x00, 0x02, 0x00, 8, // Recommended Cache Time + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x6D, 0xDD, 0x00, // 2 hours (0x6DDD00 milli seconds) + // ------------------------ + 0x00, 0x02, 0x00, 21, // type = content object, length = 21 + // ------------------------ + 0x00, 0x00, 0x00, 0x11, // type = name, length = 17 + 0x00, 0x03, 0x00, 0x05, // type = binary, length = 5 + 'h', 'e', 'l', 'l', // "hello" + 'o', + 0xF0, 0x00, 0x00, 0x04, // type = app, length = 4 + 'o', 'u', 'c', 'h', // "ouch" + // ------------------------ + 0x00, 0x03, 0x00, 4, // validation alg, length = 4 + 0x00, 0x02, 0x00, 0x00, // CRC32C + // ------------------------ + 0x00, 0x04, 0x00, 4, // validation payload + 0x2C, 0x3C, 0xC0, 0xAF // 2C3CC0AF +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_content_nameA_crc32c)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_E2EFRAG, .bodyManifest = false, .extent = { 12, 20 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_RecommendedCacheTime, .bodyManifest = false, .extent = { 36, 8 } }, + + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_CONTENTOBJECT, .bodyManifest = true, .extent = { 48, 21 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_NAME, .bodyManifest = true, .extent = { 52, 17 } }, + + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_ValidationAlg, .bodyManifest = true, .extent = { 73, 4 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_SIGBITS, .bodyManifest = true, .extent = { 81, 4 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_content_nameA_crc32c_truthTable TABLEENTRY(v1_content_nameA_crc32c, TLV_ERR_NO_ERROR) + +#define v1_content_nameA_crc32c_URI "lci:/3=hello/0xf000=ouch" + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameA_keyid1_rsasha256.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameA_keyid1_rsasha256.h new file mode 100644 index 00000000..ef37fb5e --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameA_keyid1_rsasha256.h @@ -0,0 +1,181 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file interest_nameA_crc32c.h + * @brief Interest with CRC validation + * + * Signature generated using "openssl sha -sign test_rsa_key.pem -sha256 -binary y > sig", where "y" is + * generated from the "xxd -r" of the message hex dump. You need to manually edit "y" so it only + * contains the parts begin signed. Then use "xxd -i sig" to get the byte array. + * + * you can get the dump from the "write_packets" command. here's the detailed steps: + * + * 1) execute ./write_packets + * 2) xxd -r -c 8 v1_content_nameA_keyid1_rsasha256.txt > y + * 3) vim -b y + * 4) :%!xxd -p -c 16 + * 5) Delete the frist 32 bytes (2 lines). The first line should now be: + * 0002003a000000110002000568656c6c + * 6) Delete the last 132 bytes (9 lines, 8 full lines plus the last 4 byte line) + * The last line in the file should now be: + * 0f3592ae7027fbd2e41e270203010001 + * What's left is the part to be signed. + * 7) :%!xxd -r -p -c 16 + * 8) :wq + * 9) Copy the PEM blocks below and put them in the file "key.pem". Make sure to remove + * any leading whitespace. If you get an error in the next command like + * "53999:error:0906D06C:PEM routines:PEM_read_bio:no start ... 648:Expecting: ANY PRIVATE KEY" then + * you most likely have leading whitespace. Make sure all lines are flush left. + * 10) openssl sha -sign key.pem -sha256 -binary y > sig + * 11) xxd -i sig + * 12) Put the byte array from (11) in the Validation Payload. Verify the length, it should be + * 128 bytes. If not, fixup the length of the ValidatonPayload and the PacketLength. + * + */ + +/* + * -----BEGIN RSA PRIVATE KEY----- + * MIICXAIBAAKBgQCn1pPF8XPGErX6ecXvGIvvqs0EAY+Ddz+xZqFauTkqsj4w+xH8 + * V/yd0S938Kt3rWYsJsibUW9pvyYQBinuy7AsXpEOJEKN5nWgTgRDDD5MBnRnrYTD + * 6PTFlHPEnyWoQga/RRnimBw2oUNNm3EI4YLf4k8qPD0PNZKucCf70uQeJwIDAQAB + * AoGAVOYPA/7aIGSQlu4IOKTDDG3qnM8pSEgG+PbAQgMVrspQ+TfXZj0ftLj++P3N + * zpDw8P6BVUfBQs2FNG/ZwEhaiZVgJAl7cIAxJ9Ac+1oZYSgGyJfb3u9iWvkbMOoj + * 83Inx5yyN+Qmk5zceH4pOC5D5cDAuGGZ740Euv4o2/2O3qECQQDTmWZw021PvEbA + * r18O1YfZGxO3zFCwFXCpnHvtSMbP+MXAG5Gt47wZt4Vx1rX9k78beeCUitwqp3d3 + * ZI+YlUu3AkEAyw5wssQsJty/n2FL8DbJN3UzUhkcaCFYrKz3RtFye9wu+Bw0TxPC + * 3jhFVcynm3nH3ZJN0JsnsPnHXuoQToShEQJATXC51hb6zZC5UDGel348fo9zUvP6 + * n8bo+ZoknL3izSBdtyYf1cUgBUVuGDCdYFWfPn4HXDXJx+6MQWzTRON21wJBAMZL + * U8M/z94jtP3wBjiPR/Dggz2pSBRofDAkuVZvM13BqByjbnHK2oIocY1YTlWGl6fJ + * ODR/UEODqS8HZOVIoAECQANcuvVnqDixSIl2ySZvydQytv4DKTbvE0nYSRroYIlJ + * PTOBPy8ynIUkJwc2E1BsLl7V8gO62a5O0ntTwBMnPSQ= + * -----END RSA PRIVATE KEY----- + * + * -----BEGIN PUBLIC KEY----- + * MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCn1pPF8XPGErX6ecXvGIvvqs0E + * AY+Ddz+xZqFauTkqsj4w+xH8V/yd0S938Kt3rWYsJsibUW9pvyYQBinuy7AsXpEO + * JEKN5nWgTgRDDD5MBnRnrYTD6PTFlHPEnyWoQga/RRnimBw2oUNNm3EI4YLf4k8q + * PD0PNZKucCf70uQeJwIDAQAB + * -----END PUBLIC KEY----- + */ + +#ifndef v1_content_nameA_keyid1_rsasha256_h +#define v1_content_nameA_keyid1_rsasha256_h + +#include +#include + +/** + * A well formed interest with only a name + */ + + +__attribute__((unused)) +static uint8_t v1_content_nameA_keyid1_rsasha256[] = { + 0x01, 0x01, 0x01, 0xB4,// ver = 1, type = content object, length = 436 + 0x00, 0x00, 0x00, 32, // HopLimit = 0, reserved = 0, header length = 32 + // ------------------------ + 0x00, 0x04, 0x00, 20, // ContentObject Fragment, length = 20 + 0x12, 0x23, 0x34, 0x45, + 0x56, 0x67, 0x78, 0x89,// fragid 0x1223344556677889 + 0x05, 0xDC, 0x01, 0x00,// MTU 1500, fragcnt 1, fragnum 0 + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08,// interest fragment 0x0102030405060708 + // ------------------------ + 0x00, 0x02, 0x00, 58, // type = content object, length = 58 + // ------------------------ + 0x00, 0x00, 0x00, 17, // type = name, length = 17 + 0x00, 0x03, 0x00, 0x05,// type = binary, length = 5 + 'h', 'e', 'l', 'l', // "hello" + 'o', + 0xF0, 0x00, 0x00, 0x04,// type = app, length = 4 + 'o', 'u', 'c', 'h', // "ouch" + // ------------------------ + 0x00, 0x05, 0x00, 1, // PayloadType + 1, // type 1 = key + 0x00, 0x06, 0x00, 0x08,// expiry time in msec + 0x00, 0x00, 0x01, 0x43,// 1,388,534,400,000 msec + 0x4B, 0x19, 0x84, 0x00, + 0x00, 0x19, 0x00, 4, // end chunk number + 0x06, 0x05, 0x04, 0x03, + // ------------------------ + 0x00, 0x01, 0x00, 8, // payload, length = 8 + 0x73, 0x75, 0x72, 0x70, + 0x72, 0x69, 0x73, 0x65, + // ------------------------ + 0x00, 0x03, 0x00, 206, // validation alg, length = 206 + 0x00, 0x06, 0x00, 202, // RSA-SHA256, length = 162 + 4 + 32 + 4 = 202 + 0x00, 0x09, 0x00, 32, // type = keyid, length = 32 + 0x5c, 0x23, 0x4c, 0x28, + 0x50, 0xda, 0x20, 0x7b, + 0x88, 0x25, 0x8b, 0xf3, + 0x62, 0x61, 0x96, 0xd8, + 0xf0, 0x60, 0x76, 0x38, + 0xa2, 0xd4, 0xe0, 0xe2, + 0x49, 0xb2, 0xa9, 0xaf, + 0xce, 0xb8, 0x85, 0x59, + 0x00, 0x0B, 0x00, 162, // public key, length = 162 + 0x30, 0x81, 0x9f, 0x30,0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, + 0x0d, 0x01, 0x01, 0x01,0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81, + 0x89, 0x02, 0x81, 0x81,0x00, 0xa7, 0xd6, 0x93, 0xc5, 0xf1, 0x73, 0xc6, + 0x12, 0xb5, 0xfa, 0x79,0xc5, 0xef, 0x18, 0x8b, 0xef, 0xaa, 0xcd, 0x04, + 0x01, 0x8f, 0x83, 0x77,0x3f, 0xb1, 0x66, 0xa1, 0x5a, 0xb9, 0x39, 0x2a, + 0xb2, 0x3e, 0x30, 0xfb,0x11, 0xfc, 0x57, 0xfc, 0x9d, 0xd1, 0x2f, 0x77, + 0xf0, 0xab, 0x77, 0xad,0x66, 0x2c, 0x26, 0xc8, 0x9b, 0x51, 0x6f, 0x69, + 0xbf, 0x26, 0x10, 0x06,0x29, 0xee, 0xcb, 0xb0, 0x2c, 0x5e, 0x91, 0x0e, + 0x24, 0x42, 0x8d, 0xe6,0x75, 0xa0, 0x4e, 0x04, 0x43, 0x0c, 0x3e, 0x4c, + 0x06, 0x74, 0x67, 0xad,0x84, 0xc3, 0xe8, 0xf4, 0xc5, 0x94, 0x73, 0xc4, + 0x9f, 0x25, 0xa8, 0x42,0x06, 0xbf, 0x45, 0x19, 0xe2, 0x98, 0x1c, 0x36, + 0xa1, 0x43, 0x4d, 0x9b,0x71, 0x08, 0xe1, 0x82, 0xdf, 0xe2, 0x4f, 0x2a, + 0x3c, 0x3d, 0x0f, 0x35,0x92, 0xae, 0x70, 0x27, 0xfb, 0xd2, 0xe4, 0x1e, + 0x27, 0x02, 0x03, 0x01,0x00, 0x01, + // ------------------------ + 0x00, 0x04, 0x00, 128, // validation payload, length = 128 + 0x03, 0x46, 0xee, 0xb7,0x30, 0x1c, 0xea, 0x13, 0x0c, 0xce, 0x83, 0x5b, + 0x7b, 0x4f, 0xf5, 0x83,0x37, 0x08, 0x7f, 0xe0, 0xe1, 0xc9, 0x70, 0x09, + 0x5e, 0xc2, 0x1c, 0xd3,0x74, 0xbb, 0xbd, 0x72, 0x35, 0xa4, 0x1b, 0x0f, + 0x3d, 0x04, 0x5e, 0xf7,0xc1, 0xdf, 0xea, 0xc3, 0x50, 0x47, 0x14, 0xf9, + 0xb7, 0xbb, 0x42, 0xf9,0x3e, 0xaa, 0x49, 0xd2, 0x9f, 0xd1, 0xab, 0xf6, + 0xda, 0x32, 0x4a, 0xb1,0xb9, 0x69, 0x91, 0x57, 0x43, 0x5d, 0x06, 0xcf, + 0x1d, 0x9f, 0x7c, 0x28,0xee, 0x35, 0xaa, 0xd0, 0xb2, 0x8d, 0x34, 0x09, + 0xcd, 0xdb, 0x01, 0xf7,0xda, 0xe8, 0x59, 0x98, 0x4e, 0x59, 0xfa, 0x13, + 0xd0, 0xd1, 0x54, 0x8e,0x64, 0x8c, 0xc6, 0xd7, 0x6b, 0xc5, 0x89, 0xeb, + 0x37, 0x8f, 0x53, 0x04,0xba, 0x03, 0x05, 0xb4, 0x67, 0x73, 0xe1, 0x51, + 0x59, 0x12, 0xbc, 0x25,0xaa, 0xa2, 0xc1, 0x18 +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_content_nameA_keyid1_rsasha256)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_E2EFRAG, .bodyManifest = false, .extent = { 12, 20 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_CONTENTOBJECT, .bodyManifest = true, .extent = { 36, 58 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_NAME, .bodyManifest = true, .extent = { 40, 17 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_PAYLOADTYPE, .bodyManifest = true, .extent = { 61, 1 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_EXPIRY_TIME, .bodyManifest = true, .extent = { 66, 8 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_ENDSEGMENT, .bodyManifest = true, .extent = { 78, 4 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_PAYLOAD, .bodyManifest = true, .extent = { 86, 8 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_ValidationAlg, .bodyManifest = true, .extent = { 94, 206 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_KEYID, .bodyManifest = true, .extent = { 106, 32 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_PUBKEY, .bodyManifest = true, .extent = { 142, 162 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_SIGBITS, .bodyManifest = true, .extent = { 308, 128 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_content_nameA_keyid1_rsasha256_truthTable TABLEENTRY(v1_content_nameA_keyid1_rsasha256, TLV_ERR_NO_ERROR) + +#define v1_content_nameA_keyid1_rsasha256_URI "lci:/3=hello/0xf000=ouch" + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameless_nosig.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameless_nosig.h new file mode 100644 index 00000000..f1fc59cb --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_nameless_nosig.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_content_nameless_nosig.h + * @brief A v1 content object without a name + * + */ + +#ifndef v1_content_nameless_nosig_h +#define v1_content_nameless_nosig_h + +#include +#include + +/** + * A well formed nameless V1 Content Object + */ +__attribute__((unused)) +static uint8_t v1_content_nameless_nosig[] = { + 0x01, 0x01, 0x00, 0x31, // ver = 1, type = content object, length = 0x31 + 0x00, 0x00, 0x00, 0x08, // HopLimit = 0, reserved = 0, header length = 8 + // ------------------------ + 0x00, 0x02, 0x00, 37, // type = content object, length = 37 + // ------------------------ + 0x00, 0x05, 0x00, 1, // PayloadType + 1, // type 1 = key + 0x00, 0x06, 0x00, 0x08, // expiry time in msec + 0x00, 0x00, 0x01, 0x43, // 1,388,534,400,000 msec + 0x4B, 0x19, 0x84, 0x00, + 0x00, 0x19, 0x00, 4, // end chunk number + 0x06, 0x05, 0x04, 0x03, + // ------------------------ + 0x00, 0x01, 0x00, 8, // payload, length = 8 + 0x73, 0x75, 0x72, 0x70, + 0x72, 0x69, 0x73, 0x65, +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_content_nameless_nosig)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_CONTENTOBJECT, .bodyManifest = true, .extent = { 12, 37 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_PAYLOADTYPE, .bodyManifest = true, .extent = { 17, 1 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_EXPIRY_TIME, .bodyManifest = true, .extent = { 22, 8 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_ENDSEGMENT, .bodyManifest = true, .extent = { 30, 4 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_PAYLOAD, .bodyManifest = true, .extent = { 41, 8 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_content_nameless_nosig_truthTable TABLEENTRY(v1_content_nameless_nosig, TLV_ERR_NO_ERROR) + +#endif // v1_content_nameless_nosig_h diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_no_payload.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_no_payload.h new file mode 100644 index 00000000..ae439bf5 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_no_payload.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_content_no_payload.h + * @brief Content Object without a payload TLV + * + * + */ + + +#ifndef CCNx_Common_v1_content_no_payload_h +#define CCNx_Common_v1_content_no_payload_h + +#include +#include + +__attribute__((unused)) +static uint8_t v1_content_no_payload[] = { + 0x01, 0x01, 0x00, 0x21, + 0x00, 0x00, 0x00, 0x08, + // -- content object + 0x00, 0x02, 0x00, 0x15, + // -- name + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x03, 0x00, 0x02, + 0x6e, 0x6f, + 0x00, 0x03, 0x00, 0x07, + 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64 +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_content_no_payload)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_CONTENTOBJECT, .bodyManifest = true, .extent = { 12, 21 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_content_no_payload_truthTable TABLEENTRY(v1_content_no_payload, TLV_ERR_NO_ERROR) + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_zero_payload.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_zero_payload.h new file mode 100644 index 00000000..01f7a8b4 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_content_zero_payload.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_content_zero_payload.h + * @brief Content Object with zero length payload + * + * + */ + + +#ifndef CCNx_Common_v1_content_zero_payload_h +#define CCNx_Common_v1_content_zero_payload_h + +#include +#include + +__attribute__((unused)) +static uint8_t v1_content_zero_payload[] = { + 0x01, 0x01, 0x00, 0x25, + 0x00, 0x00, 0x00, 0x08, + // -- content object + 0x00, 0x02, 0x00, 0x19, + // -- name + 0x00, 0x00, 0x00, 0x11, + 0x00, 0x03, 0x00, 0x02, + 0x6e, 0x6f, + 0x00, 0x03, 0x00, 0x07, + 0x70, 0x61, 0x79, 0x6c, + 0x6f, 0x61, 0x64, + // -- payload + 0x00, 0x01, 0x00, 0x00, +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_content_zero_payload)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_OBJ_CONTENTOBJECT, .bodyManifest = true, .extent = { 12, 25 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_content_zero_payload_truthTable TABLEENTRY(v1_content_zero_payload, TLV_ERR_NO_ERROR) + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_cpi_add_route.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_cpi_add_route.h new file mode 100644 index 00000000..9bcf7dfc --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_cpi_add_route.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_cpi_add_route.h + * @brief A hand-encoded CPI packet to add a route + * + * The v1 old-style control packet is a fixed header plus a tlv container 0xBEEF with a "value" of the CPI JSON string. + * The packet type is 0xA4. + * + */ + +#ifndef TransportRTA_v1_cpi_AddRoute_h +#define TransportRTA_v1_cpi_AddRoute_h + +#include +#include + +__attribute__((unused)) +static uint8_t v1_cpi_add_route[] = "\x01\xA4\x00\xA7" + "\x00\x00\x00\x08" + "\xBE\xEF\x00\x9A" + "{\"CPI_REQUEST\":{\"SEQUENCE\":22,\"REGISTER\":{\"PREFIX\":\"lci:/howdie/stranger\",\"INTERFACE\":55,\"FLAGS\":0,\"PROTOCOL\":\"STATIC\",\"ROUTETYPE\":\"LONGEST\",\"COST\":200}}}"; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_cpi_add_route)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_CPI_PAYLOAD, .bodyManifest = true, .extent = { 12, 155 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_cpi_add_route_truthTable TABLEENTRY(v1_cpi_add_route, TLV_ERR_NO_ERROR) + +#define v1_cpi_add_route_PrefixUri "lci:/howdie/stranger" +#define v1_cpi_add_route_Sequence 22 +#define v1_cpi_add_route_Interface 55 +#endif // TransportRTA_cpi_AddRoute_h diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_cpi_add_route_crc32c.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_cpi_add_route_crc32c.h new file mode 100644 index 00000000..e31cfc85 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_cpi_add_route_crc32c.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_cpi_add_route.h + * @brief A hand-encoded CPI packet to add a route + * + * The v1 old-style control packet is a fixed header plus a tlv container 0xBEEF with a "value" of the CPI JSON string. + * The packet type is 0xA4. + * + * This control packet has a CRC32C MIC on it. Otherwise, same as v1_cpi_add_route.h + * + * Ground truth set derived from CRC RevEng http://reveng.sourceforge.net + * e.g. reveng -c -m CRC-32C 313233343536373839 gives the canonical check value 0xe306928e + * + * You can also calcaulate CRC32C online at http://www.zorc.breitbandkatze.de/crc.html using + * CRC polynomial 0x1EDC6F41, init 0xFFFFFFFF, final 0xFFFFFFFF, reverse data bytes (check), + * and reverse CRC result before final XOR (check). + * + * you can get the packet dump from the "write_packets" command. here's the detailed steps. + * The -c size of 4 in steps 4 and 7 are chosen to make it easy to delete the right number of lines. + * there's nothing magic about the "4". + * + * 1) execute ./write_packets + * 2) xxd -r -c 8 v1_cpi_add_route_crc32c.txt > y + * 3) Delete the first 8 bytes and last 16 bytes and display has a hex string + * tail -c +9 y | head -c 158 | xxd -p -c 256 + * The string should be "beef...077d7d7d" + * 4) The string for this packet is too long for the website. Use another tool such as reveng. + * 5) The answer should be 78fd926a (the reveng answer will be byte reversed) + * 6) Put the byte array from (5) in the Validation Payload. + * + */ + +#ifndef TransportRTA_v1_v1_cpi_AddRoute_crc32c_h +#define TransportRTA_v1_v1_cpi_AddRoute_crc32c_h + +#include +#include + +__attribute__((unused)) +static uint8_t v1_cpi_add_route_crc32c[] = "\x01\xA4\x00\xB7" + "\x00\x00\x00\x08" + "\xBE\xEF\x00\x9A" + "{\"CPI_REQUEST\":{\"SEQUENCE\":22,\"REGISTER\":{\"PREFIX\":\"lci:/howdie/stranger\",\"INTERFACE\":55,\"FLAGS\":0,\"PROTOCOL\":\"STATIC\",\"ROUTETYPE\":\"LONGEST\",\"COST\":200}}}" + "\x00\x03\x00\x04" + "\x00\x02\x00\x00" + "\x00\x04\x00\x04" + "\x78\xfd\x92\x6a"; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_cpi_add_route_crc32c)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_CPI_PAYLOAD, .bodyManifest = true, .extent = { 12, 155 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_CPI_ValidationAlg, .bodyManifest = true, .extent = { 171, 4 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_CPI_SIGBITS, .bodyManifest = true, .extent = { 178, 4 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_cpi_add_route_crc32c_truthTable TABLEENTRY(v1_cpi_add_route_crc32c, TLV_ERR_NO_ERROR) + +#define v1_cpi_add_route_crc32c_PrefixUri "lci:/howdie/stranger" +#define v1_cpi_add_route_crc32c_Sequence 22 +#define v1_cpi_add_route_crc32c_Interface 55 +#endif // TransportRTA_cpi_AddRoute_h diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_all_fields.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_all_fields.h new file mode 100755 index 00000000..f6524ad1 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_all_fields.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_interest_all_fields.h + * @brief A hand-encoded v1 interest in wireformat with all Interest fields. + * + * <#Detailed Description#> + * + */ + +#ifndef CCNx_Common_v1_interest_all_fields_h +#define CCNx_Common_v1_interest_all_fields_h + +#include +#include + +/** + * A well formed interest with all allowed Interest fields + */ +__attribute__((unused)) +static uint8_t v1_interest_all_fields[] = { + 0x01, 0x00, 0x00, 156, // ver = 1, type = interest, length = 156 + 0x20, 0x00, 0x11, 14, // HopLimit = 32, reserved = 0, flags = 0x11, header length = 14 + // ------------------------ + 0x00, 0x01, 0x00, 2, // Interest Lifetime (2 bytes) + 0xEA, 0xEB, + // ------------------------ + 0x00, 0x01, 0x00, 138, // type = interest, length = 138 + // ------------------------ + 0x00, 0x00, 0x00, 45, // type = name, length = 45 + 0x00, 0x03, 0x00, 4, // type = binary, length = 4 + 'c', 'o', 'o', 'l', // "cool" + // ----- segment 2 -------- + 0x00, 0x02, 0x00, 33, // type = payload id, length = 33 + 0x01, // payloadID type = sha256 + 0x89, 0x87, 0x69, 0xfc, // hash bytes based on payload + 0x8c, 0xff, 0x16, 0xff, + 0x3d, 0xfc, 0xe7, 0xfa, + 0x02, 0xd2, 0x6d, 0x26, + 0xf0, 0x91, 0x86, 0x27, + 0xcf, 0x18, 0xc1, 0x9b, + 0x0b, 0x5f, 0xe3, 0x93, + 0xce, 0x1a, 0xa3, 0x56, + // ------------------------ + 0x00, 0x02, 0x00, 36, // type = keyid restriction, length = 36 + 0x00, 0x01, 0x00, 0x20, // SHA256 hash, length 32 + 0xa0, 0xa1, 0xa2, 0xa3, + 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, + 0xac, 0xad, 0xae, 0xaf, + 0xa0, 0xa1, 0xa2, 0xa3, + 0xa4, 0xa5, 0xa6, 0xa7, + 0xa8, 0xa9, 0xaa, 0xab, + 0xac, 0xad, 0xae, 0xaf, + // ------------------------ + 0x00, 0x03, 0x00, 36, // type = hash restriction, length = 36 + 0x00, 0x01, 0x00, 0x20, // SHA256 hash, length 32 + 0xb0, 0xb1, 0xb2, 0xb3, + 0xb4, 0xb5, 0xb6, 0xb7, + 0xb8, 0xb9, 0xba, 0xbb, + 0xbc, 0xbd, 0xbe, 0xbf, + 0xc0, 0xc1, 0xc2, 0xc3, + 0xc4, 0xc5, 0xc6, 0xc7, + 0xc8, 0xc9, 0xca, 0xcb, + 0xcc, 0xcd, 0xce, 0xcf, + // ------------------------ + 0x00, 0x01, 0x00, 5, // type = payload, length = 5 + 0xD0, 0xD1, 0xD2, 0xD3, + 0xD4, +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_interest_all_fields)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_LIFETIME, .bodyManifest = false, .extent = { 12, 2 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_INTEREST, .bodyManifest = true, .extent = { 18, 138 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_NAME, .bodyManifest = true, .extent = { 22, 45 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_KEYID, .bodyManifest = true, .extent = { 71, 36 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_OBJHASH, .bodyManifest = true, .extent = { 111, 36 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_PAYLOAD, .bodyManifest = true, .extent = { 151, 5 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_interest_all_fields_truthTable TABLEENTRY(v1_interest_all_fields, TLV_ERR_NO_ERROR) + +#define v1_interest_all_fields_URI "lci:/3=cool/2=\x01\x89\x87\x69\xfc\x8c\xff\x16\xff\x3d\xfc\xe7\xfa\x02\xd2\x6d\x26\xf0\x91\x86\x27\xcf\x18\xc1\x9b\x0b\x5f\xe3\x93\xce\x1a\xa3\x56" +#define v1_interest_all_fields_Lifetime 0xEAEB +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_bad_message_length.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_bad_message_length.h new file mode 100644 index 00000000..650c770e --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_bad_message_length.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_interest_all_fields.h + * @brief A hand-encoded v1 interest in wireformat with all Interest fields. + * + * The Interest TLV length goes beyond the end of the packet + * + */ + +#ifndef CCNx_Common_v1_interest_bad_message_length_h +#define CCNx_Common_v1_interest_bad_message_length_h + +#include +#include + +/** + * A well formed interest with all allowed Interest fields + */ +__attribute__((unused)) +static uint8_t v1_interest_bad_message_length[] = { + 0x01, 0x00, 0x00, 30, // ver = 1, type = interest, length = 30 + 0x20, 0x00, 0x11, 14, // HopLimit = 31, reserved = 0, flags = 0x11, header length = 14 + // ------------------------ + 0x00, 0x01, 0x00, 2, // Interest Lifetime (2 bytes) + 0xEA, 0xEB, + // ------------------------ + 0x00, 0x01, 0x00, 13, // type = interest, length = 13 (1 byte too far) + // ------------------------ + 0x00, 0x00, 0x00, 8, // type = name, length = 8 + 0x00, 0x03, 0x00, 4, // type = binary, length = 4 + 'c', 'o', 'o', 'l', // "cool" +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_interest_bad_message_length)[] = +{ + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_interest_bad_message_length_truthTable TABLEENTRY(v1_interest_bad_message_length, TLV_ERR_TOO_LONG) + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_bad_validation_alg.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_bad_validation_alg.h new file mode 100644 index 00000000..9c4c3117 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_bad_validation_alg.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_interest_bad_validation_alg.h + * @brief Interest with CRC validation + * + * This is an error packet, the ValidationAlg TLV does not have the correct type + * + */ + +#ifndef testdata_v1_interest_bad_validation_alg +#define testdata_v1_interest_bad_validation_alg + +/** + * A well formed interest with only a name + */ + +#include +#include + +__attribute__((unused)) +static uint8_t v1_interest_bad_validation_alg[] = { + 0x01, 0x00, 0x00, 65, // ver = 1, type = interest, length = 65 + 0x20, 0x00, 0x00, 24, // HopLimit = 32, reserved = 0, header length = 24 + // ------------------------ + 0x00, 0x03, 0x00, 12, // Interest Fragment + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, // fragment 0x0102030405060708 + 0x05, 0xDC, 0x00, 0x00, // MTU 1500, fragcnt 0, fragnum 0 + // ------------------------ + 0x00, 0x01, 0x00, 0x15, // type = interest, length = 21 + // ------------------------ + 0x00, 0x00, 0x00, 0x11, // type = name, length = 17 + 0x00, 0x03, 0x00, 0x05, // type = binary, length = 5 + 'h', 'e', 'l', 'l', // "hello" + 'o', + 0xF0, 0x00, 0x00, 0x04, // type = app, length = 4 + 'o', 'u', 'c', 'h', // "ouch" + // ------------------------ + 0x00, 0xFF, 0x00, 4, // Not "0x03" validation alg length = 4 + 0x00, 0xFF, 0x00, 0x00, // unknown validation alg + // ------------------------ + 0x00, 0x04, 0x00, 4, // validation payload + 0x6A, 0xD7, 0xB1, 0xF2 // 6AD7B1F2 +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_interest_bad_validation_alg)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_E2EFRAG, .bodyManifest = false, .extent = { 12, 12 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_INTEREST, .bodyManifest = true, .extent = { 24, 25 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_NAME, .bodyManifest = true, .extent = { 32, 17 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_ValidationAlg, .bodyManifest = true, .extent = { 53, 4 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_ValidationPayload, .bodyManifest = true, .extent = { 61, 4 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_interest_bad_validation_alg_truthTable TABLEENTRY(v1_interest_bad_validation_alg, TLV_ERR_NO_ERROR) + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA.h new file mode 100644 index 00000000..4bee1e40 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_interest_nameA.h + * @brief A basic interest + * + * A basic Interest with a fragmentation header and Name. + * + */ + +#ifndef testdata_interest_nameA_h +#define testdata_interest_nameA_h + +#include +#include + +/** + * A well formed interest with only a name + */ + + +__attribute__((unused)) +static uint8_t v1_interest_nameA[] = { + 0x01, 0x00, 0x00, 61, // ver = 1, type = interest, length = 61 + 0x20, 0x00, 0x00, 36, // HopLimit = 31, reserved = 0, header length = 36 + // ------------------------ + // ------------------------ + 0x00, 0x03, 0x00, 12, // Interest Fragment + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, // fragment 0x0102030405060708 + 0x05, 0xDC, 0x00, 0x00, // MTU 1500, fragcnt 0, fragnum 0 + // ------------------------ + 0x00, 0x01, 0x00, 8, // Interest Lifetime + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x0F, 0xA0, // 4000 milli-seconds + // ------------------------ + 0x00, 0x01, 0x00, 0x15, // type = interest, length = 21 + // ------------------------ + 0x00, 0x00, 0x00, 0x11, // type = name, length = 17 + 0x00, 0x03, 0x00, 0x05, // type = binary, length = 5 + 'h', 'e', 'l', 'l', // "hello" + 'o', + 0xF0, 0x00, 0x00, 0x04, // type = app, length = 4 + 'o', 'u', 'c', 'h', // "ouch" +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_interest_nameA)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_E2EFRAG, .bodyManifest = false, .extent = { 12, 12 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_LIFETIME, .bodyManifest = false, .extent = { 28, 8 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_INTEREST, .bodyManifest = false, .extent = { 40, 21 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_NAME, .bodyManifest = true, .extent = { 44, 17 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_interest_nameA_truthTable TABLEENTRY(v1_interest_nameA, TLV_ERR_NO_ERROR) + +#define v1_interest_nameA_URI "lci:/3=hello/0xf000=ouch" + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA_badcrc32c.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA_badcrc32c.h new file mode 100644 index 00000000..6af04f42 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA_badcrc32c.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file interest_nameA_badcrc32c.h + * @brief Interest with CRC validation + * + * Has incorrect CRC32C payload + * + */ + +#ifndef testdata_interest_nameA_badcrc32c_h +#define testdata_interest_nameA_badcrc32c_h + +#include +#include + +/** + * A well formed interest with only a name + */ + +__attribute__((unused)) +static uint8_t v1_interest_nameA_badcrc32c[] = { + 0x01, 0x00, 0x00, 41, // ver = 1, type = interest, length = 65 + 0x20, 0x00, 0x00, 24, // HopLimit = 31, reserved = 0, header length = 24 + // ------------------------ + 0x00, 0x03, 0x00, 0x0C, // Interest Fragment + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, // fragment 0x0102030405060708 + 0x05, 0xDC, 0x00, 0x00, // MTU 1500, fragcnt 0, fragnum 0 + // ------------------------ + 0x00, 0x01, 0x00, 0x15, // type = interest, length = 21 + // ------------------------ + 0x00, 0x00, 0x00, 0x11, // type = name, length = 17 + 0x00, 0x03, 0x00, 0x05, // type = binary, length = 5 + 'h', 'e', 'l', 'l', // "hello" + 'o', + 0xF0, 0x00, 0x00, 0x04, // type = app, length = 4 + 'o', 'u', 'c', 'h', // "ouch" + // ------------------------ + 0x00, 0x03, 0x00, 4, // validation alg, length = 4 + 0x00, 0x02, 0x00, 0x00, // CRC32C + // ------------------------ + 0x00, 0x04, 0x00, 4, // validation payload + 0x00, 0x00, 0x00, 0x00 // invalid CRC32C +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_interest_nameA_badcrc32c)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_E2EFRAG, .bodyManifest = false, .extent = { 12, 12 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_INTEREST, .bodyManifest = true, .extent = { 20, 21 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_NAME, .bodyManifest = true, .extent = { 24, 17 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_ValidationAlg, .bodyManifest = true, .extent = { 45, 4 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_ValidationPayload, .bodyManifest = true, .extent = { 53, 4 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_interest_nameA_badcrc32c_truthTable TABLEENTRY(v1_interest_nameA_badcrc32c, TLV_ERR_NO_ERROR) + +#define v1_interest_nameA_badcrc32c_URI "lci:/3=hello/0xf000=ouch" + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA_crc32c.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA_crc32c.h new file mode 100644 index 00000000..64edf560 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_nameA_crc32c.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file interest_nameA_crc32c.h + * @brief Interest with CRC validation + * + * + * Ground truth set derived from CRC RevEng http://reveng.sourceforge.net + * e.g. reveng -c -m CRC-32C 313233343536373839 gives the canonical check value 0xe306928e (the output will be backwards) + * + * You can also calcaulate CRC32C online at http://www.zorc.breitbandkatze.de/crc.html using + * CRC polynomial 0x1EDC6F41, init 0xFFFFFFFF, final 0xFFFFFFFF, reverse data bytes (check), + * and reverse CRC result before final XOR (check). + * + * you can get the packet dump from the "write_packets" command. here's the detailed steps. + * The -c size of 8 in steps 4 and 7 are chosen to make it easy to delete the right number of lines. + * there's nothing magic about the "8". + * + * 1) execute ./write_packets + * 2) xxd -r -c 8 v1_interest_nameA_crc32c.txt > y + * 3) Delete the first 24 bytes and last 8 bytes and display as a URI-escaped hex string + * head -c 57 y | tail -c +25 | xxd -p -c 256 | sed 's/[0-9a-f]\{2\}/%&/g' + * The string should be "00010015...00020000" + * 4) Copy the hex string to the website and use the settings specified above (don't use 0x in front + * of any hex strings). IMPORTANT: you need to %-escape each hex byte!! Click "compute!" + * 5) The answer should be 6AD7B1F2 + * 6) Put the byte array from (5) in the Validation Payload. + * + */ + +#ifndef testdata_interest_nameA_crc32c_h +#define testdata_interest_nameA_crc32c_h + +/** + * A well formed interest with only a name + */ + +#include +#include + +#define NAME_A_CRC32_PACKET(_type, _code) \ + { \ + 0x01, _type, 0x00, 65, /* ver = 1, type = interest, length = 65 */ \ + 0x20, _code, 0x00, 24, /* HopLimit = 32, reserved = 0, header length = 24*/ \ + /* ------------------------ */ \ + 0x00, 0x03, 0x00, 12, /* Interest Fragment */ \ + 0x01, 0x02, 0x03, 0x04, \ + 0x05, 0x06, 0x07, 0x08, /* fragment 0x0102030405060708 */ \ + 0x05, 0xDC, 0x00, 0x00, /* MTU 1500, fragcnt 0, fragnum 0 */ \ + /* ------------------------ */ \ + 0x00, 0x01, 0x00, 0x15, /* type = interest, length = 21 */ \ + /* ------------------------ */ \ + 0x00, 0x00, 0x00, 0x11, /* type = name, length = 17 */ \ + 0x00, 0x03, 0x00, 0x05, /* type = binary, length = 5 */ \ + 'h', 'e', 'l', 'l', /* "hello" */ \ + 'o', \ + 0xF0, 0x00, 0x00, 0x04, /* type = app, length = 4 */ \ + 'o', 'u', 'c', 'h', /* "ouch" */ \ + /* ------------------------ */ \ + 0x00, 0x03, 0x00, 4, /* validation alg, length = 4 */ \ + 0x00, 0x02, 0x00, 0x00, /* CRC32C */ \ + /* ------------------------ */ \ + 0x00, 0x04, 0x00, 4, /* validation payload */ \ + 0xD0, 0x98, 0x73, 0x7C, /* D098737C */ \ + } + +__attribute__((unused)) +static uint8_t v1_interest_nameA_crc32c[] = NAME_A_CRC32_PACKET(0x00, 0x00); + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_interest_nameA_crc32c)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_E2EFRAG, .bodyManifest = false, .extent = { 12, 12 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_INTEREST, .bodyManifest = true, .extent = { 24, 25 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_NAME, .bodyManifest = true, .extent = { 32, 17 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_ValidationAlg, .bodyManifest = true, .extent = { 53, 4 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_ValidationPayload, .bodyManifest = true, .extent = { 61, 4 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +__attribute__((unused)) +static uint8_t v1_interest_nameA_crc32c_returned[] = NAME_A_CRC32_PACKET(0x02, 0x03); //InterestReturn & NoResource + +#define v1_interest_nameA_crc32c_truthTable TABLEENTRY(v1_interest_nameA_crc32c, TLV_ERR_NO_ERROR) + +#define v1_interest_nameA_crc32c_URI "lci:/3=hello/0xf000=ouch" + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_validation_alg_overrun.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_validation_alg_overrun.h new file mode 100644 index 00000000..8f3b55a5 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_interest_validation_alg_overrun.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file v1_interest_validation_alg_overrun.h + * @brief Interest with CRC validation + * + * This is an error packet. The length of the Validation TLV runs past the end of the packet. + * + */ + +#ifndef testdata_v1_interest_validation_alg_overrun +#define testdata_v1_interest_validation_alg_overrun + +/** + * A well formed interest with only a name + */ + +#include +#include + +__attribute__((unused)) +static uint8_t v1_interest_validation_alg_overrun[] = { + 0x01, 0x00, 0x00, 65, // ver = 1, type = interest, length = 65 + 0x20, 0x00, 0x00, 24, // HopLimit = 32, reserved = 0, header length = 24 + // ------------------------ + 0x00, 0x03, 0x00, 12, // Interest Fragment + 0x01, 0x02, 0x03, 0x04, + 0x05, 0x06, 0x07, 0x08, // fragment 0x0102030405060708 + 0x05, 0xDC, 0x00, 0x00, // MTU 1500, fragcnt 0, fragnum 0 + // ------------------------ + 0x00, 0x01, 0x00, 0x15, // type = interest, length = 21 + // ------------------------ + 0x00, 0x00, 0x00, 0x11, // type = name, length = 17 + 0x00, 0x03, 0x00, 0x05, // type = binary, length = 5 + 'h', 'e', 'l', 'l', // "hello" + 'o', + 0xF0, 0x00, 0x00, 0x04, // type = app, length = 4 + 'o', 'u', 'c', 'h', // "ouch" + // ------------------------ + 0x00, 0x03, 0x00, 255, // Validation Alg, length = 255 + 0x00, 0xFF, 0x00, 0x00, // unknown validation alg + // ------------------------ + 0x00, 0x04, 0x00, 4, // validation payload + 0x6A, 0xD7, 0xB1, 0xF2 // 6AD7B1F2 +}; + +__attribute__((unused)) +static TruthTableEntry +TRUTHTABLENAME(v1_interest_validation_alg_overrun)[] = +{ + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_E2EFRAG, .bodyManifest = false, .extent = { 12, 12 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_INTEREST, .bodyManifest = true, .extent = { 24, 25 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_NAME, .bodyManifest = true, .extent = { 32, 17 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_ValidationAlg, .bodyManifest = true, .extent = { 53, 4 } }, + { .wellKnownType = true, .indexOrKey = V1_MANIFEST_INT_ValidationPayload, .bodyManifest = true, .extent = { 61, 4 } }, + { .wellKnownType = false, .indexOrKey = T_INVALID, .extent = { 0, 0 } }, +}; + +#define v1_interest_validation_alg_overrun_truthTable TABLEENTRY(v1_interest_validation_alg_overrun, TLV_ERR_TOO_LONG) + +#endif diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_testrig_truthSet.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_testrig_truthSet.h new file mode 100644 index 00000000..f98de878 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_testrig_truthSet.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Contains tables of all the packets. May be used for automated testing. Also used by write_packets utility. + * + */ + +#include + +#include "v1_interest_nameA.h" +#include "v1_interest_nameA_badcrc32c.h" +#include "v1_interest_nameA_crc32c.h" +#include "v1_interest_bad_validation_alg.h" +#include "v1_interest_validation_alg_overrun.h" + +#include "v1_content_nameA_crc32c.h" +#include "v1_content_nameA_keyid1_rsasha256.h" +#include "v1_content_zero_payload.h" +#include "v1_content_no_payload.h" + +#include "v1_cpi_add_route.h" +#include "v1_cpi_add_route_crc32c.h" + +// terminated with NULL packet entry +__attribute__((unused)) +static TruthTable v1_interests_truthSet [] = { + // tests in alphabetical order + v1_interest_nameA_truthTable, + v1_interest_nameA_badcrc32c_truthTable, + v1_interest_nameA_crc32c_truthTable, + v1_interest_bad_validation_alg_truthTable, + v1_interest_validation_alg_overrun_truthTable, + // the end of table marker + { .packet = NULL, .expectedError= 0, .entry = NULL } +}; + +// terminated with NULL packet entry +__attribute__((unused)) +static TruthTable v1_contentObject_truthSet [] = { + v1_content_nameA_crc32c_truthTable, + v1_content_nameA_keyid1_rsasha256_truthTable, + v1_content_zero_payload_truthTable, + v1_content_no_payload_truthTable, + + // the end of table marker + { .packet = NULL, .expectedError= 0, .entry = NULL } +}; + +__attribute__((unused)) +static TruthTable v1_cpi_truthSet [] = { + v1_cpi_add_route_truthTable, + v1_cpi_add_route_crc32c_truthTable, + // the end of table marker + { .packet = NULL, .expectedError= 0, .entry = NULL } +}; diff --git a/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_testrig_truthTable.h b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_testrig_truthTable.h new file mode 100755 index 00000000..32c954b7 --- /dev/null +++ b/libccnx-common/ccnx/common/codec/schema_v1/testdata/v1_testrig_truthTable.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/* + * testrig_truthTable.h + * TransportRTA + */ + +#ifndef TransportRTA_testrig_truthTable_h +#define TransportRTA_testrig_truthTable_h + +#include +#include +//#include + +#include +#include + +#include + +#endif -- cgit 1.2.3-korg