forked from named-data-iot/ndn-lite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ndn-constants.h
149 lines (133 loc) · 6.32 KB
/
ndn-constants.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
* Copyright (C) 2018-2020
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v3.0. See the file LICENSE in the top level
* directory for more details.
*
* See AUTHORS.md for complete list of NDN-LITE authors and contributors.
*/
#ifndef NDN_CONSTANTS_H
#define NDN_CONSTANTS_H
#include <stdint.h>
// name and name component
#define NDN_NAME_COMPONENT_BUFFER_SIZE 36
#define NDN_NAME_COMPONENT_BLOCK_SIZE 38
#define NDN_NAME_COMPONENTS_SIZE 10
#define NDN_NAME_MAX_BLOCK_SIZE 384
#define NDN_FWD_INVALID_NAME_SIZE ((uint8_t)(-1))
#define NDN_FWD_INVALID_NAME_COMPONENT_SIZE ((uint8_t)(-1))
// tlv
#define NDN_TLV_LENGTH_FIELD_MAX_SIZE 9
#define NDN_TLV_TYPE_FIELD_MAX_SIZE 1
// interest
#define NDN_INTEREST_PARAMS_BUFFER_SIZE 248
#define NDN_INTEREST_PARAMS_BLOCK_SIZE (NDN_INTEREST_PARAMS_BUFFER_SIZE+10) //1byte[type] + 9byte[Max Len]
#define NDN_SIGNED_INTEREST_BE_SIGNED_MAX_SIZE 680
#define NDN_DEFAULT_INTEREST_LIFETIME 4000
// data
#define NDN_CONTENT_BUFFER_SIZE 1024
// signature
#define NDN_SIGNATURE_BUFFER_SIZE 128
// forwarder
typedef uint16_t ndn_table_id_t;
#define NDN_INVALID_ID 0xFFFF
#define NDN_NAMETREE_MAX_SIZE 64
#define NDN_FIB_MAX_SIZE 20
#define NDN_PIT_MAX_SIZE 32
#define NDN_CS_MAX_SIZE 10
#define NDN_FACE_TABLE_MAX_SIZE 10
#define NDN_FACE_DEFAULT_COST 1
#define NDN_AES_BLOCK_SIZE 16
#define NDN_MAX_FACE_PER_PIT_ENTRY 3
// fragmentation support
#define NDN_FRAG_HDR_LEN 3 // Size of the NDN L2 fragmentation header
#define NDN_FRAG_HB_MASK 0x80 // 1000 0000
#define NDN_FRAG_MF_MASK 0x20 // 0010 0000
#define NDN_FRAG_SEQ_MASK 0x1F // 0001 1111
#define NDN_FRAG_MAX_SEQ_NUM 30
#define NDN_FRAG_BUFFER_MAX 512
// access control
#define NDN_APPSUPPORT_AC_EDK_SIZE 16
#define NDN_APPSUPPORT_AC_SALT_SIZE 16
#define NDN_APPSUPPORT_AC_KEY_LIST_SIZE 5
// service discovery
#define NDN_SD_SERVICES_SIZE 10
#define NDN_APPSUPPORT_SERVICE_ID_SIZE 20
#define NDN_APPSUPPORT_INVALID_SERVICE_ID_SIZE ((uint32_t)(-1))
#define NDN_APPSUPPORT_SERVICE_UNDEFINED ((uint8_t)(-1))
#define NDN_APPSUPPORT_SERVICE_UNAVAILABLE 0
#define NDN_APPSUPPORT_SERVICE_AVAILABLE 1
#define NDN_APPSUPPORT_SERVICE_BUSY 2
#define NDN_APPSUPPORT_SERVICE_PERMISSION_DENIED 3
// asn1 encoding
// the below constants are based on the number of bytes in the
// micro-ecc curve, which can be found here:
// https://github.com/kmackay/micro-ecc/blob/master/curve-specific.inc
// the maximum asn signature encoding size is found by taking the
// size of the raw signature (the number of bytes in its micro-ecc curve * 2)
// and then adding 8, to account for the ASN1.SEQUENCE tlv type and length fields,
// the two ASN1.INTEGER tlv type and length fields, and the two potential extra
// 0's if the integers of the signature containing a leading 1 bit
#define NDN_ASN1_ECDSA_ENCODING_MAX_EXTRA_BYTES 8
#define NDN_ASN1_ECDSA_ENCODING_MIN_EXTRA_BYTES 6
#define NDN_ASN1_ECDSA_SECP256R1_RAW_SIG_SIZE 64
#define NDN_ASN1_ECDSA_SECP256K1_RAW_SIG_SIZE 64
#define NDN_ASN1_ECDSA_SECP224R1_RAW_SIG_SIZE 56
#define NDN_ASN1_ECDSA_SECP192R1_RAW_SIG_SIZE 48
#define NDN_ASN1_ECDSA_SECP160R1_RAW_SIG_SIZE 40
#define NDN_ASN1_ECDSA_SECP256R1_MAX_ENCODED_SIG_SIZE (NDN_ASN1_ECDSA_SECP256R1_RAW_SIG_SIZE + \
NDN_ASN1_ECDSA_ENCODING_MAX_EXTRA_BYTES)
#define NDN_ASN1_ECDSA_SECP256K1_MAX_ENCODED_SIG_SIZE (NDN_ASN1_ECDSA_SECP256K1_RAW_SIG_SIZE + \
NDN_ASN1_ECDSA_ENCODING_MAX_EXTRA_BYTES)
#define NDN_ASN1_ECDSA_SECP224R1_MAX_ENCODED_SIG_SIZE (NDN_ASN1_ECDSA_SECP224R1_RAW_SIG_SIZE + \
NDN_ASN1_ECDSA_ENCODING_MAX_EXTRA_BYTES)
#define NDN_ASN1_ECDSA_SECP192R1_MAX_ENCODED_SIG_SIZE (NDN_ASN1_ECDSA_SECP192R1_RAW_SIG_SIZE + \
NDN_ASN1_ECDSA_ENCODING_MAX_EXTRA_BYTES)
#define NDN_ASN1_ECDSA_SECP160R1_MAX_ENCODED_SIG_SIZE (NDN_ASN1_ECDSA_SECP160R1_RAW_SIG_SIZE + \
NDN_ASN1_ECDSA_ENCODING_MAX_EXTRA_BYTES)
#define NDN_ASN1_ECDSA_MIN_RAW_SIG_SIZE (NDN_ASN1_ECDSA_SECP160R1_RAW_SIG_SIZE)
#define NDN_ASN1_ECDSA_MIN_ENCODED_SIG_SIZE (NDN_ASN1_ECDSA_MIN_RAW_SIG_SIZE + \
NDN_ASN1_ECDSA_ENCODING_MIN_EXTRA_BYTES)
#define NDN_ASN1_ECDSA_MAX_RAW_SIG_SIZE (NDN_ASN1_ECDSA_SECP256R1_RAW_SIG_SIZE)
#define NDN_ASN1_ECDSA_MAX_ENCODED_SIG_SIZE (NDN_ASN1_ECDSA_MAX_RAW_SIG_SIZE + \
NDN_ASN1_ECDSA_ENCODING_MAX_EXTRA_BYTES)
// security
#define NDN_SEC_CERT_SIZE 3
#define NDN_SEC_SIGNING_KEYS_SIZE 10
#define NDN_SEC_ENCRYPTION_KEYS_SIZE 5
#define NDN_SEC_INVALID_KEY_SIZE ((uint32_t)(-1))
#define NDN_SEC_INVALID_KEY_ID ((uint32_t)(-1))
#define NDN_SEC_SHA256_HASH_SIZE 32
#define NDN_SEC_AES_MIN_KEY_SIZE 16
#define NDN_SEC_AES_IV_LENGTH 16
#define NDN_SEC_HMAC_MAX_KEY_SIZE 100
#define NDN_SEC_HMAC_MAX_OUTPUT_SIZE 256
#define NDN_SEC_ECC_SECP256R1_PUBLIC_KEY_SIZE 64
#define NDN_SEC_ECC_SECP256R1_PRIVATE_KEY_SIZE 32
#define NDN_SEC_ECC_SECP160R1_PUBLIC_KEY_SIZE 40
#define NDN_SEC_ECC_SECP160R1_PRIVATE_KEY_SIZE 21
#define NDN_SEC_ECC_MAX_PUBLIC_KEY_SIZE (NDN_SEC_ECC_SECP256R1_PUBLIC_KEY_SIZE)
#define NDN_SEC_ECC_MAX_PRIVATE_KEY_SIZE (NDN_SEC_ECC_SECP256R1_PRIVATE_KEY_SIZE)
#define NDN_SEC_ECC_MIN_PUBLIC_KEY_SIZE (NDN_SEC_ECC_SECP160R1_PUBLIC_KEY_SIZE)
#define NDN_SEC_ECC_MIN_PRIVATE_KEY_SIZE (NDN_SEC_ECC_SECP160R1_PRIVATE_KEY_SIZE)
#define NDN_SEC_MAX_SIG_SIZE (NDN_ASN1_ECDSA_MAX_ENCODED_SIG_SIZE)
#define NDN_SEC_MIN_SIG_SIZE (NDN_SEC_SHA256_HASH_SIZE)
// schematized trust
#define NDN_TRUST_SCHEMA_MAX_SUBPATTERN_MATCHES 5
#define NDN_TRUST_SCHEMA_PATTERN_COMPONENTS_SIZE 10
#define NDN_TRUST_SCHEMA_PATTERN_COMPONENT_BUFFER_SIZE 50
#define NDN_TRUST_SCHEMA_PATTERN_COMPONENT_STRING_MAX_SIZE \
(NDN_TRUST_SCHEMA_PATTERN_COMPONENT_BUFFER_SIZE)
#define NDN_TRUST_SCHEMA_RULE_NAME_MAX_LENGTH \
(NDN_TRUST_SCHEMA_PATTERN_COMPONENT_BUFFER_SIZE - 1)
#define NDN_TRUST_SCHEMA_NO_TYPE 0x00
#define NDN_TRUST_SCHEMA_WILDCARD_NAME_COMPONENT_SEQUENCE 0x01
#define NDN_TRUST_SCHEMA_WILDCARD_NAME_COMPONENT 0x02
#define NDN_TRUST_SCHEMA_SINGLE_NAME_COMPONENT 0x03
#define NDN_TRUST_SCHEMA_SUBPATTERN_INDEX 0x04
#define NDN_TRUST_SCHEMA_WILDCARD_SPECIALIZER 0x05
#define NDN_TRUST_SCHEMA_RULE_REF 0x06
#define NDN_TRUST_SCHEMA_SUBPATTERN_BEGIN_ONLY 0x02
#define NDN_TRUST_SCHEMA_SUBPATTERN_END_ONLY 0x01
#endif // NDN_CONSTANTS_H