Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix 543: improve COSE_Key spec language and add COSE_Key examples #732

Merged
merged 10 commits into from
Jan 12, 2018
84 changes: 80 additions & 4 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2487,7 +2487,7 @@ object=] for a given credential. It has the following format:
<tr>
<td><dfn>credentialIdLength</dfn></td>
<td>2</td>
<td>Byte length L of Credential ID</td>
<td>Byte length <strong>L</strong> of Credential ID</td>
</tr>
<tr>
<td><dfn>credentialId</dfn></td>
Expand All @@ -2498,16 +2498,92 @@ object=] for a given credential. It has the following format:
<td><dfn>credentialPublicKey</dfn></td>
<td>variable</td>
<td>
The [=credential public key=] encoded in COSE_Key format, as defined in Section 7 of [[!RFC8152]].
The encoded [=credential public key=] MUST contain the "alg" parameter and MUST NOT contain any other optional
parameters. The "alg" parameter MUST contain a {{COSEAlgorithmIdentifier}} value.
The [=credential public key=] encoded in COSE_Key format,
as defined in Section 7 of [[RFC8152]], using the [=CTAP canonical CBOR encoding form=].
The COSE_Key-encoded [=credential public key=] MUST contain the optional "alg" parameter and MUST NOT
contain any other optional parameters. The "alg" parameter MUST contain a {{COSEAlgorithmIdentifier}} value.
The encoded [=credential public key=] MUST also contain any additional required parameters stipulated by the
relevant key type specification, i.e., required for the key type "kty" and algorithm "alg" (see Section 8 of
[[RFC8152]]).
</td>
</tr>
</table>

NOTE: The names in the Name column in the above table are only for reference within this document, and are not present in the
actual representation of the [=attested credential data=].

#### Examples of `credentialPublicKey` Values encoded in COSE_Key format #### {#sctn-encoded-credPubKey-examples}

This section provides examples of COSE_Key-encoded Eliptic Curve and RSA public keys for the ES256, PS256, and RS256
signature algorithms. These examples adhere to the rules defined above for the [=credentialPublicKey=] value, and are presented in [[CDDL]] for clarity.

[[RFC8152]] [Section 7](https://tools.ietf.org/html/rfc8152#section-7) defines the general framework for all
COSE_Key-encoded keys.
Specific key types for specific algorithms are defined in other sections of [[RFC8152]] as well as in other specifications,
as noted below.

Below is an example of a COSE_Key-encoded Eliptic Curve public key in EC2 format (see [[RFC8152]]
[Section 13.1](https://tools.ietf.org/html/rfc8152#section-13.1)), on the P-256 curve, to be used with the ES256 signature
algorithm (ECDSA w/ SHA-256, see [[RFC8152]] [Section 8.1](https://tools.ietf.org/html/rfc8152#section-8.1)):

<pre class="example" highlight="json">
{
1: 2, ; kty: EC2 key type
3: -7, ; alg: ES256 signature algorithm
-1: 1, ; crv: P-256 curve
-2: x, ; x-coordinate as byte string 32 bytes in length
; e.g., in hex: 65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c08551d
-3: y ; y-coordinate as byte string 32 bytes in length
; e.g., in hex: 1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd0084d19c
}
</pre>

Below is the above Eliptic Curve public key encoded in the [=CTAP canonical CBOR encoding form=], whitespace and line breaks
are included here for clarity and to match the [[CDDL]] presentation above:

<pre class="example" highlight="json">
A5
01 02

03 26

20 01

21 58 20 65eda5a12577c2bae829437fe338701a10aaa375e1bb5b5de108de439c08551d

22 58 20 1e52ed75701163f7f9e40ddf9f341b3dc9ba860af7e0ca7ca7e9eecd0084d19c
</pre>


Below is an example of a COSE_Key-encoded 2048-bit RSA public key (see [[RFC8230]] [Section 4](https://tools.ietf.org/html/rfc8230#section-4)),
to be used with the PS256 signature algorithm
(RSASSA-PSS with SHA-256, see [[RFC8230]] [Section 2](https://tools.ietf.org/html/rfc8230#section-2)):

<pre class="example" highlight="json">
{
1: 3, ; kty: RSA key type
3: -37, ; alg: PS256
-1: n, ; n: RSA modulus n byte string 256 bytes in length
; e.g., in hex (middle bytes elided for brevity): DB5F651550...6DC6548ACC3
-2: e ; e: RSA public exponent e byte string 3 bytes in length
; e.g., in hex: 010001
}
</pre>

Below is an example of the same COSE_Key-encoded RSA public key as above,
to be used with the RS256 signature algorithm (RSASSA-PKCS1-v1_5 with SHA-256, see [[#sctn-cose-alg-reg]]):

<pre class="example" highlight="json">
{
1: 3, ; kty: RSA key type
3:-257, ; alg: RS256
-1: n, ; n: RSA modulus n byte string 256 bytes in length
; e.g., in hex (middle bytes elided for brevity): DB5F651550...6DC6548ACC3
-2: e ; e: RSA public exponent e byte string 3 bytes in length
; e.g., in hex: 010001
}
</pre>


### Attestation Statement Formats ### {#attestation-formats}

Expand Down