blob: 28a74edaa8129d7c17d3ce88b9f70087b1fa4f8d [file] [log] [blame]
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -04001Signature
2=========
3
Alexander Afanasyeve2800232013-11-27 02:24:14 +00004.. _Signature:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +00005
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -04006Data Signature
7--------------
Alexander Afanasyeveee8c252013-11-21 23:22:41 +00008
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -04009NDN Data Signature is defined as two consecutive TLV blocks: ``SignatureInfo`` and ``SignatureValue``.
Alexander Afanasyeve2800232013-11-27 02:24:14 +000010The following general considerations about SignatureInfo and SignatureValue blocks that apply for all signature types:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000011
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800121. ``SignatureInfo`` is **included** in signature calculation and fully describes the signature, signature algorithm, and any other relevant information to obtain parent certificate(s), such as :ref:`KeyLocator`.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000013
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000142. ``SignatureValue`` is **excluded** from signature calculation and represent actual bits of the signature and any other supporting signature material.
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000015
Alexander Afanasyev7455e9b2014-06-25 09:41:08 -070016The reason for separating the signature into two separate TLV blocks is to allow efficient signing of a contiguous memory block (e.g., for Data packet this block starts from Name TLV and ends with SignatureInfo TLV).
17
Alexander Afanasyeve2800232013-11-27 02:24:14 +000018::
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000019
Junxiao Shi78ce2952019-05-07 15:34:00 -040020 DataSignature = SignatureInfo SignatureValue
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000021
Junxiao Shi78ce2952019-05-07 15:34:00 -040022 SignatureInfo = SIGNATURE-INFO-TYPE TLV-LENGTH
23 SignatureType
24 [KeyLocator]
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000025
Junxiao Shi78ce2952019-05-07 15:34:00 -040026 SignatureValue = SIGNATURE-VALUE-TYPE TLV-LENGTH *OCTET
Zhiyi Zhang47e51372019-02-25 13:47:01 -080027
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -040028.. _InterestSignature:
29
30Interest Signature
31------------------
32
33NDN Interest Signature is defined as two consecutive TLV blocks: ``InterestSignatureInfo`` and ``InterestSignatureValue``.
34
35To ensure uniqueness of the signed Interest name and to mitigate potential replay attacks, the ``InterestSignatureInfo`` element can include a ``SignatureNonce`` element, ``SignatureTime`` element, and/or ``SignatureSeqNum`` element.
36
37The cryptographic signature in the ``InterestSignatureValue`` element covers all the ``NameComponent`` elements inside ``Name`` up to but not including ``ParametersSha256DigestComponent`` component, and the complete TLVs starting from ``ApplicationParameters`` up until but not including ``InterestSignatureValue``.
38
39
40::
41
Junxiao Shi78ce2952019-05-07 15:34:00 -040042 InterestSignature = InterestSignatureInfo InterestSignatureValue
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -040043
Junxiao Shi78ce2952019-05-07 15:34:00 -040044 InterestSignatureInfo = INTEREST-SIGNATURE-INFO-TYPE TLV-LENGTH
45 SignatureType
46 [KeyLocator]
47 [SignatureNonce]
48 [SignatureTime]
49 [SignatureSeqNum]
50
51 InterestSignatureValue = INTEREST-SIGNATURE-VALUE-TYPE TLV-LENGTH *OCTET
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -040052
53Signature Elements
54------------------
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000055
Alexander Afanasyeve2800232013-11-27 02:24:14 +000056SignatureType
57~~~~~~~~~~~~~
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000058
Alexander Afanasyeve2800232013-11-27 02:24:14 +000059::
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000060
Junxiao Shi78ce2952019-05-07 15:34:00 -040061 SignatureType = SIGNATURE-TYPE-TYPE TLV-LENGTH nonNegativeInteger
Jeff Thompsond4225d42014-06-09 12:32:21 -070062
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000063
Alexander Afanasyeve2800232013-11-27 02:24:14 +000064This specification defines the following SignatureType values:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000065
Jeff Thompsond4225d42014-06-09 12:32:21 -070066+---------+----------------------------------------+-------------------------------------------------+
67| Value | Reference | Description |
68+=========+========================================+=================================================+
69| 0 | :ref:`DigestSha256` | Integrity protection using SHA-256 digest |
70+---------+----------------------------------------+-------------------------------------------------+
71| 1 | :ref:`SignatureSha256WithRsa` | Integrity and provenance protection using |
72| | | RSA signature over a SHA-256 digest |
73+---------+----------------------------------------+-------------------------------------------------+
74| 3 | :ref:`SignatureSha256WithEcdsa` | Integrity and provenance protection using |
75| | | an ECDSA signature over a SHA-256 digest |
76+---------+----------------------------------------+-------------------------------------------------+
Jeff Thompson29840e82015-04-06 15:21:21 -070077| 4 | :ref:`SignatureHmacWithSha256` | Integrity and provenance protection using |
78| | | SHA256 hash-based message authentication codes |
79+---------+----------------------------------------+-------------------------------------------------+
80| 2,5-200 | | reserved for future assignments |
Jeff Thompsond4225d42014-06-09 12:32:21 -070081+---------+----------------------------------------+-------------------------------------------------+
82| >200 | | unassigned |
83+---------+----------------------------------------+-------------------------------------------------+
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000084
Alexander Afanasyev4b896112014-06-23 21:47:15 -070085.. _KeyLocator:
86
87KeyLocator
88~~~~~~~~~~
89
Alexander Afanasyev7455e9b2014-06-25 09:41:08 -070090A ``KeyLocator`` specifies either ``Name`` that points to another Data packet containing certificate or public key or ``KeyDigest`` to identify the public key within a specific trust model (the trust model definition is outside the scope of the current specification).
Alexander Afanasyev4b896112014-06-23 21:47:15 -070091Note that although ``KeyLocator`` is defined as an optional field in ``SignatureInfo`` block, some signature types may require presence of it and some require ``KeyLocator`` absence.
92
93::
94
Junxiao Shi78ce2952019-05-07 15:34:00 -040095 KeyLocator = KEY-LOCATOR-TYPE TLV-LENGTH (Name / KeyDigest)
Alexander Afanasyev4b896112014-06-23 21:47:15 -070096
Junxiao Shi78ce2952019-05-07 15:34:00 -040097 KeyDigest = KEY-DIGEST-TYPE TLV-LENGTH *OCTET
Alexander Afanasyev4b896112014-06-23 21:47:15 -070098
99See :ref:`Name specification <Name>` for the definition of Name field.
100
101The specific definition of the usage of ``Name`` and ``KeyDigest`` options in ``KeyLocator`` field is outside the scope of this specification.
102Generally, ``Name`` names the Data packet with the corresponding certificate.
103However, it is up to the specific trust model to define whether this name is a full name of the Data packet or a prefix that can match multiple Data packets.
104For example, the hierarchical trust model :cite:`testbed-key-management` uses the latter approach, requiring clients to fetch the latest version of the Data packet pointed by the KeyLocator (the latest version of the public key certificate) in order to ensure that the public key was not yet revoked.
105
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800106.. _SignatureInfoNonce:
107
108SignatureNonce
109~~~~~~~~~~~~~~
110
111::
112
Junxiao Shi78ce2952019-05-07 15:34:00 -0400113 SignatureNonce = SIGNATURE-NONCE-TYPE
114 TLV-LENGTH ; == 4
115 4OCTET
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800116
117
118The ``SignatureNonce`` element adds additional assurances that a signature will be unique.
119
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400120.. _SignatureTime:
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800121
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400122SignatureTime
123~~~~~~~~~~~~~
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800124
125::
126
Junxiao Shi78ce2952019-05-07 15:34:00 -0400127 SignatureTime = SIGNATURE-TIME-TYPE TLV-LENGTH nonNegativeInteger
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800128
129
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400130The value of the ``SignatureTime`` element is the signature's timestamp (in terms of milliseconds since 1970-01-01 00:00:00 UTC) encoded as nonNegativeInteger.
131The ``SignatureTime`` element may be used to protect against replay attacks.
132
133.. _SignatureSeqNum:
134
135SignatureSeqNum
136~~~~~~~~~~~~~~~
137
138::
139
Junxiao Shi78ce2952019-05-07 15:34:00 -0400140 SignatureSeqNum = SIGNATURE-SEQ-NUM-TYPE TLV-LENGTH nonNegativeInteger
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400141
142
143The ``SignatureSeqNum`` element adds additional assurances that a signature will be unique.
144The ``SignatureSeqNum`` may be used to protect against replay attacks.
145
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800146
147Different Types of Signature
148~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400150Each signature type has different requirements on the format of its ``SignatureInfo`` or ``InterestSignatureInfo`` element.
151In the following sections, these requirements are specified along 2 dimensions:
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800152
153* The TLV-VALUE of ``SignatureType``
154* ``KeyLocator`` is required/forbidden
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800155
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000156.. _DigestSha256:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +0000157
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000158DigestSha256
159^^^^^^^^^^^^
Alexander Afanasyeveee8c252013-11-21 23:22:41 +0000160
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000161``DigestSha256`` provides no provenance of a Data packet or any kind of guarantee that packet is from the original source.
Alexander Afanasyev4b896112014-06-23 21:47:15 -0700162This signature type is intended only for debug purposes and limited circumstances when it is necessary to protect only against unexpected modification during the transmission.
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000163
164``DigestSha256`` is defined as a SHA256 hash of the :ref:`Name`, :ref:`MetaInfo`, :ref:`Content`, and :ref:`SignatureInfo <Signature>` TLVs:
165
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800166* The TLV-VALUE of ``SignatureType`` is 0
167* ``KeyLocator`` is forbidden; if present, it must be ignored
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000168
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800169::
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000170
Junxiao Shi78ce2952019-05-07 15:34:00 -0400171 SignatureValue = SIGNATURE-VALUE-TYPE
172 TLV-LENGTH ; == 32
173 32OCTET ; == SHA256{Name, MetaInfo, Content, SignatureInfo}
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000174
Junxiao Shi78ce2952019-05-07 15:34:00 -0400175 InterestSignatureValue = INTEREST-SIGNATURE-VALUE-TYPE
176 TLV-LENGTH ; == 32
177 32OCTET ; == SHA256{Name(without T, L, and ParametersSha256DigestComponent),
178 ; ApplicationParameters, InterestSignatureInfo}
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400179
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000180.. _SignatureSha256WithRsa:
181
182SignatureSha256WithRsa
183^^^^^^^^^^^^^^^^^^^^^^
184
185``SignatureSha256WithRsa`` is the basic signature algorithm that MUST be supported by any NDN-compliant software.
186As suggested by the name, it defines an RSA public key signature that is calculated over SHA256 hash of the :ref:`Name`, :ref:`MetaInfo`, :ref:`Content`, and :ref:`SignatureInfo <Signature>` TLVs.
187
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800188* The TLV-VALUE of ``SignatureType`` is 1
189* ``KeyLocator`` is required
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000190
191::
192
Junxiao Shi78ce2952019-05-07 15:34:00 -0400193 SignatureValue = SIGNATURE-VALUE-TYPE TLV-LENGTH
194 *OCTET ; == RSA over SHA256{Name, MetaInfo, Content, SignatureInfo}
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000195
Junxiao Shi78ce2952019-05-07 15:34:00 -0400196 InterestSignatureValue = INTEREST-SIGNATURE-VALUE-TYPE TLV-LENGTH
197 *OCTET ; == RSA over SHA256{Name(without T, L, and ParametersSha256DigestComponent),
198 ApplicationParameters, InterestSignatureInfo}
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400199
Alexander Afanasyev16962fc2014-02-12 19:53:47 +0000200.. note::
201
Junxiao Shi78ce2952019-05-07 15:34:00 -0400202 The TLV-LENGTH of these elements varies (typically 128 or 256 bytes) depending on the private key length used during the signing process.
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000203
204This type of signature ensures strict provenance of a Data packet, provided that the signature verifies and signature issuer is authorized to sign the Data packet.
Jeff Thompsond4225d42014-06-09 12:32:21 -0700205The signature issuer is identified using :ref:`KeyLocator` block in :ref:`SignatureInfo <Signature>` block of ``SignatureSha256WithRsa``.
Alexander Afanasyev4b896112014-06-23 21:47:15 -0700206KeyDigest option in ``KeyLocator`` is defined as SHA256 digest over the DER encoding of the SubjectPublicKeyInfo for an RSA key as defined by `RFC 3279 <http://www.rfc-editor.org/rfc/rfc3279.txt>`_."
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000207See :ref:`KeyLocator section <KeyLocator>` for more detail.
208
209.. note::
210
211 It is application's responsibility to define rules (trust model) of when a specific issuer (KeyLocator) is authorized to sign a specific Data packet.
212 While trust model is outside the scope of the current specification, generally, trust model needs to specify authorization rules between KeyName and Data packet Name, as well as clearly define trust anchor(s).
Jeff Thompsond4225d42014-06-09 12:32:21 -0700213 For example, an application can elect to use hierarchical trust model :cite:`testbed-key-management` to ensure Data integrity and provenance.
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000214
Jeff Thompsond4225d42014-06-09 12:32:21 -0700215.. _SignatureSha256WithEcdsa:
216
217SignatureSha256WithEcdsa
218^^^^^^^^^^^^^^^^^^^^^^^^
219
220``SignatureSha256WithEcdsa`` defines an ECDSA public key signature that is calculated over the SHA256 hash of the :ref:`Name`, :ref:`MetaInfo`, :ref:`Content`, and :ref:`SignatureInfo <Signature>` TLVs.
221The signature algorithm is defined in `[RFC5753], Section 2.1 <http://tools.ietf.org/html/rfc5753#section-2.1>`_.
222
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800223* The TLV-VALUE of ``SignatureType`` is 3
224* ``KeyLocator`` is required
Jeff Thompsond4225d42014-06-09 12:32:21 -0700225
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800226::
Jeff Thompsond4225d42014-06-09 12:32:21 -0700227
Junxiao Shi78ce2952019-05-07 15:34:00 -0400228 SignatureValue = SIGNATURE-VALUE-TYPE TLV-LENGTH
229 *OCTET ; == ECDSA over SHA256{Name, MetaInfo, Content, SignatureInfo}
Jeff Thompsond4225d42014-06-09 12:32:21 -0700230
Junxiao Shi78ce2952019-05-07 15:34:00 -0400231 InterestSignatureValue = INTEREST-SIGNATURE-VALUE-TYPE TLV-LENGTH
232 *OCTET ; == ECDSA over SHA256{Name(without T, L, and ParametersSha256DigestComponent),
233 ApplicationParameters, InterestSignatureInfo}
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400234
Jeff Thompsond4225d42014-06-09 12:32:21 -0700235.. note::
236
Junxiao Shi78ce2952019-05-07 15:34:00 -0400237 The TLV-LENGTH of these elements depends on the elliptic curve used during the signing process (about 63 bytes for a 224 bit key).
Jeff Thompsond4225d42014-06-09 12:32:21 -0700238
239This type of signature ensures strict provenance of a Data packet, provided that the signature verifies and the signature issuer is authorized to sign the Data packet.
240The signature issuer is identified using the :ref:`KeyLocator` block in the :ref:`SignatureInfo <Signature>` block of the ``SignatureSha256WithEcdsa``.
Alexander Afanasyev4b896112014-06-23 21:47:15 -0700241KeyDigest option in ``KeyLocator`` is defined as SHA256 digest over the DER encoding of the SubjectPublicKeyInfo for an EC key as defined by `RFC 5480 <http://www.ietf.org/rfc/rfc5480.txt>`_.
Jeff Thompsond4225d42014-06-09 12:32:21 -0700242See the :ref:`KeyLocator section <KeyLocator>` for more detail.
243
Junxiao Shi78ce2952019-05-07 15:34:00 -0400244The value of ``SignatureValue`` of ``SignatureSha256WithEcdsa`` is a DER encoded ECDSA signature as defined in `Section 2.2.3 in RFC 3279 <http://tools.ietf.org/html/rfc3279#section-2.2.3>`_.
Jeff Thompsond4225d42014-06-09 12:32:21 -0700245
246::
247
248 Ecdsa-Sig-Value ::= SEQUENCE {
249 r INTEGER,
250 s INTEGER }
251
Jeff Thompson29840e82015-04-06 15:21:21 -0700252.. _SignatureHmacWithSha256:
253
254SignatureHmacWithSha256
255^^^^^^^^^^^^^^^^^^^^^^^
256
257``SignatureHmacWithSha256`` defines a hash-based message authentication code (HMAC) that is calculated over the :ref:`Name`, :ref:`MetaInfo`, :ref:`Content`, and :ref:`SignatureInfo <Signature>` TLVs, using SHA256 as the hash function, salted with a shared secret key.
258The signature algorithm is defined in `Section 2 in RFC 2104 <http://tools.ietf.org/html/rfc2104#section-2>`__.
259
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800260* The TLV-VALUE of ``SignatureType`` is 4
261* ``KeyLocator`` is required
Jeff Thompson29840e82015-04-06 15:21:21 -0700262
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800263::
Jeff Thompson29840e82015-04-06 15:21:21 -0700264
Junxiao Shi78ce2952019-05-07 15:34:00 -0400265 SignatureValue = SIGNATURE-VALUE-TYPE
266 TLV-LENGTH ; == 32
267 32OCTET ; == HMAC{Name, MetaInfo, Content, SignatureInfo}
Jeff Thompson29840e82015-04-06 15:21:21 -0700268
Junxiao Shi78ce2952019-05-07 15:34:00 -0400269 InterestSignatureValue = INTEREST-SIGNATURE-VALUE-TYPE
270 TLV-LENGTH ; == 32
271 32OCTET ; == HMAC{Name(without T, L, and ParametersSha256DigestComponent),
272 ApplicationParameters, InterestSignatureInfo}
Zhiyi Zhang0c04fd82018-09-04 16:29:47 -0400273
Jeff Thompson29840e82015-04-06 15:21:21 -0700274.. note::
275
276 The shared secret key is not included in the signature and must not be included anywhere in the data packet, as it would invalidate security properties of HMAC.
277
278.. note::
279
280 As stated in `Section 3 of RFC 2104 <http://tools.ietf.org/html/rfc2104#section-3>`__, shared keys shorter than the SHA256 output byte length (32 bytes) are strongly discouraged.
281
282Provided that the signature verifies, this type of signature ensures provenance that the Data packet was signed by one of the parties who holds the shared key.
283The shared key used to generate HMAC signature can be identified by the :ref:`KeyLocator` block in :ref:`SignatureInfo <Signature>`, e.g., by using the ``Name`` according to application's naming conventions.
284It is the application's responsibility to establish association between the shared key and the identities of the parties who hold the shared key.
285
Junxiao Shi78ce2952019-05-07 15:34:00 -0400286.. bibliography:: ndnspec-refs.bib