blob: 21c9df1ef87edc34c149c8c1853b8756fe79ee6c [file] [log] [blame]
Alexander Afanasyeve2800232013-11-27 02:24:14 +00001.. _Signature:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +00002
3Signature
4---------
5
Alexander Afanasyeve2800232013-11-27 02:24:14 +00006NDN Signature is defined as two consecutive TLV blocks: ``SignatureInfo`` and ``SignatureValue``.
7The following general considerations about SignatureInfo and SignatureValue blocks that apply for all signature types:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +00008
Zhiyi Zhang47e51372019-02-25 13:47:01 -080091. ``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 +000010
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000112. ``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 +000012
Alexander Afanasyev7455e9b2014-06-25 09:41:08 -070013The 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).
14
Alexander Afanasyeve2800232013-11-27 02:24:14 +000015::
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000016
Alexander Afanasyeve2800232013-11-27 02:24:14 +000017 Signature ::= SignatureInfo
Alexander Afanasyev9e0791a2015-06-12 19:00:31 -070018 SignatureValue
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000019
Alexander Afanasyeve2800232013-11-27 02:24:14 +000020 SignatureInfo ::= SIGNATURE-INFO-TYPE TLV-LENGTH
21 SignatureType
Alexander Afanasyev4b896112014-06-23 21:47:15 -070022 KeyLocator?
Zhiyi Zhang47e51372019-02-25 13:47:01 -080023 SignatureNonce?
24 Timestamp?
Alexander Afanasyeve2800232013-11-27 02:24:14 +000025 ... (SignatureType-specific TLVs)
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000026
Alexander Afanasyev23c2e412014-02-12 19:53:48 +000027 SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH
Zhiyi Zhang47e51372019-02-25 13:47:01 -080028 BYTE+
29
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000030
Alexander Afanasyeve2800232013-11-27 02:24:14 +000031SignatureType
32~~~~~~~~~~~~~
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000033
Alexander Afanasyeve2800232013-11-27 02:24:14 +000034::
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000035
Alexander Afanasyeve2800232013-11-27 02:24:14 +000036 SignatureType ::= SIGNATURE-TYPE-TYPE TLV-LENGTH
37 nonNegativeInteger
Jeff Thompsond4225d42014-06-09 12:32:21 -070038
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000039
Alexander Afanasyeve2800232013-11-27 02:24:14 +000040This specification defines the following SignatureType values:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000041
Jeff Thompsond4225d42014-06-09 12:32:21 -070042+---------+----------------------------------------+-------------------------------------------------+
43| Value | Reference | Description |
44+=========+========================================+=================================================+
45| 0 | :ref:`DigestSha256` | Integrity protection using SHA-256 digest |
46+---------+----------------------------------------+-------------------------------------------------+
47| 1 | :ref:`SignatureSha256WithRsa` | Integrity and provenance protection using |
48| | | RSA signature over a SHA-256 digest |
49+---------+----------------------------------------+-------------------------------------------------+
50| 3 | :ref:`SignatureSha256WithEcdsa` | Integrity and provenance protection using |
51| | | an ECDSA signature over a SHA-256 digest |
52+---------+----------------------------------------+-------------------------------------------------+
Jeff Thompson29840e82015-04-06 15:21:21 -070053| 4 | :ref:`SignatureHmacWithSha256` | Integrity and provenance protection using |
54| | | SHA256 hash-based message authentication codes |
55+---------+----------------------------------------+-------------------------------------------------+
56| 2,5-200 | | reserved for future assignments |
Jeff Thompsond4225d42014-06-09 12:32:21 -070057+---------+----------------------------------------+-------------------------------------------------+
58| >200 | | unassigned |
59+---------+----------------------------------------+-------------------------------------------------+
Alexander Afanasyeveee8c252013-11-21 23:22:41 +000060
Alexander Afanasyev4b896112014-06-23 21:47:15 -070061.. _KeyLocator:
62
63KeyLocator
64~~~~~~~~~~
65
Alexander Afanasyev7455e9b2014-06-25 09:41:08 -070066A ``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 -070067Note 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.
68
69::
70
71 KeyLocator ::= KEY-LOCATOR-TYPE TLV-LENGTH (Name | KeyDigest)
72
73 KeyDigest ::= KEY-DIGEST-TYPE TLV-LENGTH BYTE+
74
75See :ref:`Name specification <Name>` for the definition of Name field.
76
77The specific definition of the usage of ``Name`` and ``KeyDigest`` options in ``KeyLocator`` field is outside the scope of this specification.
78Generally, ``Name`` names the Data packet with the corresponding certificate.
79However, 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.
80For 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.
81
Zhiyi Zhang47e51372019-02-25 13:47:01 -080082.. _SignatureInfoNonce:
83
84SignatureNonce
85~~~~~~~~~~~~~~
86
87::
88
89 SignatureNonce ::= SIGNATURE-NONCE-TYPE TLV-LENGTH(=4)
90 BYTE{4}
91
92
93The ``SignatureNonce`` element adds additional assurances that a signature will be unique.
94
95.. _Timestamp:
96
97Timestamp
98~~~~~~~~~
99
100::
101
102 Timestamp ::= TIMESTAMP-TYPE TLV-LENGTH
103 nonNegativeInteger
104
105
106The value of the ``Timestamp`` element is the signature's timestamp (in terms of milliseconds since 1970-01-01 00:00:00 UTC) encoded as nonNegativeInteger.
107The timestamp may be used to protect against replay attacks.
108
109Different Types of Signature
110~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111
112Each signature type has different requirements on the format of its ``SignatureInfo`` element.
113In the following sections, these requirements are specified along 3 dimensions:
114
115* The TLV-VALUE of ``SignatureType``
116* ``KeyLocator`` is required/forbidden
117* If ``SignatureType``-specific elements are needed, express so using a ``SignatureInfoByType`` rule
118
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000119.. _DigestSha256:
Alexander Afanasyeveee8c252013-11-21 23:22:41 +0000120
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000121DigestSha256
122^^^^^^^^^^^^
Alexander Afanasyeveee8c252013-11-21 23:22:41 +0000123
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000124``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 -0700125This 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 +0000126
127``DigestSha256`` is defined as a SHA256 hash of the :ref:`Name`, :ref:`MetaInfo`, :ref:`Content`, and :ref:`SignatureInfo <Signature>` TLVs:
128
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800129* The TLV-VALUE of ``SignatureType`` is 0
130* ``KeyLocator`` is forbidden; if present, it must be ignored
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000131
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800132::
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000133
Alexander Afanasyev23c2e412014-02-12 19:53:48 +0000134 SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH(=32)
135 BYTE+(=SHA256{Name, MetaInfo, Content, SignatureInfo})
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000136
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000137.. _SignatureSha256WithRsa:
138
139SignatureSha256WithRsa
140^^^^^^^^^^^^^^^^^^^^^^
141
142``SignatureSha256WithRsa`` is the basic signature algorithm that MUST be supported by any NDN-compliant software.
143As 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.
144
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800145* The TLV-VALUE of ``SignatureType`` is 1
146* ``KeyLocator`` is required
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000147
148::
149
Alexander Afanasyev23c2e412014-02-12 19:53:48 +0000150 SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH
151 BYTE+(=RSA over SHA256{Name, MetaInfo, Content, SignatureInfo})
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000152
Alexander Afanasyev16962fc2014-02-12 19:53:47 +0000153.. note::
154
155 SignatureValue size varies (typically 128 or 256 bytes) depending on the private key length used during the signing process.
Alexander Afanasyeve2800232013-11-27 02:24:14 +0000156
157This 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 -0700158The signature issuer is identified using :ref:`KeyLocator` block in :ref:`SignatureInfo <Signature>` block of ``SignatureSha256WithRsa``.
Alexander Afanasyev4b896112014-06-23 21:47:15 -0700159KeyDigest 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 +0000160See :ref:`KeyLocator section <KeyLocator>` for more detail.
161
162.. note::
163
164 It is application's responsibility to define rules (trust model) of when a specific issuer (KeyLocator) is authorized to sign a specific Data packet.
165 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 -0700166 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 +0000167
Jeff Thompsond4225d42014-06-09 12:32:21 -0700168.. _SignatureSha256WithEcdsa:
169
170SignatureSha256WithEcdsa
171^^^^^^^^^^^^^^^^^^^^^^^^
172
173``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.
174The signature algorithm is defined in `[RFC5753], Section 2.1 <http://tools.ietf.org/html/rfc5753#section-2.1>`_.
175
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800176* The TLV-VALUE of ``SignatureType`` is 3
177* ``KeyLocator`` is required
Jeff Thompsond4225d42014-06-09 12:32:21 -0700178
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800179::
Jeff Thompsond4225d42014-06-09 12:32:21 -0700180
181 SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH
182 BYTE+(=ECDSA over SHA256{Name, MetaInfo, Content, SignatureInfo})
183
184.. note::
185
186 The SignatureValue size depends on the private key length used during the signing process (about 63 bytes for a 224 bit key).
187
188This 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.
189The 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 -0700190KeyDigest 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 -0700191See the :ref:`KeyLocator section <KeyLocator>` for more detail.
192
193The value of ``SignatureValue`` of ``SignatureSha256WithEcdsa`` is a DER encoded DSA signature as defined in `Section 2.2.3 in RFC 3279 <http://tools.ietf.org/html/rfc3279#section-2.2.3>`_.
194
195::
196
197 Ecdsa-Sig-Value ::= SEQUENCE {
198 r INTEGER,
199 s INTEGER }
200
Jeff Thompson29840e82015-04-06 15:21:21 -0700201.. _SignatureHmacWithSha256:
202
203SignatureHmacWithSha256
204^^^^^^^^^^^^^^^^^^^^^^^
205
206``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.
207The signature algorithm is defined in `Section 2 in RFC 2104 <http://tools.ietf.org/html/rfc2104#section-2>`__.
208
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800209* The TLV-VALUE of ``SignatureType`` is 4
210* ``KeyLocator`` is required
Jeff Thompson29840e82015-04-06 15:21:21 -0700211
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800212::
Jeff Thompson29840e82015-04-06 15:21:21 -0700213
214 SignatureValue ::= SIGNATURE-VALUE-TYPE TLV-LENGTH(=32)
215 BYTE+(=HMAC{Name, MetaInfo, Content, SignatureInfo})
216
217.. note::
218
219 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.
220
221.. note::
222
223 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.
224
225Provided 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.
226The 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.
227It is the application's responsibility to establish association between the shared key and the identities of the parties who hold the shared key.
228
Zhiyi Zhang47e51372019-02-25 13:47:01 -0800229.. bibliography:: ndnspec-refs.bib