draft-ietf-cose-msg-11.txt   draft-ietf-cose-msg-12.txt 
COSE Working Group J. Schaad COSE Working Group J. Schaad
Internet-Draft August Cellars Internet-Draft August Cellars
Intended status: Informational March 21, 2016 Intended status: Standards Track May 12, 2016
Expires: September 22, 2016 Expires: November 13, 2016
CBOR Encoded Message Syntax CBOR Encoded Message Syntax
draft-ietf-cose-msg-11 draft-ietf-cose-msg-12
Abstract Abstract
Concise Binary Object Representation (CBOR) is data format designed Concise Binary Object Representation (CBOR) is data format designed
for small code size and small message size. There is a need for the for small code size and small message size. There is a need for the
ability to have the basic security services defined for this data ability to have the basic security services defined for this data
format. This document specifies processing for signatures, message format. This document specifies processing for signatures, message
authentication codes, and encryption using CBOR. This document also authentication codes, and encryption using CBOR. This document also
specifies a representation for cryptographic keys using CBOR. specifies a representation for cryptographic keys using CBOR.
skipping to change at page 1, line 43 skipping to change at page 1, line 43
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at http://datatracker.ietf.org/drafts/current/. Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on September 22, 2016. This Internet-Draft will expire on November 13, 2016.
Copyright Notice Copyright Notice
Copyright (c) 2016 IETF Trust and the persons identified as the Copyright (c) 2016 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of (http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents publication of this document. Please review these documents
skipping to change at page 2, line 22 skipping to change at page 2, line 22
the Trust Legal Provisions and are provided without warranty as the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License. described in the Simplified BSD License.
Table of Contents Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1. Design changes from JOSE . . . . . . . . . . . . . . . . 5 1.1. Design changes from JOSE . . . . . . . . . . . . . . . . 5
1.2. Requirements Terminology . . . . . . . . . . . . . . . . 6 1.2. Requirements Terminology . . . . . . . . . . . . . . . . 6
1.3. CBOR Grammar . . . . . . . . . . . . . . . . . . . . . . 6 1.3. CBOR Grammar . . . . . . . . . . . . . . . . . . . . . . 6
1.4. CBOR Related Terminology . . . . . . . . . . . . . . . . 7 1.4. CBOR Related Terminology . . . . . . . . . . . . . . . . 7
1.5. Document Terminology . . . . . . . . . . . . . . . . . . 8 1.5. Document Terminology . . . . . . . . . . . . . . . . . . 7
2. Basic COSE Structure . . . . . . . . . . . . . . . . . . . . 8 2. Basic COSE Structure . . . . . . . . . . . . . . . . . . . . 8
3. Header Parameters . . . . . . . . . . . . . . . . . . . . . . 10 3. Header Parameters . . . . . . . . . . . . . . . . . . . . . . 9
3.1. Common COSE Headers Parameters . . . . . . . . . . . . . 12 3.1. Common COSE Headers Parameters . . . . . . . . . . . . . 11
4. Signing Objects . . . . . . . . . . . . . . . . . . . . . . . 16 4. Signing Objects . . . . . . . . . . . . . . . . . . . . . . . 15
4.1. Signing with One or More Signers . . . . . . . . . . . . 16 4.1. Signing with One or More Signers . . . . . . . . . . . . 15
4.2. Signing with One Signer . . . . . . . . . . . . . . . . . 18 4.2. Signing with One Signer . . . . . . . . . . . . . . . . . 17
4.3. Externally Supplied Data . . . . . . . . . . . . . . . . 19 4.3. Externally Supplied Data . . . . . . . . . . . . . . . . 18
4.4. Signing and Verification Process . . . . . . . . . . . . 20 4.4. Signing and Verification Process . . . . . . . . . . . . 19
4.5. Computing Counter Signatures . . . . . . . . . . . . . . 21 4.5. Computing Counter Signatures . . . . . . . . . . . . . . 20
5. Encryption Objects . . . . . . . . . . . . . . . . . . . . . 22 5. Encryption Objects . . . . . . . . . . . . . . . . . . . . . 21
5.1. Enveloped COSE Structure . . . . . . . . . . . . . . . . 22 5.1. Enveloped COSE Structure . . . . . . . . . . . . . . . . 21
5.1.1. Recipient Algorithm Classes . . . . . . . . . . . . . 24 5.1.1. Recipient Algorithm Classes . . . . . . . . . . . . . 23
5.2. Encrypted COSE structure . . . . . . . . . . . . . . . . 24 5.2. Single Recipient Encrypted . . . . . . . . . . . . . . . 23
5.3. Encryption Algorithm for AEAD algorithms . . . . . . . . 25 5.3. Encryption Algorithm for AEAD algorithms . . . . . . . . 24
5.4. Encryption algorithm for AE algorithms . . . . . . . . . 27 5.4. Encryption algorithm for AE algorithms . . . . . . . . . 26
6. MAC Objects . . . . . . . . . . . . . . . . . . . . . . . . . 28 6. MAC Objects . . . . . . . . . . . . . . . . . . . . . . . . . 27
6.1. MAC Message with Recipients . . . . . . . . . . . . . . . 28 6.1. MAC Message with Recipients . . . . . . . . . . . . . . . 28
6.2. MAC Messages with Implicit Key . . . . . . . . . . . . . 30 6.2. MAC Messages with Implicit Key . . . . . . . . . . . . . 29
6.3. How to compute and verify a MAC . . . . . . . . . . . . . 30 6.3. How to compute and verify a MAC . . . . . . . . . . . . . 30
7. Key Structure . . . . . . . . . . . . . . . . . . . . . . . . 32 7. Key Structure . . . . . . . . . . . . . . . . . . . . . . . . 31
7.1. COSE Key Common Parameters . . . . . . . . . . . . . . . 32 7.1. COSE Key Common Parameters . . . . . . . . . . . . . . . 32
8. Signature Algorithms . . . . . . . . . . . . . . . . . . . . 35 8. Signature Algorithms . . . . . . . . . . . . . . . . . . . . 34
8.1. ECDSA . . . . . . . . . . . . . . . . . . . . . . . . . . 36 8.1. ECDSA . . . . . . . . . . . . . . . . . . . . . . . . . . 35
8.1.1. Security Considerations . . . . . . . . . . . . . . . 38 8.1.1. Security Considerations . . . . . . . . . . . . . . . 37
8.2. Edwards-curve Digital Signature Algorithms (EdDSA) . . . 38
8.2.1. Security Considerations . . . . . . . . . . . . . . . 39
9. Message Authentication (MAC) Algorithms . . . . . . . . . . . 39 9. Message Authentication (MAC) Algorithms . . . . . . . . . . . 39
9.1. Hash-based Message Authentication Codes (HMAC) . . . . . 39 9.1. Hash-based Message Authentication Codes (HMAC) . . . . . 39
9.1.1. Security Considerations . . . . . . . . . . . . . . . 41 9.1.1. Security Considerations . . . . . . . . . . . . . . . 41
9.2. AES Message Authentication Code (AES-CBC-MAC) . . . . . . 41 9.2. AES Message Authentication Code (AES-CBC-MAC) . . . . . . 41
9.2.1. Security Considerations . . . . . . . . . . . . . . . 42 9.2.1. Security Considerations . . . . . . . . . . . . . . . 42
10. Content Encryption Algorithms . . . . . . . . . . . . . . . . 42 10. Content Encryption Algorithms . . . . . . . . . . . . . . . . 42
10.1. AES GCM . . . . . . . . . . . . . . . . . . . . . . . . 43 10.1. AES GCM . . . . . . . . . . . . . . . . . . . . . . . . 43
10.1.1. Security Considerations . . . . . . . . . . . . . . 44 10.1.1. Security Considerations . . . . . . . . . . . . . . 44
10.2. AES CCM . . . . . . . . . . . . . . . . . . . . . . . . 44 10.2. AES CCM . . . . . . . . . . . . . . . . . . . . . . . . 44
10.2.1. Security Considerations . . . . . . . . . . . . . . 47 10.2.1. Security Considerations . . . . . . . . . . . . . . 47
10.3. ChaCha20 and Poly1305 . . . . . . . . . . . . . . . . . 47 10.3. ChaCha20 and Poly1305 . . . . . . . . . . . . . . . . . 47
10.3.1. Security Considerations . . . . . . . . . . . . . . 48 10.3.1. Security Considerations . . . . . . . . . . . . . . 48
11. Key Derivation Functions (KDF) . . . . . . . . . . . . . . . 48 11. Key Derivation Functions (KDF) . . . . . . . . . . . . . . . 48
11.1. HMAC-based Extract-and-Expand Key Derivation Function 11.1. HMAC-based Extract-and-Expand Key Derivation Function
(HKDF) . . . . . . . . . . . . . . . . . . . . . . . . . 49 (HKDF) . . . . . . . . . . . . . . . . . . . . . . . . . 49
11.2. Context Information Structure . . . . . . . . . . . . . 51 11.2. Context Information Structure . . . . . . . . . . . . . 51
12. Recipient Algorithm Classes . . . . . . . . . . . . . . . . . 54 12. Recipient Algorithm Classes . . . . . . . . . . . . . . . . . 54
12.1. Direct Encryption . . . . . . . . . . . . . . . . . . . 55 12.1. Direct Encryption . . . . . . . . . . . . . . . . . . . 55
12.1.1. Direct Key . . . . . . . . . . . . . . . . . . . . . 55 12.1.1. Direct Key . . . . . . . . . . . . . . . . . . . . . 55
12.1.2. Direct Key with KDF . . . . . . . . . . . . . . . . 56 12.1.2. Direct Key with KDF . . . . . . . . . . . . . . . . 56
12.2. Key Wrapping . . . . . . . . . . . . . . . . . . . . . . 57 12.2. Key Wrapping . . . . . . . . . . . . . . . . . . . . . . 58
12.2.1. AES Key Wrapping . . . . . . . . . . . . . . . . . . 58 12.2.1. AES Key Wrapping . . . . . . . . . . . . . . . . . . 58
12.3. Key Encryption . . . . . . . . . . . . . . . . . . . . . 59 12.3. Key Encryption . . . . . . . . . . . . . . . . . . . . . 59
12.4. Direct Key Agreement . . . . . . . . . . . . . . . . . . 59 12.4. Direct Key Agreement . . . . . . . . . . . . . . . . . . 60
12.4.1. ECDH . . . . . . . . . . . . . . . . . . . . . . . . 60 12.4.1. ECDH . . . . . . . . . . . . . . . . . . . . . . . . 61
12.5. Key Agreement with KDF . . . . . . . . . . . . . . . . . 64 12.5. Key Agreement with KDF . . . . . . . . . . . . . . . . . 63
12.5.1. ECDH . . . . . . . . . . . . . . . . . . . . . . . . 64 12.5.1. ECDH . . . . . . . . . . . . . . . . . . . . . . . . 64
13. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 13. Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
13.1. Elliptic Curve Keys . . . . . . . . . . . . . . . . . . 65 13.1. Elliptic Curve Keys . . . . . . . . . . . . . . . . . . 66
13.1.1. Double Coordinate Curves . . . . . . . . . . . . . . 66 13.1.1. Double Coordinate Curves . . . . . . . . . . . . . . 67
13.2. Symmetric Keys . . . . . . . . . . . . . . . . . . . . . 67 13.2. Octet Key Pair . . . . . . . . . . . . . . . . . . . . . 68
14. CBOR Encoder Restrictions . . . . . . . . . . . . . . . . . . 68 13.3. Symmetric Keys . . . . . . . . . . . . . . . . . . . . . 69
15. Application Profiling Considerations . . . . . . . . . . . . 68 14. CBOR Encoder Restrictions . . . . . . . . . . . . . . . . . . 70
16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 69 15. Application Profiling Considerations . . . . . . . . . . . . 70
16.1. CBOR Tag assignment . . . . . . . . . . . . . . . . . . 69 16. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 72
16.2. COSE Header Parameter Registry . . . . . . . . . . . . . 70 16.1. CBOR Tag assignment . . . . . . . . . . . . . . . . . . 72
16.3. COSE Header Algorithm Label Table . . . . . . . . . . . 70 16.2. COSE Header Parameter Registry . . . . . . . . . . . . . 72
16.4. COSE Algorithm Registry . . . . . . . . . . . . . . . . 71 16.3. COSE Header Algorithm Label Table . . . . . . . . . . . 73
16.5. COSE Key Common Parameter Registry . . . . . . . . . . . 72 16.4. COSE Algorithm Registry . . . . . . . . . . . . . . . . 73
16.6. COSE Key Type Parameter Registry . . . . . . . . . . . . 73 16.5. COSE Key Common Parameter Registry . . . . . . . . . . . 74
16.7. COSE Elliptic Curve Registry . . . . . . . . . . . . . . 73 16.6. COSE Key Type Parameter Registry . . . . . . . . . . . . 75
16.8. Media Type Registrations . . . . . . . . . . . . . . . . 74 16.7. COSE Elliptic Curve Registry . . . . . . . . . . . . . . 76
16.8.1. COSE Security Message . . . . . . . . . . . . . . . 74 16.8. Media Type Registrations . . . . . . . . . . . . . . . . 76
16.8.2. COSE Key media type . . . . . . . . . . . . . . . . 75 16.8.1. COSE Security Message . . . . . . . . . . . . . . . 76
16.9. CoAP Content Format Registrations . . . . . . . . . . . 77 16.8.2. COSE Key media type . . . . . . . . . . . . . . . . 77
16.10. Expert Review Instructions . . . . . . . . . . . . . . . 78 16.9. CoAP Content Format Registrations . . . . . . . . . . . 79
17. Security Considerations . . . . . . . . . . . . . . . . . . . 79 16.10. Expert Review Instructions . . . . . . . . . . . . . . . 80
18. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 80 17. Implementation Status . . . . . . . . . . . . . . . . . . . . 81
19. References . . . . . . . . . . . . . . . . . . . . . . . . . 80 17.1. Author's Versions . . . . . . . . . . . . . . . . . . . 82
19.1. Normative References . . . . . . . . . . . . . . . . . . 80 17.2. COSE Testing Library . . . . . . . . . . . . . . . . . . 82
19.2. Informative References . . . . . . . . . . . . . . . . . 81 18. Security Considerations . . . . . . . . . . . . . . . . . . . 83
Appendix A. Making Mandatory Algorithm Header Optional . . . . . 84 19. References . . . . . . . . . . . . . . . . . . . . . . . . . 85
A.1. Algorithm Identification . . . . . . . . . . . . . . . . 84 19.1. Normative References . . . . . . . . . . . . . . . . . . 85
A.2. Counter Signature Without Headers . . . . . . . . . . . . 87 19.2. Informative References . . . . . . . . . . . . . . . . . 86
Appendix A. Making Mandatory Algorithm Header Optional . . . . . 88
Appendix B. Three Levels of Recipient Information . . . . . . . 88 A.1. Algorithm Identification . . . . . . . . . . . . . . . . 89
Appendix C. Examples . . . . . . . . . . . . . . . . . . . . . . 89 A.2. Counter Signature Without Headers . . . . . . . . . . . . 92
C.1. Examples of Signed Message . . . . . . . . . . . . . . . 90 Appendix B. Three Levels of Recipient Information . . . . . . . 92
C.1.1. Single Signature . . . . . . . . . . . . . . . . . . 90 Appendix C. Examples . . . . . . . . . . . . . . . . . . . . . . 93
C.1.2. Multiple Signers . . . . . . . . . . . . . . . . . . 91 C.1. Examples of Signed Message . . . . . . . . . . . . . . . 94
C.1.3. Counter Signature . . . . . . . . . . . . . . . . . . 92 C.1.1. Single Signature . . . . . . . . . . . . . . . . . . 94
C.1.4. Signature w/ Operation Time and Criticality . . . . . 93 C.1.2. Multiple Signers . . . . . . . . . . . . . . . . . . 94
C.2. Single Signer Examples . . . . . . . . . . . . . . . . . 94 C.1.3. Counter Signature . . . . . . . . . . . . . . . . . . 95
C.2.1. Single ECDSA signature . . . . . . . . . . . . . . . 94 C.1.4. Signature w/ Criticality . . . . . . . . . . . . . . 96
C.3. Examples of Enveloped Messages . . . . . . . . . . . . . 95 C.2. Single Signer Examples . . . . . . . . . . . . . . . . . 97
C.3.1. Direct ECDH . . . . . . . . . . . . . . . . . . . . . 95 C.2.1. Single ECDSA signature . . . . . . . . . . . . . . . 97
C.3.2. Direct plus Key Derivation . . . . . . . . . . . . . 96 C.3. Examples of Enveloped Messages . . . . . . . . . . . . . 98
C.3.3. Counter Signature on Encrypted Content . . . . . . . 97 C.3.1. Direct ECDH . . . . . . . . . . . . . . . . . . . . . 98
C.3.4. Encrypted Content with External Data . . . . . . . . 99 C.3.2. Direct plus Key Derivation . . . . . . . . . . . . . 99
C.4. Examples of Encrypted Messages . . . . . . . . . . . . . 99 C.3.3. Counter Signature on Encrypted Content . . . . . . . 100
C.4.1. Simple Encrypted Message . . . . . . . . . . . . . . 99 C.3.4. Encrypted Content with External Data . . . . . . . . 102
C.4.2. Encrypted Message w/ a Partial IV . . . . . . . . . . 100 C.4. Examples of Encrypted Messages . . . . . . . . . . . . . 102
C.5. Examples of MAC messages . . . . . . . . . . . . . . . . 100 C.4.1. Simple Encrypted Message . . . . . . . . . . . . . . 102
C.5.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 100 C.4.2. Encrypted Message w/ a Partial IV . . . . . . . . . . 103
C.5.2. ECDH Direct MAC . . . . . . . . . . . . . . . . . . . 101 C.5. Examples of MAC messages . . . . . . . . . . . . . . . . 103
C.5.3. Wrapped MAC . . . . . . . . . . . . . . . . . . . . . 102 C.5.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 103
C.5.4. Multi-recipient MAC message . . . . . . . . . . . . . 103 C.5.2. ECDH Direct MAC . . . . . . . . . . . . . . . . . . . 104
C.6. Examples of MAC0 messages . . . . . . . . . . . . . . . . 104 C.5.3. Wrapped MAC . . . . . . . . . . . . . . . . . . . . . 105
C.6.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 104 C.5.4. Multi-recipient MAC message . . . . . . . . . . . . . 106
C.7. COSE Keys . . . . . . . . . . . . . . . . . . . . . . . . 105 C.6. Examples of MAC0 messages . . . . . . . . . . . . . . . . 107
C.7.1. Public Keys . . . . . . . . . . . . . . . . . . . . . 105 C.6.1. Shared Secret Direct MAC . . . . . . . . . . . . . . 108
C.7.2. Private Keys . . . . . . . . . . . . . . . . . . . . 106 C.7. COSE Keys . . . . . . . . . . . . . . . . . . . . . . . . 108
Appendix D. Document Updates . . . . . . . . . . . . . . . . . . 108 C.7.1. Public Keys . . . . . . . . . . . . . . . . . . . . . 108
D.1. Version -09 to -10 . . . . . . . . . . . . . . . . . . . 108 C.7.2. Private Keys . . . . . . . . . . . . . . . . . . . . 109
D.2. Version -08 to -09 . . . . . . . . . . . . . . . . . . . 109 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . 111
D.3. Version -07 to -08 . . . . . . . . . . . . . . . . . . . 109 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 112
D.4. Version -06 to -07 . . . . . . . . . . . . . . . . . . . 109
D.5. Version -05 to -06 . . . . . . . . . . . . . . . . . . . 109
D.6. Version -04 to -05 . . . . . . . . . . . . . . . . . . . 109
D.7. Version -03 to -04 . . . . . . . . . . . . . . . . . . . 110
D.8. Version -02 to -03 . . . . . . . . . . . . . . . . . . . 110
D.9. Version -02 to -03 . . . . . . . . . . . . . . . . . . . 110
D.10. Version -01 to -2 . . . . . . . . . . . . . . . . . . . . 110
D.11. Version -00 to -01 . . . . . . . . . . . . . . . . . . . 111
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 111
1. Introduction 1. Introduction
There has been an increased focus on the small, constrained devices There has been an increased focus on the small, constrained devices
that make up the Internet of Things (IOT). One of the standards that that make up the Internet of Things (IOT). One of the standards that
has come out of this process is the Concise Binary Object has come out of this process is the Concise Binary Object
Representation (CBOR). CBOR extended the data model of the Representation (CBOR) [RFC7049]. CBOR extended the data model of the
JavaScript Object Notation (JSON) by allowing for binary data among JavaScript Object Notation (JSON) [RFC7159] by allowing for binary
other changes. CBOR is being adopted by several of the IETF working data among other changes. CBOR is being adopted by several of the
groups dealing with the IOT world as their encoding of data IETF working groups dealing with the IOT world as their encoding of
structures. CBOR was designed specifically to be both small in terms data structures. CBOR was designed specifically to be both small in
of messages transport and implementation size as well having a schema terms of messages transport and implementation size as well having a
free decoder. A need exists to provide message security services for schema free decoder. A need exists to provide message security
IOT and using CBOR as the message encoding format makes sense. services for IOT and using CBOR as the message encoding format makes
sense.
The JOSE working group produced a set of documents The JOSE working group produced a set of documents
[RFC7515][RFC7516][RFC7517][RFC7518] using JSON [RFC7159] that [RFC7515][RFC7516][RFC7517][RFC7518] using JSON that specified how to
specified how to process encryption, signatures and message process encryption, signatures and message authentication (MAC)
authentication (MAC) operations, and how to encode keys using JSON. operations, and how to encode keys using JSON. This document does
This document does the same work for use with the CBOR [RFC7049] the same work for use with the CBOR document format. While there is
document format. While there is a strong attempt to keep the flavor a strong attempt to keep the flavor of the original JOSE documents,
of the original JOSE documents, two considerations are taken into two considerations are taken into account:
account:
o CBOR has capabilities that are not present in JSON and should be o CBOR has capabilities that are not present in JSON and should be
used. One example of this is the fact that CBOR has a method of used. One example of this is the fact that CBOR has a method of
encoding binary directly without first converting it into a base64 encoding binary directly without first converting it into a base64
encoded string. encoded string.
o COSE is not a direct copy of the JOSE specification. In the o COSE is not a direct copy of the JOSE specification. In the
process of creating COSE, decisions that were made for JOSE were process of creating COSE, decisions that were made for JOSE were
re-examined. In many cases different results were decided on as re-examined. In many cases different results were decided on as
the criteria were not always the same as for JOSE. the criteria was not always the same.
1.1. Design changes from JOSE 1.1. Design changes from JOSE
o Define a top level message structure so that encrypted, signed and o Define a single top level message structure so that encrypted,
MACed messages can easily identified and still have a consistent signed and MACed messages can easily identified and still have a
view. consistent view.
o Signed messages separate the concept of protected and unprotected o Signed messages separate the concept of protected and unprotected
parameters that are for the content and the signature. parameters that are for the content and the signature.
o MAC messages are separated from signed messages. o MAC messages are separated from signed messages.
o MAC messages have the ability to use the same set of recipient o MAC messages have the ability to use the same set of recipient
algorithms as enveloped messages do to obtain the MAC algorithms as enveloped messages for obtaining the MAC
authentication key. authentication key.
o Use binary encodings for binary data rather than base64url o Use binary encodings for binary data rather than base64url
encodings. encodings.
o Combine the authentication tag for encryption algorithms with the o Combine the authentication tag for encryption algorithms with the
ciphertext. ciphertext.
o The set of cryptographic algorithms has been expanded in some o The set of cryptographic algorithms has been expanded in some
directions, and trimmed in others. directions, and trimmed in others.
skipping to change at page 6, line 25 skipping to change at page 6, line 22
When the words appear in lower case, their natural language meaning When the words appear in lower case, their natural language meaning
is used. is used.
1.3. CBOR Grammar 1.3. CBOR Grammar
There currently is no standard CBOR grammar available for use by There currently is no standard CBOR grammar available for use by
specifications. We therefore describe the CBOR structures in prose. specifications. We therefore describe the CBOR structures in prose.
The document was developed by first working on the grammar and then The document was developed by first working on the grammar and then
developing the prose to go with it. An artifact of this is that the developing the prose to go with it. An artifact of this is that the
prose was written using the primitive type strings defined by CDDL. prose was written using the primitive type strings defined by CBOR
Data Definition Language (CDDL) [I-D.greevenbosch-appsawg-cbor-cddl].
In this specification, the following primitive types are used: In this specification, the following primitive types are used:
any - non-specific value that permits all CBOR values to be placed any - non-specific value that permits all CBOR values to be placed
here. here.
bool - a boolean value (true: major type 7, value 21; false: major bool - a boolean value (true: major type 7, value 21; false: major
type 7, value 20). type 7, value 20).
bstr - byte string (major type 2). bstr - byte string (major type 2).
int - an unsigned integer or a negative integer. int - an unsigned integer or a negative integer.
nil - a null value (major type 7, value 22). nil - a null value (major type 7, value 22).
nint - a negative integer (major type 1). nint - a negative integer (major type 1).
tstr - a UTF-8 text string (major type 3). tstr - a UTF-8 text string (major type 3).
uint - an unsigned integer (major type 0). uint - an unsigned integer (major type 0).
There is a version of a CBOR grammar in the CBOR Data Definition As well as the prose description, a version of a CBOR grammar is
Language (CDDL) [I-D.greevenbosch-appsawg-cbor-cddl]. Since CDDL has presented in CDDL. Since CDDL has not be published as an RFC, this
not be published as an RFC, this grammar may not work with the final grammar may not work with the final version of CDDL. The CDDL
version of CDDL when it is published. For those people who prefer grammar is informational, the prose description is normative.
using a formal language to describe the syntax of the CBOR, an
informational version of the CBOR grammar is interweaved into the
text as well. The CDDL grammar is informational, the prose
description is normative.
The collected CDDL can be extracted from the XML version of this The collected CDDL can be extracted from the XML version of this
document via the following XPath expression below. (Depending on the document via the following XPath expression below. (Depending on the
XPath evaluator one is using, it may be necessary to deal with > XPath evaluator one is using, it may be necessary to deal with >
as an entity.) as an entity.)
//artwork[@type='CDDL']/text() //artwork[@type='CDDL']/text()
CDDL expects the initial non-terminal symbol to be the first symbol CDDL expects the initial non-terminal symbol to be the first symbol
in the file. For this reason the first fragment of CDDL is presented in the file. For this reason the first fragment of CDDL is presented
here. here.
start = COSE_Messages / COSE_Key / COSE_KeySet / Internal_Types start = COSE_Messages / COSE_Key / COSE_KeySet / Internal_Types
; This is define to make the tool quieter ; This is define to make the tool quieter
Internal_Types = Sig_structure / Enc_structure / MAC_structure / Internal_Types = Sig_structure / Enc_structure / MAC_structure /
skipping to change at page 8, line 7 skipping to change at page 7, line 44
A CDDL grammar fragment is defined that defines the non-terminals A CDDL grammar fragment is defined that defines the non-terminals
'label' as in the previous paragraph and 'values' which permits any 'label' as in the previous paragraph and 'values' which permits any
value to be used. value to be used.
label = int / tstr label = int / tstr
values = any values = any
1.5. Document Terminology 1.5. Document Terminology
In this document we use the following terminology: [CREF1] In this document we use the following terminology:
Byte is a synonym for octet. Byte is a synonym for octet.
Constrained Application Protocol (CoAP) is a specialized web transfer Constrained Application Protocol (CoAP) is a specialized web transfer
protocol for use in constrained systems. It is defined in [RFC7252]. protocol for use in constrained systems. It is defined in [RFC7252].
Key management is used as a term to describe how a key at level n is
obtained from level n+1 in encrypted and MACed messages. The term is
also used to discuss key life cycle management, this document does
not discuss key life cycle operations.
2. Basic COSE Structure 2. Basic COSE Structure
The COSE Message structure is designed so that there can be a large The COSE Message structure is designed so that there can be a large
amount of common code when parsing and processing the different amount of common code when parsing and processing the different
security messages. All of the message structures are built on the security messages. All of the message structures are built on the
CBOR array type. The first three elements of the array contain the CBOR array type. The first three elements of the array contain the
same information. same information.
1. The set of protected header parameters wrapped in a bstr. 1. The set of protected header parameters wrapped in a bstr.
2. The set of unprotected header parameters as a map. 2. The set of unprotected header parameters as a map.
3. The content of the message. The content is either the plain text 3. The content of the message. The content is either the plain text
or the cipher text as appropriate. (The content may be detached, or the cipher text as appropriate. The content may be detached,
but the location is still used.) but the location is still used. The content is wrapped in a bstr
when present and is a nil value when detached.
Elements after this point are dependent on the specific message type. Elements after this point are dependent on the specific message type.
Identification of which type of message has been presented is done by Identification of which type of message has been presented is done by
the following method: the following method:
1. The specific message type is known from the context. This may be 1. The specific message type is known from the context. This may be
defined by a marker in the containing structure or by defined by a marker in the containing structure or by
restrictions specified by the application protocol. restrictions specified by the application protocol.
skipping to change at page 9, line 9 skipping to change at page 8, line 45
3. When a COSE object is carried in a media type of application/ 3. When a COSE object is carried in a media type of application/
cose, the optional parameter 'cose-type' can be used to identify cose, the optional parameter 'cose-type' can be used to identify
the embedded object. The parameter is OPTIONAL if the tagged the embedded object. The parameter is OPTIONAL if the tagged
version of the structure is used. The parameter is REQUIRED if version of the structure is used. The parameter is REQUIRED if
the untagged version of the structure is used. The value to use the untagged version of the structure is used. The value to use
with the parameter for each of the structures can be found in with the parameter for each of the structures can be found in
Table 1. Table 1.
4. When a COSE object is carried as a CoAP payload, the CoAP content 4. When a COSE object is carried as a CoAP payload, the CoAP content
type parameter can be used to identify the message content. The type parameter can be used to identify the message content. The
CoAP content types can be found in Table 23. The CBOR Tag for CoAP content types can be found in Table 26. The CBOR tag for
the message structure is not required as each security message is the message structure is not required as each security message is
uniquely identified. uniquely identified.
+---------+----------------+-----------------+----------------------+ +-------+---------------+---------------+---------------------------+
| Tag | cose-type | Data Item | Semantics | | CBOR | cose-type | Data Item | Semantics |
| Value | | | | | Tag | | | |
+---------+----------------+-----------------+----------------------+ +-------+---------------+---------------+---------------------------+
| TBD1 | cose-sign | COSE_Sign | COSE Signed Data | | TBD1 | cose-sign | COSE_Sign | COSE Signed Data Object |
| | | | Object | | | | | |
| | | | | | TBD7 | cose-sign1 | COSE_Sign1 | COSE Single Signer Data |
| TBD7 | cose-sign1 | COSE_Sign1 | COSE Single Signer | | | | | Object |
| | | | Data Object | | | | | |
| | | | | | TBD2 | cose-encrypt | COSE_Encrypt | COSE Encrypted Data |
| TBD2 | cose-enveloped | COSE_Enveloped | COSE Enveloped Data | | | | | Object |
| | | | Object | | | | | |
| | | | | | TBD3 | cose-encrypt1 | COSE_Encrypt1 | COSE Single Recipient |
| TBD3 | cose-encrypted | COSE_Encrypted | COSE Encrypted Data | | | | | Encrypted Data Object |
| | | | Object | | | | | |
| | | | | | TBD4 | cose-mac | COSE_Mac | COSE Mac-ed Data Object |
| TBD4 | cose-mac | COSE_Mac | COSE Mac-ed Data | | | | | |
| | | | Object | | TBD6 | cose-mac0 | COSE_Mac0 | COSE Mac w/o Recipients |
| | | | | | | | | Object |
| TBD6 | cose-mac0 | COSE_Mac0 | COSE Mac w/o | | | | | |
| | | | Recipients Object | | TBD5 | N/A | COSE_Key, | COSE Key or COSE Key Set |
| | | | | | | | COSE_KeySet | Object |
| TBD5 | N/A | COSE_Key, | COSE Key or COSE Key | +-------+---------------+---------------+---------------------------+
| | | COSE_KeySet | Set Object |
+---------+----------------+-----------------+----------------------+
Table 1: COSE Object Identification Table 1: COSE Object Identification
The following CDDL fragment identifies all of the top level messages The following CDDL fragment identifies all of the top level messages
defined in this document. Separate non-terminals are defined for the defined in this document. Separate non-terminals are defined for the
tagged and the untagged versions of the messages for the convenience tagged and the untagged versions of the messages.
of applications.
COSE_Messages = COSE_Untagged_Message / COSE_Tagged_Message COSE_Messages = COSE_Untagged_Message / COSE_Tagged_Message
COSE_Untagged_Message = COSE_Sign / COSE_Sign1 / COSE_Untagged_Message = COSE_Sign / COSE_Sign1 /
COSE_Enveloped / COSE_Encrypted / COSE_Encrypt / COSE_Encrypt1 /
COSE_Mac / COSE_Mac0 COSE_Mac / COSE_Mac0
COSE_Tagged_Message = COSE_Sign_Tagged / COSE_Sign1_Tagged / COSE_Tagged_Message = COSE_Sign_Tagged / COSE_Sign1_Tagged /
COSE_Enveloped_Tagged / COSE_Encrypted_Tagged / COSE_Encrypt_Tagged / COSE_Encrypt1_Tagged /
COSE_Mac_Tagged / COSE_Mac0_Tagged COSE_Mac_Tagged / COSE_Mac0_Tagged
3. Header Parameters 3. Header Parameters
The structure of COSE has been designed to have two buckets of The structure of COSE has been designed to have two buckets of
information that are not considered to be part of the payload itself, information that are not considered to be part of the payload itself,
but are used for holding information about content, algorithms, keys, but are used for holding information about content, algorithms, keys,
or evaluation hints for the processing of the layer. These two or evaluation hints for the processing of the layer. These two
buckets are available for use in all of the structures except for buckets are available for use in all of the structures except for
keys. While these buckets can be present, they may not all be usable keys. While these buckets are present, they may not all be usable in
in all instances. For example, while the protected bucket is defined all instances. For example, while the protected bucket is defined as
as part of the recipient structure, some of the algorithms used for part of the recipient structure, some of the algorithms used for
recipient structures do not provide for authenticated data. If this recipient structures do not provide for authenticated data. If this
is the case, the protected bucket should be left empty. is the case, the protected bucket is left empty.
Both buckets are implemented as CBOR maps. The map key is a 'label' Both buckets are implemented as CBOR maps. The map key is a 'label'
(Section 1.4). The value portion is dependent on the definition for (Section 1.4). The value portion is dependent on the definition for
the label. Both maps use the same set of label/value pairs. The the label. Both maps use the same set of label/value pairs. The
integer and string values for labels has been divided into several integer and string values for labels has been divided into several
sections with a standard range, a private range, and a range that is sections with a standard range, a private range, and a range that is
dependent on the algorithm selected. The defined labels can be found dependent on the algorithm selected. The defined labels can be found
in the 'COSE Header Parameters' IANA registry (Section 16.2). in the 'COSE Header Parameters' IANA registry (Section 16.2).
Two buckets are provided for each layer: Two buckets are provided for each layer:
skipping to change at page 13, line 7 skipping to change at page 12, line 26
* Integer labels in the range -1 to -255 can be omitted as they * Integer labels in the range -1 to -255 can be omitted as they
are algorithm dependent. If an application can correctly are algorithm dependent. If an application can correctly
process an algorithm, it can be assumed that it will correctly process an algorithm, it can be assumed that it will correctly
process all of the common parameters associated with that process all of the common parameters associated with that
algorithm. (The algorithm range is -1 to -65536, the higher algorithm. (The algorithm range is -1 to -65536, the higher
end is for more optional algorithm specific items.) end is for more optional algorithm specific items.)
* Labels for parameters required for an application MAY be * Labels for parameters required for an application MAY be
omitted. Applications should have a statement if the label can omitted. Applications should have a statement if the label can
or cannot be omitted. be omitted.
The header parameter values indicated by 'crit' can be processed The header parameter values indicated by 'crit' can be processed
by either the security library code or by an application using a by either the security library code or by an application using a
security library, the only requirement is that the parameter is security library, the only requirement is that the parameter is
processed. If the 'crit' value list includes a value for which processed. If the 'crit' value list includes a value for which
the parameter is not in the protected bucket, this is a fatal the parameter is not in the protected bucket, this is a fatal
error in processing the message. error in processing the message.
content type This parameter is used to indicate the content type of content type This parameter is used to indicate the content type of
the data in the payload or ciphertext fields. Integers are from the data in the payload or ciphertext fields. Integers are from
skipping to change at page 13, line 41 skipping to change at page 13, line 11
applications. Key identifier values are hints about which key to applications. Key identifier values are hints about which key to
use. They are not directly a security critical field. For this use. They are not directly a security critical field. For this
reason, they can be placed in the unprotected headers bucket. reason, they can be placed in the unprotected headers bucket.
Initialization Vector This parameter holds the Initialization Vector Initialization Vector This parameter holds the Initialization Vector
(IV) value. For some symmetric encryption algorithms this may be (IV) value. For some symmetric encryption algorithms this may be
referred to as a nonce. As the IV is authenticated by encryption referred to as a nonce. As the IV is authenticated by encryption
process, it can be placed in the unprotected header bucket. process, it can be placed in the unprotected header bucket.
Partial Initialization Vector This parameter holds a part of the IV Partial Initialization Vector This parameter holds a part of the IV
value. When using the COSE_Encrypted structure, frequently a value. When using the COSE_Encrypt1 structure, a portion of the
portion of the IV is part of the context associated with the key IV can be part of the context associated with the key. This field
value. This field is used to carry a value that causes the IV to is used to carry a value that causes the IV to be changed for each
be changed for each message. As the IV is authenticated by the message. As the IV is authenticated by the encryption process,
encryption process, this value can be placed in the unprotected this value can be placed in the unprotected header bucket. The
header bucket. The 'Initialization Vector' and 'Partial 'Initialization Vector' and 'Partial Initialization Vector'
Initialization Vector' parameters MUST NOT be present in the same parameters MUST NOT be present in the same security layer.
security layer.
The message IV is generated by the following steps: The message IV is generated by the following steps:
1. Left pad the partial IV with zeros to the length of IV. 1. Left pad the partial IV with zeros to the length of IV.
2. XOR the padded partial IV with the context IV. 2. XOR the padded partial IV with the context IV.
counter signature This parameter holds a counter signature value. counter signature This parameter holds a counter signature value.
Counter signatures provide a method of having a second party sign Counter signatures provide a method of having a second party sign
some data. The counter signature can occur as an unprotected some data. The counter signature can occur as an unprotected
attribute in any of the following structures: COSE_Sign, attribute in any of the following structures: COSE_Sign,
COSE_Sign1, COSE_Signature, COSE_Enveloped, COSE_recipient, COSE_Sign1, COSE_Signature, COSE_Encrypt, COSE_recipient,
COSE_Encrypted, COSE_Mac and COSE_Mac0. These structures all have COSE_Encrypt1, COSE_Mac and COSE_Mac0. These structures all have
the same beginning elements so that a consistent calculation of the same beginning elements so that a consistent calculation of
the counter signature can be computed. Details on computing the counter signature can be computed. Details on computing
counter signatures are found in Section 4.5. counter signatures are found in Section 4.5.
operation time This parameter provides the time the content
cryptographic operation is performed. For signatures and
recipient structures, this would be the time that the signature or
recipient key object was created. For content structures, this
would be the time that the content structure was created. The
unsigned integer value is the number of seconds, excluding leap
seconds, after midnight UTC, January 1, 1970. The field is
primarily intended to be to be used for counter signatures,
however it can additionally be used for replay detection as well.
+-----------+-------+----------------+-------------+----------------+ +-----------+-------+----------------+-------------+----------------+
| name | label | value type | value | description | | name | label | value type | value | description |
| | | | registry | | | | | | registry | |
+-----------+-------+----------------+-------------+----------------+ +-----------+-------+----------------+-------------+----------------+
| alg | 1 | int / tstr | COSE | Cryptographic | | alg | 1 | int / tstr | COSE | Cryptographic |
| | | | Algorithm | algorithm to | | | | | Algorithm | algorithm to |
| | | | Registry | use | | | | | Registry | use |
| | | | | | | | | | | |
| crit | 2 | [+ label] | COSE Header | Critical | | crit | 2 | [+ label] | COSE Header | Critical |
| | | | Label | headers to be | | | | | Label | headers to be |
skipping to change at page 15, line 37 skipping to change at page 14, line 37
| | | | | Vector | | | | | | Vector |
| | | | | | | | | | | |
| Partial | 6 | bstr | | Partial | | Partial | 6 | bstr | | Partial |
| IV | | | | Initialization | | IV | | | | Initialization |
| | | | | Vector | | | | | | Vector |
| | | | | | | | | | | |
| counter | 7 | COSE_Signature | | CBOR encoded | | counter | 7 | COSE_Signature | | CBOR encoded |
| signature | | / [+ | | signature | | signature | | / [+ | | signature |
| | | COSE_Signature | | structure | | | | COSE_Signature | | structure |
| | | ] | | | | | | ] | | |
| | | | | |
| operation | 8 | uint | | Time the COSE |
| time | | | | structure was |
| | | | | created |
+-----------+-------+----------------+-------------+----------------+ +-----------+-------+----------------+-------------+----------------+
Table 2: Common Header Parameters Table 2: Common Header Parameters
The CDDL fragment that represents the set of headers defined in this The CDDL fragment that represents the set of headers defined in this
section is given below. Each of the headers is tagged as optional section is given below. Each of the headers is tagged as optional
because they do not need to be in every map, headers required in because they do not need to be in every map, headers required in
specific maps are discussed above. specific maps are discussed above.
Generic_Headers = ( Generic_Headers = (
? 1 => int / tstr, ; algorithm identifier ? 1 => int / tstr, ; algorithm identifier
? 2 => [+label], ; criticality ? 2 => [+label], ; criticality
? 3 => tstr / int, ; content type ? 3 => tstr / int, ; content type
? 4 => bstr, ; key identifier ? 4 => bstr, ; key identifier
? 5 => bstr, ; IV ? 5 => bstr, ; IV
? 6 => bstr, ; Partial IV ? 6 => bstr, ; Partial IV
? 7 => COSE_Signature / [+COSE_Signature], ; Counter signature ? 7 => COSE_Signature / [+COSE_Signature] ; Counter signature
? 8 => uint ; Operation time
) )
4. Signing Objects 4. Signing Objects
COSE supports two different signature structures. COSE_Sign allows COSE supports two different signature structures. COSE_Sign allows
for one or more signers to be applied to a single content. for one or more signers to be applied to a single content.
COSE_Sign1 is restricted to a single signer. The structures cannot COSE_Sign1 is restricted to a single signer. The structures cannot
be converted between each other, the signature computation includes a be converted between each other, the signature computation includes a
parameter identifying which structure is being used. parameter identifying which structure is being used.
4.1. Signing with One or More Signers 4.1. Signing with One or More Signers
The signature structure allows for one or more signatures to be The COSE_Sign structure allows for one or more signatures to be
applied to a message payload. There are provisions for parameters applied to a message payload. There are provisions for parameters
about the content and parameters about the signature to be carried about the content and parameters about the signature to be carried
along with the signature itself. These parameters may be along with the signature itself. These parameters may be
authenticated by the signature, or just present. An example of a authenticated by the signature, or just present. An example of a
parameter about the content is the content type. Examples of parameter about the content is the content type. Examples of
parameters about the signature would be the algorithm and key used to parameters about the signature would be the algorithm and key used to
create the signature, when the signature was created, and counter create the signature and counter signatures.
signatures.
When more than one signature is present, the successful validation of When more than one signature is present, the successful validation of
one signature associated with a given signer is usually treated as a one signature associated with a given signer is usually treated as a
successful signature by that signer. However, there are some successful signature by that signer. However, there are some
application environments where other rules are needed. An application environments where other rules are needed. An
application that employs a rule other than one valid signature for application that employs a rule other than one valid signature for
each signer must specify those rules. Also, where simple matching of each signer must specify those rules. Also, where simple matching of
the signer identifier is not sufficient to determine whether the the signer identifier is not sufficient to determine whether the
signatures were generated by the same signer, the application signatures were generated by the same signer, the application
specification must describe how to determine which signatures were specification must describe how to determine which signatures were
generated by the same signer. Support of different communities of generated by the same signer. Support of different communities of
recipients is the primary reason that signers choose to include more recipients is the primary reason that signers choose to include more
than one signature. For example, the COSE_Sign structure might than one signature. For example, the COSE_Sign structure might
include signatures generated with the RSA signature algorithm and include signatures generated with the Edwards Digital Signature
with the Elliptic Curve Digital Signature Algorithm (ECDSA) signature Algorithm (EdDSA) signature algorithm and with the Elliptic Curve
algorithm. This allows recipients to verify the signature associated Digital Signature Algorithm (ECDSA) signature algorithm. This allows
with one algorithm or the other. (The original source of this text recipients to verify the signature associated with one algorithm or
is [RFC5652].) More detailed information on multiple signature the other. (The original source of this text is [RFC5652].) More
evaluation can be found in [RFC5752]. detailed information on multiple signature evaluation can be found in
[RFC5752].
The signature structure can be encoded either with or without a tag The signature structure can be encoded either with or without a tag
depending on the context it will be used in. The signature structure depending on the context it will be used in. The signature structure
is identified by the CBOR tag TBD1. The CDDL fragment that is identified by the CBOR tag TBD1. The CDDL fragment that
represents this is. represents this is.
COSE_Sign_Tagged = #6.991(COSE_Sign) ; Replace 991 with TBD1 COSE_Sign_Tagged = #6.991(COSE_Sign) ; Replace 991 with TBD1
A COSE Signed Message is divided into two parts. The CBOR object A COSE Signed Message is divided into two parts. The CBOR object
that carries the body and information about the body is called the that carries the body and information about the body is called the
skipping to change at page 18, line 31 skipping to change at page 17, line 24
The CDDL fragment which represents the above text for COSE_Signature The CDDL fragment which represents the above text for COSE_Signature
follows. follows.
COSE_Signature = [ COSE_Signature = [
Headers, Headers,
signature : bstr signature : bstr
] ]
4.2. Signing with One Signer 4.2. Signing with One Signer
The signature structure can be encoded either with or without a tag The COSE_Sign1 signature structure is used when only one signer is
depending on the context it will be used in. The signature structure going to be placed on a message. The parameters dealing with the
is identified by the CBOR tag TBD7. The CDDL fragment that content and the signature are placed in the same pair of buckets
represents this is: rather than having the separation of COSE_Sign.
The structure can be encoded either with or without a tag depending
on the context it will be used in. The structure is identified by
the CBOR tag TBD7. The CDDL fragment that represents this is:
COSE_Sign1_Tagged = #6.997(COSE_Sign1) ; Replace 997 with TBD7 COSE_Sign1_Tagged = #6.997(COSE_Sign1) ; Replace 997 with TBD7
The CBOR object that carries the body, the signature and the The CBOR object that carries the body, the signature and the
information about the body and signature is called the COSE_Sign1 information about the body and signature is called the COSE_Sign1
structure. Examples of COSE Single signature messages can be found structure. Examples of COSE Single signature messages can be found
in Appendix C.2. in Appendix C.2.
The COSE_Sign1 structure is a CBOR array. The fields of the array in The COSE_Sign1 structure is a CBOR array. The fields of the array in
order are: order are:
skipping to change at page 19, line 30 skipping to change at page 18, line 27
ability for applications to provide additional data to be ability for applications to provide additional data to be
authenticated as part of the security, but that is not carried as authenticated as part of the security, but that is not carried as
part of the COSE object. The primary reason for supporting this can part of the COSE object. The primary reason for supporting this can
be seen by looking at the CoAP message structure [RFC7252] where the be seen by looking at the CoAP message structure [RFC7252] where the
facility exists for options to be carried before the payload. An facility exists for options to be carried before the payload. An
example of data that can be placed in this location would be CoAP example of data that can be placed in this location would be CoAP
options for transaction ids and nonces to check for replay options for transaction ids and nonces to check for replay
protection. If the data is in the options section, then it is protection. If the data is in the options section, then it is
available for routers to help in performing the replay detection and available for routers to help in performing the replay detection and
prevention. However, it may also be desired to protect these values prevention. However, it may also be desired to protect these values
so that if they are be modified in transit it can be detected. This so that if they are be modified in transit it can be detected.
is the purpose of the externally supplied data field.
This document describes the process for using a byte array of This document describes the process for using a byte array of
externally supplied authenticated data, however the method of externally supplied authenticated data, however the method of
constructing the byte array is a function of the application. constructing the byte array is a function of the application.
Applications that use this feature need to define how the externally Applications that use this feature need to define how the externally
supplied authenticated data is to be constructed. Such a supplied authenticated data is to be constructed. Such a
construction needs to take into account the following issues: construction needs to take into account the following issues:
o If multiple items are included, care needs to be taken that data o If multiple items are included, care needs to be taken that data
cannot bleed between the items. This is usually addressed by cannot bleed between the items. This is usually addressed by
making fields fixed width and/or encoding the length of the field. making fields fixed width and/or encoding the length of the field.
Using options from CoAP [RFC7252] as an example, these fields use Using options from CoAP [RFC7252] as an example, these fields use
a TLV structure so they can be concatenated without any problems. a TLV structure so they can be concatenated without any problems.
o If multiple items are included, a defined order for the items o If multiple items are included, a defined order for the items
needs to be defined. Using options from CoAP as an example, an needs to be defined. Using options from CoAP as an example, an
application could state that the fields are to be ordered by the application could state that the fields are to be ordered by the
option number. option number.
o Applications need to ensure that the byte stream is going to be
the same on both sides. Using options from CoAP might give a
problem if the same relative numbering is kept. An intermediate
node could insert or remove an option changing how the relative
number is done. An application would need to specify that the
relative number must be re-encoded to be relative only to the
options that are in the external data.
4.4. Signing and Verification Process 4.4. Signing and Verification Process
In order to create a signature, a consistent byte stream is needed. In order to create a signature, a consistent byte stream is needed.
This algorithm takes in the body information (COSE_Sign), the signer This algorithm takes in the body information (COSE_Sign or
information (COSE_Signature), and the application data (External). A COSE_Sign1), the signer information (COSE_Signature), and the
CBOR array is used to construct the byte stream. The fields of the application data (External). A CBOR array is used to construct the
array in order are: byte stream. The fields of the array in order are:
1. A text string identifying the context of the signature. The 1. A text string identifying the context of the signature. The
context string is: context string is:
"Signature" for signatures using the COSE_Signature structure. "Signature" for signatures using the COSE_Signature structure.
"Signature1" for signatures using the COSE_Sign1 structure. "Signature1" for signatures using the COSE_Sign1 structure.
"CounterSignature" for signatures used as counter signature "CounterSignature" for signatures used as counter signature
attributes. attributes.
skipping to change at page 21, line 24 skipping to change at page 20, line 25
4. Place the resulting signature value in the 'signature' field of 4. Place the resulting signature value in the 'signature' field of
the array. the array.
How to verify a signature: How to verify a signature:
1. Create a Sig_structure object and populate it with the 1. Create a Sig_structure object and populate it with the
appropriate fields. appropriate fields.
2. Create the value ToBeSigned by encoding the Sig_structure to a 2. Create the value ToBeSigned by encoding the Sig_structure to a
byte string using the encoding described in Section 14.. byte string using the encoding described in Section 14.
3. Call the signature verification algorithm passing in K (the key 3. Call the signature verification algorithm passing in K (the key
to verify with), alg (the algorithm used sign with), ToBeSigned to verify with), alg (the algorithm used sign with), ToBeSigned
(the value to sign), and sig (the signature to be verified). (the value to sign), and sig (the signature to be verified).
In addition to performing the signature verification, one must also In addition to performing the signature verification, one must also
perform the appropriate checks to ensure that the key is correctly perform the appropriate checks to ensure that the key is correctly
paired with the signing identity and that the appropriate paired with the signing identity and that the appropriate
authorization is done. authorization is done.
4.5. Computing Counter Signatures 4.5. Computing Counter Signatures
Counter signatures provide a method of having a different signature Counter signatures provide a method of having a different signature
occur on some piece of content. This is normally used to provide a occur on some piece of content. This is normally used to provide a
signature on a signature allowing for a proof that a signature signature on a signature allowing for a proof that a signature
existed at a given time (i.e. a Timestamp). In this document we existed at a given time (i.e. a Timestamp). In this document we
allow for counter signatures to exist in a greater number of allow for counter signatures to exist in a greater number of
environments. As an example, it is possible to place a counter environments. As an example, it is possible to place a counter
signature in the unprotected attributes of a COSE_Enveloped object. signature in the unprotected attributes of a COSE_Encrypt object.
This would allow for an intermediary to either verify that the This would allow for an intermediary to either verify that the
encrypted byte stream has not been modified, without being able to encrypted byte stream has not been modified, without being able to
decrypt it. Or for the intermediary to assert that an encrypted byte decrypt it. Or for the intermediary to assert that an encrypted byte
stream either existed at a given time or passed through it in terms stream either existed at a given time or passed through it in terms
of routing (i.e. a proxy signature). of routing (i.e. a proxy signature).
An example of a counter signature on a signature can be found in An example of a counter signature on a signature can be found in
Appendix C.1.3. An example of a counter signature in an encryption Appendix C.1.3. An example of a counter signature in an encryption
object can be found in Appendix C.3.3. object can be found in Appendix C.3.3.
The creation and validation of counter signatures over the different The creation and validation of counter signatures over the different
items relies on the fact that the structure of the objects have the items relies on the fact that the structure of the objects have the
same structure. The elements are a set of protected attributes, a same structure. The elements are a set of protected attributes, a
set of unprotected attributes and a body in that order. This means set of unprotected attributes and a body in that order. This means
that the Sig_structure can be used in a uniform manner to get the that the Sig_structure can be used in a uniform manner to get the
byte stream for processing a signature. If the counter signature is byte stream for processing a signature. If the counter signature is
going to be computed over a COSE_Enveloped structure, the going to be computed over a COSE_Encrypt structure, the
body_protected and payload items can be mapped into the Sig_structure body_protected and payload items can be mapped into the Sig_structure
in the same manner as from the COSE_Sign structure. in the same manner as from the COSE_Sign structure.
It should be noted that only a signature algorithm with appendix (see It should be noted that only a signature algorithm with appendix (see
Section 8) can be used for counter signatures. This is because the Section 8) can be used for counter signatures. This is because the
body should be able to be processed without having to evaluate the body should be able to be processed without having to evaluate the
counter signature, and this is not possible for signature schemes counter signature, and this is not possible for signature schemes
with message recovery. with message recovery.
5. Encryption Objects 5. Encryption Objects
COSE supports two different encryption structures. COSE_Encrypted is COSE supports two different encryption structures. COSE_Encrypt1 is
used when a recipient structure is not needed because the key to be used when a recipient structure is not needed because the key to be
used is known implicitly. COSE_Enveloped is used the rest of time used is known implicitly. COSE_Encrypt is used the rest of time
time. This includes cases where there are multiple recipients, a time. This includes cases where there are multiple recipients or a
recipient algorithm other than direct is to be used, or the key to be recipient algorithm other than direct is used.
used is not known.
5.1. Enveloped COSE Structure 5.1. Enveloped COSE Structure
The enveloped structure allows for one or more recipients of a The enveloped structure allows for one or more recipients of a
message. There are provisions for parameters about the content and message. There are provisions for parameters about the content and
parameters about the recipient information to be carried in the parameters about the recipient information to be carried in the
message. The protected parameters associated with the content are message. The protected parameters associated with the content are
authenticated by the content encryption algorithm. The protected authenticated by the content encryption algorithm. The protected
parameters associated with the recipient are authenticated by the parameters associated with the recipient are authenticated by the
recipient algorithm (when the algorithm supports it). Examples of recipient algorithm (when the algorithm supports it). Examples of
parameters about the content are the type of the content, and the parameters about the content are the type of the content, and the
content encryption algorithm. Examples of parameters about the content encryption algorithm. Examples of parameters about the
recipient are the recipient's key identifier, the recipient recipient are the recipient's key identifier, the recipient
encryption algorithm. encryption algorithm.
The same techniques and structures are used for encrypting both the The same techniques and structures are used for encrypting both the
plain text and the keys used to protect the text. This is different plain text and the keys used to protect the text. This is different
from the approach used by both [RFC5652] and [RFC7516] where from the approach used by both CMS [RFC5652] and JSON Web Encryption
different structures are used for the content layer and for the (JWE) [RFC7516] where different structures are used for the content
recipient layer. Two structures are defined: COSE_Enveloped to hold layer and for the recipient layer. Two structures are defined:
the encrypted content, and COSE_recipient to hold the encrypted keys COSE_Encrypt to hold the encrypted content, and COSE_recipient to
for recipients. Examples of encrypted messages can be found in hold the encrypted keys for recipients. Examples of encrypted
Appendix C.3. messages can be found in Appendix C.3.
The COSE Enveloped structure can be encoded either with or without a The COSE_Encrypt structure can be encoded either with or without a
tag depending on the context it will be used in. The COSE Enveloped tag depending on the context it will be used in. The structure is
structure is identified by the CBOR tag TBD2. The CDDL fragment that identified by the CBOR tag TBD2. The CDDL fragment that represents
represents this is. this is.
COSE_Enveloped_Tagged = #6.992(COSE_Enveloped) ; Replace 992 with TBD2 COSE_Encrypt_Tagged = #6.992(COSE_Encrypt) ; Replace 992 with TBD2
The COSE_Enveloped structure is a CBOR array. The fields of the The COSE_Encrypt structure is a CBOR array. The fields of the array
array in order are: in order are:
protected as described in Section 3. protected as described in Section 3.
unprotected as described in Section 3. unprotected as described in Section 3.
ciphertext contains the cipher text encoded as a bstr. If the ciphertext contains the cipher text encoded as a bstr. If the
ciphertext is to be transported independently of the control ciphertext is to be transported independently of the control
information about the encryption process (i.e. detached content) information about the encryption process (i.e. detached content)
then the field is encoded as a null object. then the field is encoded as a nil value.
recipients contains an array of recipient information structures. recipients contains an array of recipient information structures.
The type for the recipient information structure is a The type for the recipient information structure is a
COSE_recipient. COSE_recipient.
The CDDL fragment that corresponds to the above text is: The CDDL fragment that corresponds to the above text is:
COSE_Enveloped = [ COSE_Encrypt = [
Headers, Headers,
ciphertext: bstr / nil, ciphertext: bstr / nil,
recipients: [+COSE_recipient] recipients: [+COSE_recipient]
] ]
The COSE_recipient structure is a CBOR array. The fields of the The COSE_recipient structure is a CBOR array. The fields of the
array in order are: array in order are:
protected as described in Section 3. protected as described in Section 3.
skipping to change at page 24, line 16 skipping to change at page 23, line 18
COSE_recipient is: COSE_recipient is:
COSE_recipient = [ COSE_recipient = [
Headers, Headers,
ciphertext: bstr / nil, ciphertext: bstr / nil,
? recipients: [+COSE_recipient] ? recipients: [+COSE_recipient]
] ]
5.1.1. Recipient Algorithm Classes 5.1.1. Recipient Algorithm Classes
A typical encrypted message consists of an encrypted content and an An encrypted message consists of an encrypted content and an
encrypted CEK for one or more recipients. The CEK is encrypted for encrypted CEK for one or more recipients. The CEK is encrypted for
each recipient, using a key specific to that recipient. The details each recipient, using a key specific to that recipient. The details
of this encryption depends on which class the recipient algorithm of this encryption depends on which class the recipient algorithm
falls into. Specific details on each of the classes can be found in falls into. Specific details on each of the classes can be found in
Section 12. A short summary of the five recipient algorithm classes Section 12. A short summary of the five recipient algorithm classes
is: is:
direct: The CEK is the same as the identified previously distributed direct: The CEK is the same as the identified previously distributed
symmetric key or derived from a previously distributed secret. No symmetric key or derived from a previously distributed secret. No
CEK is transported in the message. CEK is transported in the message.
skipping to change at page 24, line 42 skipping to change at page 23, line 44
are used to generate a pairwise secret, a KDF is applied to derive are used to generate a pairwise secret, a KDF is applied to derive
a key, and then the CEK is either the derived key or encrypted by a key, and then the CEK is either the derived key or encrypted by
the derived key. the derived key.
key transport: The CEK is encrypted with the recipient's public key. key transport: The CEK is encrypted with the recipient's public key.
No key transport algorithms are defined in this document. No key transport algorithms are defined in this document.
passwords: The CEK is encrypted in a KEK that is derived from a passwords: The CEK is encrypted in a KEK that is derived from a
password. No password algorithms are defined in this document. password. No password algorithms are defined in this document.
5.2. Encrypted COSE structure 5.2. Single Recipient Encrypted
The encrypted structure does not have the ability to specify The COSE_Encrypt1 encrypted structure does not have the ability to
recipients of the message. The structure assumes that the recipient specify recipients of the message. The structure assumes that the
of the object will already know the identity of the key to be used in recipient of the object will already know the identity of the key to
order to decrypt the message. If a key needs to be identified to the be used in order to decrypt the message. If a key needs to be
recipient, the enveloped structure ought to be used. identified to the recipient, the enveloped structure ought to be
used.
The structure defined to hold an encrypted message is COSE_Encrypted.
Examples of encrypted messages can be found in Appendix C.3. Examples of encrypted messages can be found in Appendix C.3.
The COSE_Encrypted structure can be encoded either with or without a The COSE_Encrypt1 structure can be encoded either with or without a
tag depending on the context it will be used in. The COSE_Encrypted tag depending on the context it will be used in. The COSE_Encrypt1
structure is identified by the CBOR tag TBD3. The CDDL fragment that structure is identified by the CBOR tag TBD3. The CDDL fragment that
represents this is. represents this is.
COSE_Encrypted_Tagged = #6.993(COSE_Encrypted) ; Replace 993 with TBD3 COSE_Encrypt1_Tagged = #6.993(COSE_Encrypt1) ; Replace 993 with TBD3
The COSE_Enveloped structure is a CBOR array. The fields of the The COSE_Encrypt structure is a CBOR array. The fields of the array
array in order are: in order are:
protected as described in Section 3. protected as described in Section 3.
unprotected as described in Section 3. unprotected as described in Section 3.
ciphertext as described in Section 5.1. ciphertext as described in Section 5.1.
The CDDL fragment for COSE_Encrypted that corresponds to the above The CDDL fragment for COSE_Encrypt1 that corresponds to the above
text is: text is:
COSE_Encrypted = [ COSE_Encrypt1 = [
Headers, Headers,
ciphertext: bstr / nil, ciphertext: bstr / nil,
] ]
5.3. Encryption Algorithm for AEAD algorithms 5.3. Encryption Algorithm for AEAD algorithms
The encryption algorithm for AEAD algorithms is fairly simple. The The encryption algorithm for AEAD algorithms is fairly simple. The
first step is to create a consistent byte stream for the first step is to create a consistent byte stream for the
authenticated data structure. For this purpose we use a CBOR array, authenticated data structure. For this purpose we use a CBOR array,
the fields of the array in order are: the fields of the array in order are:
1. A text string identifying the context of the authenticated data 1. A text string identifying the context of the authenticated data
structure. The context string is: structure. The context string is:
"Encrypted" for the content encryption of an encrypted data "Encrypt1" for the content encryption of an COSE_Encrypt1 data
structure. structure.
"Enveloped" for the first level of an enveloped data structure "Encrypt" for the first level of an COSE_Encrypt data structure
(i.e. for content encryption). (i.e. for content encryption).
"Env_Recipient" for a recipient encoding to be placed in an "Enc_Recipient" for a recipient encoding to be placed in an
enveloped data structure. COSE_Encrypt data structure.
"Mac_Recipient" for a recipient encoding to be placed in a MAC "Mac_Recipient" for a recipient encoding to be placed in a MAC
message structure. message structure.
"Rec_Recipient" for a recipient encoding to be placed in a "Rec_Recipient" for a recipient encoding to be placed in a
recipient structure. recipient structure.
2. The protected attributes from the body structure encoded in a 2. The protected attributes from the body structure encoded in a
bstr type. If there are no protected attributes, a bstr of bstr type. If there are no protected attributes, a bstr of
length zero is used. length zero is used.
3. The protected attributes from the application encoded in a bstr 3. The protected attributes from the application encoded in a bstr
type. If this field is not supplied, it defaults to a zero type. If this field is not supplied, it defaults to a zero
length bstr. (See Section 4.3 for application guidance on length bstr. (See Section 4.3 for application guidance on
constructing this field.) constructing this field.)
The CDDL fragment which describes the above text is: The CDDL fragment which describes the above text is:
Enc_structure = [ Enc_structure = [
context : "Enveloped" / "Encrypted" / "Env_Recipient" / context : "Encrypt" / "Encrypt1" / "Enc_Recipient" /
"Mac_Recipient" / "Rec_Recipient", "Mac_Recipient" / "Rec_Recipient",
protected: bstr, protected: bstr,
external_aad: bstr external_aad: bstr
] ]
How to encrypt a message: How to encrypt a message:
1. Create a Enc_structure and populate it with the appropriate 1. Create a Enc_structure and populate it with the appropriate
fields. fields.
skipping to change at page 27, line 25 skipping to change at page 26, line 29
No Recipients: The key to be used is determined by the algorithm No Recipients: The key to be used is determined by the algorithm
and key at the current level. and key at the current level.
Direct and Direct Key Agreement: The key is determined by the Direct and Direct Key Agreement: The key is determined by the
key and algorithm in the recipient structure. The encryption key and algorithm in the recipient structure. The encryption
algorithm and size of the key to be used are inputs into the algorithm and size of the key to be used are inputs into the
KDF used for the recipient. (For direct, the KDF can be KDF used for the recipient. (For direct, the KDF can be
thought of as the identity operation.) thought of as the identity operation.)
Other: The key is determined by decoding and decrypting the Other: The key is determined by decoding and decrypting one of
recipient structure. the recipient structures.
4. Call the decryption algorithm with K (the decryption key to use), 4. Call the decryption algorithm with K (the decryption key to use),
C (the cipher text) and AAD. C (the cipher text) and AAD.
5.4. Encryption algorithm for AE algorithms 5.4. Encryption algorithm for AE algorithms
How to encrypt a message: How to encrypt a message:
1. Verify that the 'protected' field is absent. 1. Verify that the 'protected' field is absent.
skipping to change at page 28, line 32 skipping to change at page 27, line 36
No Recipients: The key to be used is determined by the algorithm No Recipients: The key to be used is determined by the algorithm
and key at the current level. and key at the current level.
Direct and Direct Key Agreement: The key is determined by the Direct and Direct Key Agreement: The key is determined by the
key and algorithm in the recipient structure. The encryption key and algorithm in the recipient structure. The encryption
algorithm and size of the key to be used are inputs into the algorithm and size of the key to be used are inputs into the
KDF used for the recipient. (For direct, the KDF can be KDF used for the recipient. (For direct, the KDF can be
thought of as the identity operation.) thought of as the identity operation.)
Other: The key is determined by decoding and decrypting the Other: The key is determined by decoding and decrypting one of
recipient structure. the recipient structures.
4. Call the decryption algorithm with K (the decryption key to use), 4. Call the decryption algorithm with K (the decryption key to use),
C (the cipher text) and AAD. and C (the cipher text).
6. MAC Objects 6. MAC Objects
COSE supports two different MAC structures. COSE_MAC0 is used when a COSE supports two different MAC structures. COSE_MAC0 is used when a
recipient structure is not needed because the key to be used is recipient structure is not needed because the key to be used is
implicitly known. COSE_MAC is used for all other cases. These implicitly known. COSE_MAC is used for all other cases. These
include a requirement for multiple recipients, the key being unknown, include a requirement for multiple recipients, the key being unknown,
a recipient algorithm of other than direct. a recipient algorithm of other than direct.
6.1. MAC Message with Recipients
In this section we describe the structure and methods to be used when In this section we describe the structure and methods to be used when
doing MAC authentication in COSE. This document allows for the use doing MAC authentication in COSE. This document allows for the use
of all of the same classes of recipient algorithms as are allowed for of all of the same classes of recipient algorithms as are allowed for
encryption. encryption.
When using MAC operations, there are two modes in which it can be When using MAC operations, there are two modes in which it can be
used. The first is just a check that the content has not been used. The first is just a check that the content has not been
changed since the MAC was computed. Any class of recipient algorithm changed since the MAC was computed. Any class of recipient algorithm
can be used for this purpose. The second mode is to both check that can be used for this purpose. The second mode is to both check that
the content has not been changed since the MAC was computed, and to the content has not been changed since the MAC was computed, and to
use the recipient algorithm to verify who sent it. The classes of use the recipient algorithm to verify who sent it. The classes of
recipient algorithms that support this are those that use a pre- recipient algorithms that support this are those that use a pre-
shared secret or do static-static key agreement (without the key wrap shared secret or do static-static key agreement (without the key wrap
step). In both of these cases, the entity that created and sent the step). In both of these cases, the entity that created and sent the
message MAC can be validated. (This knowledge of sender assumes that message MAC can be validated. (This knowledge of sender assumes that
there are only two parties involved and you did not send the message there are only two parties involved and you did not send the message
yourself.) yourself.)
The MAC message uses two structures, the COSE_Mac structure defined 6.1. MAC Message with Recipients
in this section for carrying the body and the COSE_recipient
structure (Section 5.1) to hold the key used for the MAC computation. The multiple recipient MAC message uses two structures, the COSE_Mac
Examples of MAC messages can be found in Appendix C.5. structure defined in this section for carrying the body and the
COSE_recipient structure (Section 5.1) to hold the key used for the
MAC computation. Examples of MAC messages can be found in
Appendix C.5.
The MAC structure can be encoded either with or without a tag The MAC structure can be encoded either with or without a tag
depending on the context it will be used in. The MAC structure is depending on the context it will be used in. The MAC structure is
identified by the CBOR tag TBD4. The CDDL fragment that represents identified by the CBOR tag TBD4. The CDDL fragment that represents
this is: this is:
COSE_Mac_Tagged = #6.994(COSE_Mac) ; Replace 994 with TBD4 COSE_Mac_Tagged = #6.994(COSE_Mac) ; Replace 994 with TBD4
The COSE_Mac structure is a CBOR array. The fields of the array in The COSE_Mac structure is a CBOR array. The fields of the array in
order are: order are:
protected as described in Section 3. protected as described in Section 3.
unprotected as described in Section 3. unprotected as described in Section 3.
payload contains the serialized content to be MACed. If the payload payload contains the serialized content to be MACed. If the payload
is not present in the message, the application is required to is not present in the message, the application is required to
supply the payload separately. The payload is wrapped in a bstr supply the payload separately. The payload is wrapped in a bstr
to ensure that it is transported without changes. If the payload to ensure that it is transported without changes. If the payload
is transported separately (i.e. detached content), then a null is transported separately (i.e. detached content), then a nil CBOR
CBOR object is placed in this location and it is the value is placed in this location and it is the responsibility of
responsibility of the application to ensure that it will be the application to ensure that it will be transported without
transported without changes. changes.
tag contains the MAC value. tag contains the MAC value.
recipients as described in Section 5.1. recipients as described in Section 5.1.
The CDDL fragment which represents the above text for COSE_Mac The CDDL fragment which represents the above text for COSE_Mac
follows. follows.
COSE_Mac = [ COSE_Mac = [
Headers, Headers,
skipping to change at page 32, line 33 skipping to change at page 31, line 35
A COSE Key structure is built on a CBOR map object. The set of A COSE Key structure is built on a CBOR map object. The set of
common parameters that can appear in a COSE Key can be found in the common parameters that can appear in a COSE Key can be found in the
IANA registry 'COSE Key Common Parameter Registry' (Section 16.5). IANA registry 'COSE Key Common Parameter Registry' (Section 16.5).
Additional parameters defined for specific key types can be found in Additional parameters defined for specific key types can be found in
the IANA registry 'COSE Key Type Parameters' (Section 16.6). the IANA registry 'COSE Key Type Parameters' (Section 16.6).
A COSE Key Set uses a CBOR array object as its underlying type. The A COSE Key Set uses a CBOR array object as its underlying type. The
values of the array elements are COSE Keys. A Key Set MUST have at values of the array elements are COSE Keys. A Key Set MUST have at
least one element in the array. least one element in the array.
Each element in a key set MUST be processed independently. If one
element in a key set is either malformed or uses a key which is not
understood by an application, that key is ignored and the other keys
are processed normally.
The element "kty" is a required element in a COSE_Key map. The element "kty" is a required element in a COSE_Key map.
The CDDL grammar describing COSE_Key and COSE_KeySet is: The CDDL grammar describing COSE_Key and COSE_KeySet is:
COSE_Key = { COSE_Key = {
key_kty => tstr / int, key_kty => tstr / int,
? key_ops => [+ (tstr / int) ], ? key_ops => [+ (tstr / int) ],
? key_alg => tstr / int, ? key_alg => tstr / int,
? key_kid => bstr, ? key_kid => bstr,
* label => values * label => values
skipping to change at page 33, line 34 skipping to change at page 32, line 41
| Base IV | 5 | bstr | | Base IV to be xor- | | Base IV | 5 | bstr | | Base IV to be xor- |
| | | | | ed with Partial | | | | | | ed with Partial |
| | | | | IVs | | | | | | IVs |
+---------+-------+----------------+-----------+--------------------+ +---------+-------+----------------+-----------+--------------------+
Table 3: Key Map Labels Table 3: Key Map Labels
kty: This parameter is used to identify the family of keys for this kty: This parameter is used to identify the family of keys for this
structure, and thus the set of key type specific parameters to be structure, and thus the set of key type specific parameters to be
found. The set of values defined in this document can be found in found. The set of values defined in this document can be found in
Table 19. This parameter MUST be present in a key object. Table 21. This parameter MUST be present in a key object.
Implementations MUST verify that the key type is appropriate for Implementations MUST verify that the key type is appropriate for
the algorithm being processed. The key type MUST be included as the algorithm being processed. The key type MUST be included as
part of the trust decision process. part of the trust decision process.
alg: This parameter is used to restrict the algorithms that are to alg: This parameter is used to restrict the algorithm that is used
be used with this key. If this parameter is present in the key with the key. If this parameter is present in the key structure,
structure, the application MUST verify that this algorithm matches the application MUST verify that this algorithm matches the
the algorithm for which the key is being used. If the algorithms algorithm for which the key is being used. If the algorithms do
do not match, then this key object MUST NOT be used to perform the not match, then this key object MUST NOT be used to perform the
cryptographic operation. Note that the same key can be in a cryptographic operation. Note that the same key can be in a
different key structure with a different or no algorithm different key structure with a different or no algorithm
specified, however this is considered to be a poor security specified, however this is considered to be a poor security
practice. practice.
kid: This parameter is used to give an identifier for a key. The kid: This parameter is used to give an identifier for a key. The
identifier is not structured and can be anything from a user identifier is not structured and can be anything from a user
provided string to a value computed on the public portion of the provided string to a value computed on the public portion of the
key. This field is intended for matching against a 'kid' key. This field is intended for matching against a 'kid'
parameter in a message in order to filter down the set of keys parameter in a message in order to filter down the set of keys
that need to be checked. that need to be checked.
key_ops: This parameter is defined to restrict the set of operations key_ops: This parameter is defined to restrict the set of operations
that a key is to be used for. The value of the field is an array that a key is to be used for. The value of the field is an array
of values from Table 4. of values from Table 4. Algorithms define the values of key ops
that are permitted to appear and are required for specific
operations.
Base IV: This parameter is defined to carry the base portion of an Base IV: This parameter is defined to carry the base portion of an
IV. It is designed to be used with the partial IV header IV. It is designed to be used with the partial IV header
parameter defined in Section 3.1. This field provides the ability parameter defined in Section 3.1. This field provides the ability
to associate a partial IV with a key that is then modified on a to associate a partial IV with a key that is then modified on a
per message basis with the parital IV. per message basis with the parital IV.
Care needs to be taken that this is only used as part of a key Extreme care needs to be taken when using a Base IV in an
distribution algorithm that will ensure that it will be given only application. Many encryption algorithms loose security if the
to parties that will use it correctly. This is due to the fact same IV is used twice.
that many of the content encryption algorithms defined for COSE
require that IVs be unique for every message. Use of this field If different keys are derived for each sender, starting at the
will easily allow for this rule to be broken if not used same base IV is likely to satisfy this condition. If the same key
carefully. This field MUST be ignored unless an application is used for multiple senders, then the application needs to
specifically calls for its use. provide for a method of dividing the IV space up between the
senders. This could be done by providing a different base point
to start from or a different partial IV to start with and
restricting the number of messages to be sent before re-keying.
+---------+-------+-------------------------------------------------+ +---------+-------+-------------------------------------------------+
| name | value | description | | name | value | description |
+---------+-------+-------------------------------------------------+ +---------+-------+-------------------------------------------------+
| sign | 1 | The key is used to create signatures. Requires | | sign | 1 | The key is used to create signatures. Requires |
| | | private key fields. | | | | private key fields. |
| | | | | | | |
| verify | 2 | The key is used for verification of signatures. | | verify | 2 | The key is used for verification of signatures. |
| | | | | | | |
| encrypt | 3 | The key is used for key transport encryption. | | encrypt | 3 | The key is used for key transport encryption. |
skipping to change at page 36, line 37 skipping to change at page 35, line 37
different schemes in a single message is not supported, and if a different schemes in a single message is not supported, and if a
recovery signature scheme is used then the same amount of content recovery signature scheme is used then the same amount of content
needs to be consumed by all of the signatures. needs to be consumed by all of the signatures.
The signature functions for this scheme are: The signature functions for this scheme are:
signature, message sent = Sign(message content, key) signature, message sent = Sign(message content, key)
valid, message content = Verification(message sent, key, signature) valid, message content = Verification(message sent, key, signature)
At this time, only signatures with appendixes are defined for use Signature algorithms are used with the COSE_Signature and COSE_Sign1
with COSE, however considerable interest has been expressed in using structures. At this time, only signatures with appendixes are
a signature with message recovery algorithm due to the effective size defined for use with COSE, however considerable interest has been
reduction that is possible. Implementations will need to keep this expressed in using a signature with message recovery algorithm due to
in mind for later possible integration. the effective size reduction that is possible. Implementations will
need to keep this in mind for later possible integration.
8.1. ECDSA 8.1. ECDSA
ECDSA [DSS] defines a signature algorithm using ECC. ECDSA [DSS] defines a signature algorithm using ECC.
The ECDSA signature algorithm is parameterized with a hash function The ECDSA signature algorithm is parameterized with a hash function
(h). In the event that the length of the hash function output is (h). In the event that the length of the hash function output is
greater than the group of the key, the left-most bytes of the hash greater than the group of the key, the left-most bytes of the hash
output are used. output are used.
skipping to change at page 38, line 20 skipping to change at page 37, line 23
The security strength of the signature is no greater than the minimum The security strength of the signature is no greater than the minimum
of the security strength associated with the bit length of the key of the security strength associated with the bit length of the key
and the security strength of the hash function. and the security strength of the hash function.
System which have poor random number generation can leak their keys System which have poor random number generation can leak their keys
by signing two different messages with the same value 'k' (the per- by signing two different messages with the same value 'k' (the per-
message random value). [RFC6979] provides a method to deal with this message random value). [RFC6979] provides a method to deal with this
problem by making 'k' be deterministic based on the message content problem by making 'k' be deterministic based on the message content
rather than randomly generated. Applications that specify ECDSA rather than randomly generated. Applications that specify ECDSA
should evaluate the ability to get good random number generation and should evaluate the ability to get good random number generation and
require this when it is not possible. require deterministic signatures where poor random number generation
exists.
Note: Use of this technique a good idea even when good random number Note: Use of this technique a good idea even when good random number
generation exists. Doing so both reduces the possibility of having generation exists. Doing so both reduces the possibility of having
the same value of 'k' in two signature operations and allows for the same value of 'k' in two signature operations and allows for
reproducible signature values which helps testing. reproducible signature values which helps testing.
There are two substitution attacks that can theoretically be mounted There are two substitution attacks that can theoretically be mounted
against the ECDSA signature algorithm. against the ECDSA signature algorithm.
o Changing the curve used to validate the signature: If one changes o Changing the curve used to validate the signature: If one changes
skipping to change at page 39, line 5 skipping to change at page 38, line 5
o Change the hash function used to validate the signature: If one o Change the hash function used to validate the signature: If one
has either two different hash functions of the same length, or one has either two different hash functions of the same length, or one
can truncate a hash function down, then one could potentially find can truncate a hash function down, then one could potentially find
collisions between the hash functions rather than within a single collisions between the hash functions rather than within a single
hash function. (For example, truncating SHA-512 to 256 bits might hash function. (For example, truncating SHA-512 to 256 bits might
collide with a SHA-256 bit hash value.) This attack can be collide with a SHA-256 bit hash value.) This attack can be
mitigated by including the signature algorithm identifier in the mitigated by including the signature algorithm identifier in the
data to be signed. data to be signed.
8.2. Edwards-curve Digital Signature Algorithms (EdDSA)
[I-D.irtf-cfrg-eddsa] describes the elliptic curve signature scheme
Edwards-curve Digital Signature Algorithm (EdDSA). In that document,
the signature algorithm is instantiated using parameters for
edwards25519 and edwards448 curves. The document additionally
describes two variants of the EdDSA algorithm: Pure EdDSA, where no
hash function is applied to the content before signing and, HashEdDSA
where a hash function is applied to the content before signing and
the result of that hash function is signed. For use with COSE, only
the pure EdDSA version is used. This is because it is not expected
that extremely large contents are going to be needed and, based on
the arrangement of the message structure, the entire message is going
to need to be held in memory in order to create or verify a
signature. Thus, the use of an incremental update process would not
be useful. Applications can provide the same features by defining
the content of the message as a hash value and transporting the COSE
message and the content as separate items.
The algorithms defined in this document can be found in Table 6. A
single signature algorithm is defined which can be used for multiple
curves.
+-------+-------+-------------+
| name | value | description |
+-------+-------+-------------+
| EdDSA | -8 | EdDSA |
+-------+-------+-------------+
Table 6: EdDSA Algorithm Values
[I-D.irtf-cfrg-eddsa] describes the method of encoding the signature
value.
When using a COSE key for this algorithm the following checks are
made:
o The 'kty' field MUST be present and it MUST be 'OKP'.
o The 'crv' field MUST be present, and it MUST be a curve defined
for this signature algorithm.
o If the 'alg' field is present, it MUST match 'EdDSA'.
o If the 'key_ops' field is present, it MUST include 'sign' when
creating an EdDSA signature.
o If the 'key_ops' field is present, it MUST include 'verify' when
verifying an EdDSA signature.
8.2.1. Security Considerations
The Edwards curves for EdDSA and ECDH are distinct and should not be
used for the other algorithm.
If batch signature verification is performed, a well-seeded
cryptographic random number generator is REQUIRED. Signing and non-
batch signature verification are deterministic operations and do not
nee random nuber of any kind.
9. Message Authentication (MAC) Algorithms 9. Message Authentication (MAC) Algorithms
Message Authentication Codes (MACs) provide data authentication and Message Authentication Codes (MACs) provide data authentication and
integrity protection. They provide either no or very limited data integrity protection. They provide either no or very limited data
origination. (One cannot, for example, be used to prove the identity origination. (One cannot, for example, be used to prove the identity
of the sender to a third party.) of the sender to a third party.)
MACs use the same scheme as signature with appendix algorithms. The MACs use the same scheme as signature with appendix algorithms. The
message content is processed and an authentication code is produced. message content is processed and an authentication code is produced.
The authentication code is frequently called a tag. The authentication code is frequently called a tag.
The MAC functions are: The MAC functions are:
tag = MAC_Create(message content, key) tag = MAC_Create(message content, key)
valid = MAC_Verify(message content, key, tag) valid = MAC_Verify(message content, key, tag)
MAC algorithms can be based on either a block cipher algorithm (i.e. MAC algorithms can be based on either a block cipher algorithm (i.e.
AES-MAC) or a hash algorithm (i.e. HMAC). This document defines a AES-MAC) or a hash algorithm (i.e. HMAC). This document defines a
MAC algorithm for each of these two constructions. MAC algorithm using each of these constructions.
MAC algorithms are used in the COSE_Mac and COSE_Mac1 structures.
9.1. Hash-based Message Authentication Codes (HMAC) 9.1. Hash-based Message Authentication Codes (HMAC)
The Hash-base Message Authentication Code algorithm (HMAC) The Hash-base Message Authentication Code algorithm (HMAC)
[RFC2104][RFC4231] was designed to deal with length extension [RFC2104][RFC4231] was designed to deal with length extension
attacks. The algorithm was also designed to allow for new hash attacks. The algorithm was also designed to allow for new hash
algorithms to be directly plugged in without changes to the hash algorithms to be directly plugged in without changes to the hash
function. The HMAC design process has been vindicated as, while the function. The HMAC design process has been vindicated as, while the
security of hash algorithms such as MD5 has decreased over time, the security of hash algorithms such as MD5 has decreased over time, the
security of HMAC combined with MD5 has not yet been shown to be security of HMAC combined with MD5 has not yet been shown to be
skipping to change at page 39, line 48 skipping to change at page 40, line 16
hash function (h) and an authentication tag value length. For this hash function (h) and an authentication tag value length. For this
specification, the inner and outer padding are fixed to the values specification, the inner and outer padding are fixed to the values
set in [RFC2104]. The length of the authentication tag corresponds set in [RFC2104]. The length of the authentication tag corresponds
to the difficulty of producing a forgery. For use in constrained to the difficulty of producing a forgery. For use in constrained
environments, we define a set of HMAC algorithms that are truncated. environments, we define a set of HMAC algorithms that are truncated.
There are currently no known issues with truncation, however the There are currently no known issues with truncation, however the
security strength of the message tag is correspondingly reduced in security strength of the message tag is correspondingly reduced in
strength. When truncating, the left-most tag length bits are kept strength. When truncating, the left-most tag length bits are kept
and transmitted. and transmitted.
The algorithm defined in this document can be found in Table 6. The algorithm defined in this document can be found in Table 7.
+-----------+-------+---------+----------+--------------------------+ +-----------+-------+---------+----------+--------------------------+
| name | value | Hash | Tag | description | | name | value | Hash | Tag | description |
| | | | Length | | | | | | Length | |
+-----------+-------+---------+----------+--------------------------+ +-----------+-------+---------+----------+--------------------------+
| HMAC | 4 | SHA-256 | 64 | HMAC w/ SHA-256 | | HMAC | 4 | SHA-256 | 64 | HMAC w/ SHA-256 |
| 256/64 | | | | truncated to 64 bits | | 256/64 | | | | truncated to 64 bits |
| | | | | | | | | | | |
| HMAC | 5 | SHA-256 | 256 | HMAC w/ SHA-256 | | HMAC | 5 | SHA-256 | 256 | HMAC w/ SHA-256 |
| 256/256 | | | | | | 256/256 | | | | |
| | | | | | | | | | | |
| HMAC | 6 | SHA-384 | 384 | HMAC w/ SHA-384 | | HMAC | 6 | SHA-384 | 384 | HMAC w/ SHA-384 |
| 384/384 | | | | | | 384/384 | | | | |
| | | | | | | | | | | |
| HMAC | 7 | SHA-512 | 512 | HMAC w/ SHA-512 | | HMAC | 7 | SHA-512 | 512 | HMAC w/ SHA-512 |
| 512/512 | | | | | | 512/512 | | | | |
+-----------+-------+---------+----------+--------------------------+ +-----------+-------+---------+----------+--------------------------+
Table 6: HMAC Algorithm Values Table 7: HMAC Algorithm Values
Some recipient algorithms carry the key while others derive a key Some recipient algorithms carry the key while others derive a key
from secret data. For those algorithms that carry the key (i.e. from secret data. For those algorithms that carry the key (i.e.
AES-KeyWrap), the size of the HMAC key SHOULD be the same size as the AES-KeyWrap), the size of the HMAC key SHOULD be the same size as the
underlying hash function. For those algorithms that derive the key underlying hash function. For those algorithms that derive the key
(i.e. ECDH), the derived key MUST be the same size as the underlying (i.e. ECDH), the derived key MUST be the same size as the underlying
hash function. hash function.
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
skipping to change at page 41, line 8 skipping to change at page 41, line 18
o If the 'key_ops' field is present, it MUST include 'verify' when o If the 'key_ops' field is present, it MUST include 'verify' when
verifying an HMAC authentication tag. verifying an HMAC authentication tag.
Implementations creating and validating MAC values MUST validate that Implementations creating and validating MAC values MUST validate that
the key type, key length, and algorithm are correct and appropriate the key type, key length, and algorithm are correct and appropriate
for the entities involved. for the entities involved.
9.1.1. Security Considerations 9.1.1. Security Considerations
HMAC has proved to be resistant to attack even when used with HMAC has proved to be resistant to attack even when used with
weakening hash algorithms. The current best method appears to be a weakened hash algorithms. The current best method appears to be a
brute force attack on the key. This means that key size is going to brute force attack on the key. This means that key size is going to
be directly related to the security of an HMAC operation. be directly related to the security of an HMAC operation.
9.2. AES Message Authentication Code (AES-CBC-MAC) 9.2. AES Message Authentication Code (AES-CBC-MAC)
AES-CBC-MAC is defined in [MAC]. (Note this is not the same AES-CBC-MAC is defined in [MAC]. (Note this is not the same
algorithm as AES-CMAC [RFC4493]). algorithm as AES-CMAC [RFC4493]).
AES-CBC-MAC is parameterized by the key length, the authentication AES-CBC-MAC is parameterized by the key length, the authentication
tag length and the IV used. For all of these algorithms, the IV is tag length and the IV used. For all of these algorithms, the IV is
fixed to all zeros. We provide an array of algorithms for various fixed to all zeros. We provide an array of algorithms for various
key lengths and tag lengths. The algorithms defined in this document key lengths and tag lengths. The algorithms defined in this document
are found in Table 7. are found in Table 8.
+-------------+-------+----------+----------+-----------------------+ +-------------+-------+----------+----------+-----------------------+
| name | value | key | tag | description | | name | value | key | tag | description |
| | | length | length | | | | | length | length | |
+-------------+-------+----------+----------+-----------------------+ +-------------+-------+----------+----------+-----------------------+
| AES-MAC | 14 | 128 | 64 | AES-MAC 128 bit key, | | AES-MAC | 14 | 128 | 64 | AES-MAC 128 bit key, |
| 128/64 | | | | 64-bit tag | | 128/64 | | | | 64-bit tag |
| | | | | | | | | | | |
| AES-MAC | 15 | 256 | 64 | AES-MAC 256 bit key, | | AES-MAC | 15 | 256 | 64 | AES-MAC 256 bit key, |
| 256/64 | | | | 64-bit tag | | 256/64 | | | | 64-bit tag |
| | | | | | | | | | | |
| AES-MAC | 25 | 128 | 128 | AES-MAC 128 bit key, | | AES-MAC | 25 | 128 | 128 | AES-MAC 128 bit key, |
| 128/128 | | | | 128-bit tag | | 128/128 | | | | 128-bit tag |
| | | | | | | | | | | |
| AES-MAC | 26 | 256 | 128 | AES-MAC 256 bit key, | | AES-MAC | 26 | 256 | 128 | AES-MAC 256 bit key, |
| 256/128 | | | | 128-bit tag | | 256/128 | | | | 128-bit tag |
+-------------+-------+----------+----------+-----------------------+ +-------------+-------+----------+----------+-----------------------+
Table 7: AES-MAC Algorithm Values Table 8: AES-MAC Algorithm Values
Keys may be obtained either from a key structure or from a recipient Keys may be obtained either from a key structure or from a recipient
structure. Implementations creating and validating MAC values MUST structure. Implementations creating and validating MAC values MUST
validate that the key type, key length and algorithm are correct and validate that the key type, key length and algorithm are correct and
appropriate for the entities involved. appropriate for the entities involved.
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
o The 'kty' field MUST be present and it MUST be 'Symmetric'. o The 'kty' field MUST be present and it MUST be 'Symmetric'.
skipping to change at page 42, line 24 skipping to change at page 42, line 34
9.2.1. Security Considerations 9.2.1. Security Considerations
A number of attacks exist against CBC-MAC that need to be considered. A number of attacks exist against CBC-MAC that need to be considered.
o A single key must only be used for messages of a fixed and known o A single key must only be used for messages of a fixed and known
length. If this is not the case, an attacker will be able to length. If this is not the case, an attacker will be able to
generate a message with a valid tag given two message, tag pairs. generate a message with a valid tag given two message, tag pairs.
This can be addressed by using different keys for different length This can be addressed by using different keys for different length
messages. The current structure mitigates this problem as a messages. The current structure mitigates this problem as a
specific encoding structure which includes lengths is build and specific encoding structure which includes lengths is build and
signed. (CMAC mode also addresses this issue.) signed. (CMAC also addresses this issue.)
o If the same key is used for both encryption and authentication o If the same key is used for both encryption and authentication
operations, using CBC modes an attacker can produce messages with operations, using CBC modes an attacker can produce messages with
a valid authentication code. a valid authentication code.
o If the IV can be modified, then messages can be forged. This is o If the IV can be modified, then messages can be forged. This is
addressed by fixing the IV to all zeros. addressed by fixing the IV to all zeros.
10. Content Encryption Algorithms 10. Content Encryption Algorithms
Content Encryption Algorithms provide data confidentiality for Content Encryption Algorithms provide data confidentiality for
potentially large blocks of data using a symmetric key. They provide potentially large blocks of data using a symmetric key. They provide
integrity on the data that was encrypted, however they provide either integrity on the data that was encrypted, however they provide either
no or very limited data origination. (One cannot, for example, be no or very limited data origination. (One cannot, for example, be
used to prove the identity of the sender to a third party.) The used to prove the identity of the sender to a third party.) The
ability to provide data origination is linked to how the symmetric ability to provide data origination is linked to how the CEK is
key is obtained. obtained.
COSE restricts the set of legal content encryption algorithms to COSE restricts the set of legal content encryption algorithms to
those that support authentication both of the content and additional those that support authentication both of the content and additional
data. The encryption process will generate some type of data. The encryption process will generate some type of
authentication value, but that value may be either explicit or authentication value, but that value may be either explicit or
implicit in terms of the algorithm definition. For simplicity sake, implicit in terms of the algorithm definition. For simplicity sake,
the authentication code will normally be defined as being appended to the authentication code will normally be defined as being appended to
the cipher text stream. The encryption functions are: the cipher text stream. The encryption functions are:
ciphertext = Encrypt(message content, key, additional data) ciphertext = Encrypt(message content, key, additional data)
valid, message content = Decrypt(cipher text, key, additional data) valid, message content = Decrypt(cipher text, key, additional data)
Most AEAD algorithms are logically defined as returning the message Most AEAD algorithms are logically defined as returning the message
content only if the decryption is valid. Many but not all content only if the decryption is valid. Many but not all
implementations will follow this convention. The message content implementations will follow this convention. The message content
MUST NOT be used if the decryption does not validate. MUST NOT be used if the decryption does not validate.
This algorithms are used in COSE_Encrypt and COSE_Encrypt1.
10.1. AES GCM 10.1. AES GCM
The GCM mode is a generic authenticated encryption block cipher mode The GCM mode is a generic authenticated encryption block cipher mode
defined in [AES-GCM]. The GCM mode is combined with the AES block defined in [AES-GCM]. The GCM mode is combined with the AES block
encryption algorithm to define an AEAD cipher. encryption algorithm to define an AEAD cipher.
The GCM mode is parameterized with by the size of the authentication The GCM mode is parameterized with by the size of the authentication
tag and the size of the nonce. This document fixes the size of the tag and the size of the nonce. This document fixes the size of the
nonce at 96-bits. The size of the authentication tag is limited to a nonce at 96-bits. The size of the authentication tag is limited to a
small set of values. For this document however, the size of the small set of values. For this document however, the size of the
authentication tag is fixed at 128 bits. authentication tag is fixed at 128 bits.
The set of algorithms defined in this document are in Table 8. The set of algorithms defined in this document are in Table 9.
+---------+-------+------------------------------------------+ +---------+-------+------------------------------------------+
| name | value | description | | name | value | description |
+---------+-------+------------------------------------------+ +---------+-------+------------------------------------------+
| A128GCM | 1 | AES-GCM mode w/ 128-bit key, 128-bit tag | | A128GCM | 1 | AES-GCM mode w/ 128-bit key, 128-bit tag |
| | | | | | | |
| A192GCM | 2 | AES-GCM mode w/ 192-bit key, 128-bit tag | | A192GCM | 2 | AES-GCM mode w/ 192-bit key, 128-bit tag |
| | | | | | | |
| A256GCM | 3 | AES-GCM mode w/ 256-bit key, 128-bit tag | | A256GCM | 3 | AES-GCM mode w/ 256-bit key, 128-bit tag |
+---------+-------+------------------------------------------+ +---------+-------+------------------------------------------+
Table 8: Algorithm Value for AES-GCM Table 9: Algorithm Value for AES-GCM
Keys may be obtained either from a key structure or from a recipient Keys may be obtained either from a key structure or from a recipient
structure. Implementations encrypting and decrypting MUST validate structure. Implementations encrypting and decrypting MUST validate
that the key type, key length and algorithm are correct and that the key type, key length and algorithm are correct and
appropriate for the entities involved. appropriate for the entities involved.
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
o The 'kty' field MUST be present and it MUST be 'Symmetric'. o The 'kty' field MUST be present and it MUST be 'Symmetric'.
skipping to change at page 44, line 23 skipping to change at page 44, line 33
When using AES-GCM, the following restrictions MUST be enforced: When using AES-GCM, the following restrictions MUST be enforced:
o The key and nonce pair MUST be unique for every message encrypted. o The key and nonce pair MUST be unique for every message encrypted.
o The total amount of data encrypted for a single key MUST NOT o The total amount of data encrypted for a single key MUST NOT
exceed 2^39 - 256 bits. An explicit check is required only in exceed 2^39 - 256 bits. An explicit check is required only in
environments where it is expected that it might be exceeded. environments where it is expected that it might be exceeded.
Consideration was given to supporting smaller tag values, the Consideration was given to supporting smaller tag values, the
constrained community would desire tag sizes in the 64-bit range. constrained community would desire tag sizes in the 64-bit range.
Doing show drastically changes both the maximum messages size Doing so drastically changes both the maximum messages size
(generally not an issue) and the number of times that a key can be (generally not an issue) and the number of times that a key can be
used. Given that CCM is the usual mode for constrained environments used. Given that CCM is the usual mode for constrained environments
restricted modes are not supported. restricted modes are not supported.
10.2. AES CCM 10.2. AES CCM
Counter with CBC-MAC (CCM) is a generic authentication encryption Counter with CBC-MAC (CCM) is a generic authentication encryption
block cipher mode defined in [RFC3610]. The CCM mode is combined block cipher mode defined in [RFC3610]. The CCM mode is combined
with the AES block encryption algorithm to define a commonly used with the AES block encryption algorithm to define a commonly used
content encryption algorithm used in constrained devices. content encryption algorithm used in constrained devices.
The CCM mode has two parameter choices. The first choice is M, the The CCM mode has two parameter choices. The first choice is M, the
size of the authentication field. The choice of the value for M size of the authentication field. The choice of the value for M
involves a trade-off between message expansion and the probably that involves a trade-off between message growth (from the tag) and the
an attacker can undetectably modify a message. The second choice is probably that an attacker can undetectably modify a message. The
L, the size of the length field. This value requires a trade-off second choice is L, the size of the length field. This value
between the maximum message size and the size of the Nonce. requires a trade-off between the maximum message size and the size of
the Nonce.
It is unfortunate that the specification for CCM specified L and M as It is unfortunate that the specification for CCM specified L and M as
a count of bytes rather than a count of bits. This leads to possible a count of bytes rather than a count of bits. This leads to possible
misunderstandings where AES-CCM-8 is frequently used to refer to a misunderstandings where AES-CCM-8 is frequently used to refer to a
version of CCM mode where the size of the authentication is 64 bits version of CCM mode where the size of the authentication is 64 bits
and not 8 bits. These values have traditionally been specified as and not 8 bits. These values have traditionally been specified as
bit counts rather than byte counts. This document will follow the bit counts rather than byte counts. This document will follow the
tradition of using bit counts so that it is easier to compare the convention of using bit counts so that it is easier to compare the
different algorithms presented in this document. different algorithms presented in this document.
We define a matrix of algorithms in this document over the values of We define a matrix of algorithms in this document over the values of
L and M. Constrained devices are usually operating in situations L and M. Constrained devices are usually operating in situations
where they use short messages and want to avoid doing recipient where they use short messages and want to avoid doing recipient
specific cryptographic operations. This favors smaller values of specific cryptographic operations. This favors smaller values of
both L and M. Less constrained devices do will want to be able to both L and M. Less constrained devices do will want to be able to
user larger messages and are more willing to generate new keys for user larger messages and are more willing to generate new keys for
every operation. This favors larger values of L and M. every operation. This favors larger values of L and M.
skipping to change at page 46, line 45 skipping to change at page 46, line 45
| | | | | | 128-bit key, | | | | | | | 128-bit key, |
| | | | | | 128-bit tag, 7-byte | | | | | | | 128-bit tag, 7-byte |
| | | | | | nonce | | | | | | | nonce |
| | | | | | | | | | | | | |
| AES-CCM-64-128-256 | 33 | 64 | 128 | 256 | AES-CCM mode | | AES-CCM-64-128-256 | 33 | 64 | 128 | 256 | AES-CCM mode |
| | | | | | 256-bit key, | | | | | | | 256-bit key, |
| | | | | | 128-bit tag, 7-byte | | | | | | | 128-bit tag, 7-byte |
| | | | | | nonce | | | | | | | nonce |
+--------------------+-------+----+-----+-----+---------------------+ +--------------------+-------+----+-----+-----+---------------------+
Table 9: Algorithm Values for AES-CCM Table 10: Algorithm Values for AES-CCM
Keys may be obtained either from a key structure or from a recipient Keys may be obtained either from a key structure or from a recipient
structure. Implementations encrypting and decrypting MUST validate structure. Implementations encrypting and decrypting MUST validate
that the key type, key length and algorithm are correct and that the key type, key length and algorithm are correct and
appropriate for the entities involved. appropriate for the entities involved.
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
o The 'kty' field MUST be present and it MUST be 'Symmetric'. o The 'kty' field MUST be present and it MUST be 'Symmetric'.
skipping to change at page 47, line 44 skipping to change at page 47, line 44
This reduces the security of the key size by half. Ways to deal with This reduces the security of the key size by half. Ways to deal with
this attack include adding a random portion to the nonce value and/or this attack include adding a random portion to the nonce value and/or
increasing the key size used. Using a portion of the nonce for a increasing the key size used. Using a portion of the nonce for a
random value will decrease the number of messages that a single key random value will decrease the number of messages that a single key
can be used for. Increasing the key size may require more resources can be used for. Increasing the key size may require more resources
in the constrained device. See sections 5 and 10 of [RFC3610] for in the constrained device. See sections 5 and 10 of [RFC3610] for
more information. more information.
10.3. ChaCha20 and Poly1305 10.3. ChaCha20 and Poly1305
ChaCha20 and Poly1305 combined together is a new AEAD mode that is ChaCha20 and Poly1305 combined together is an AEAD mode that is
defined in [RFC7539]. This is a new algorithm defined to be a cipher defined in [RFC7539]. This is an algorithm defined to be a cipher
that is not AES and thus would not suffer from any future weaknesses that is not AES and thus would not suffer from any future weaknesses
found in AES. These cryptographic functions are designed to be fast found in AES. These cryptographic functions are designed to be fast
in software-only implementations. in software-only implementations.
The ChaCha20/Poly1305 AEAD construction defined in [RFC7539] has no The ChaCha20/Poly1305 AEAD construction defined in [RFC7539] has no
parameterization. It takes a 256-bit key and a 96-bit nonce as well parameterization. It takes a 256-bit key and a 96-bit nonce as well
as the plain text and additional data as inputs and produces the as the plain text and additional data as inputs and produces the
cipher text as an option. We define one algorithm identifier for cipher text as an option. We define one algorithm identifier for
this algorithm in Table 10. this algorithm in Table 11.
+-------------------+-------+---------------------------------------+ +-------------------+-------+---------------------------------------+
| name | value | description | | name | value | description |
+-------------------+-------+---------------------------------------+ +-------------------+-------+---------------------------------------+
| ChaCha20/Poly1305 | 24 | ChaCha20/Poly1305 w/ 256-bit key, | | ChaCha20/Poly1305 | 24 | ChaCha20/Poly1305 w/ 256-bit key, |
| | | 128-bit tag | | | | 128-bit tag |
+-------------------+-------+---------------------------------------+ +-------------------+-------+---------------------------------------+
Table 10: Algorithm Value for AES-GCM Table 11: Algorithm Value for AES-GCM
Keys may be obtained either from a key structure or from a recipient Keys may be obtained either from a key structure or from a recipient
structure. Implementations encrypting and decrypting MUST validate structure. Implementations encrypting and decrypting MUST validate
that the key type, key length and algorithm are correct and that the key type, key length and algorithm are correct and
appropriate for the entities involved. appropriate for the entities involved.
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
o The 'kty' field MUST be present and it MUST be 'Symmetric'. o The 'kty' field MUST be present and it MUST be 'Symmetric'.
skipping to change at page 49, line 24 skipping to change at page 49, line 24
The same KDF function can be setup to deal with the first two types The same KDF function can be setup to deal with the first two types
of secrets different. The KDF function defined in Section 11.1 is of secrets different. The KDF function defined in Section 11.1 is
such a function. This is reflected in the set of algorithms defined such a function. This is reflected in the set of algorithms defined
for HKDF. for HKDF.
When using KDF functions, one component that is included is context When using KDF functions, one component that is included is context
information. Context information is used to allow for different information. Context information is used to allow for different
keying information to be derived from the same secret. The use of keying information to be derived from the same secret. The use of
context based keying material is considered to be a good security context based keying material is considered to be a good security
practice. This document defines a single context structure and a practice.
single KDF function.
This document defines a single context structure and a single KDF
function. These elements are used for all of the recipient
algorithms defined in this document that require a KDF process.
These algorithms are defined in Section 12.1.2, Section 12.4.1, and
Section 12.5.1.
11.1. HMAC-based Extract-and-Expand Key Derivation Function (HKDF) 11.1. HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
The HKDF key derivation algorithm is defined in [RFC5869]. The HKDF key derivation algorithm is defined in [RFC5869].
The HKDF algorithm takes these inputs: The HKDF algorithm takes these inputs:
secret - a shared value that is secret. Secrets may be either secret - a shared value that is secret. Secrets may be either
previously shared or derived from operations like a DH key previously shared or derived from operations like a DH key
agreement. agreement.
salt - an optional value that is used to change the generation salt - an optional value that is used to change the generation
process. The salt value can be either public or private. If the process. The salt value can be either public or private. If the
salt is public and carried in the message, then the 'salt' salt is public and carried in the message, then the 'salt'
algorithm header parameter defined in Table 12 is used. While algorithm header parameter defined in Table 13 is used. While
[RFC5869] suggests that the length of the salt be the same as the [RFC5869] suggests that the length of the salt be the same as the
length of the underlying hash value, any amount of salt will length of the underlying hash value, any amount of salt will
improve the security as different key values will be generated. improve the security as different key values will be generated.
This parameter is protected by being included in the key This parameter is protected by being included in the key
computation and does not need to be separately authenticated. The computation and does not need to be separately authenticated. The
salt value does not need to be unique for every message sent. salt value does not need to be unique for every message sent.
length - the number of bytes of output that need to be generated. length - the number of bytes of output that need to be generated.
context information - Information that describes the context in context information - Information that describes the context in
which the resulting value will be used. Making this information which the resulting value will be used. Making this information
specific to the context that the material is going to be used specific to the context in which the material is going to be used
ensures that the resulting material will always be tied to the ensures that the resulting material will always be tied to that
context. The context structure used is encoded into the algorithm usage. The context structure defined in Section 11.2 is used by
identifier. the KDF functions in this document.
PRF - The underlying pseudo-random function to be used in the HKDF PRF - The underlying pseudo-random function to be used in the HKDF
algorithm. The PRF is encoded into the HKDF algorithm selection. algorithm. The PRF is encoded into the HKDF algorithm selection.
u
HKDF is defined to use HMAC as the underlying PRF. However, it is HKDF is defined to use HMAC as the underlying PRF. However, it is
possible to use other functions in the same construct to provide a possible to use other functions in the same construct to provide a
different KDF function that is more appropriate in the constrained different KDF function that is more appropriate in the constrained
world. Specifically, one can use AES-CBC-MAC as the PRF for the world. Specifically, one can use AES-CBC-MAC as the PRF for the
expand step, but not for the extract step. When using a good random expand step, but not for the extract step. When using a good random
shared secret of the correct length, the extract step can be skipped. shared secret of the correct length, the extract step can be skipped.
For the AES algorithm versions, the extract step is always skipped. For the AES algorithm versions, the extract step is always skipped.
The extract step cannot be skipped if the secret is not uniformly The extract step cannot be skipped if the secret is not uniformly
random, for example if it is the result of an ECDH key agreement random, for example if it is the result of an ECDH key agreement
step. (This implies that the AES HKDF version cannot be used with step. (This implies that the AES HKDF version cannot be used with
ECDH.) If the extract step is skipped, the 'salt' value is not used ECDH.) If the extract step is skipped, the 'salt' value is not used
as part of the HKDF functionality. as part of the HKDF functionality.
The algorithms defined in this document are found in Table 11. The algorithms defined in this document are found in Table 12.
+---------------+-----------------+---------------------------------+ +---------------+-----------------+---------------------------------+
| name | PRF | context | | name | PRF | description |
+---------------+-----------------+---------------------------------+ +---------------+-----------------+---------------------------------+
| HKDF SHA-256 | HMAC with | HKDF using HMAC SHA-256 as the | | HKDF SHA-256 | HMAC with | HKDF using HMAC SHA-256 as the |
| | SHA-256 | PRF | | | SHA-256 | PRF |
| | | | | | | |
| HKDF SHA-512 | HMAC with | HKDF using HMAC SHA-512 as the | | HKDF SHA-512 | HMAC with | HKDF using HMAC SHA-512 as the |
| | SHA-512 | PRF | | | SHA-512 | PRF |
| | | | | | | |
| HKDF AES- | AES-CBC-MAC-128 | HKDF using AES-MAC as the PRF | | HKDF AES- | AES-CBC-MAC-128 | HKDF using AES-MAC as the PRF |
| MAC-128 | | w/ 128-bit key | | MAC-128 | | w/ 128-bit key |
| | | | | | | |
| HKDF AES- | AES-CBC-MAC-256 | HKDF using AES-MAC as the PRF | | HKDF AES- | AES-CBC-MAC-256 | HKDF using AES-MAC as the PRF |
| MAC-256 | | w/ 256-bit key | | MAC-256 | | w/ 256-bit key |
+---------------+-----------------+---------------------------------+ +---------------+-----------------+---------------------------------+
Table 11: HKDF algorithms Table 12: HKDF algorithms
+------+-------+------+-------------+ +------+-------+------+-------------+
| name | label | type | description | | name | label | type | description |
+------+-------+------+-------------+ +------+-------+------+-------------+
| salt | -20 | bstr | Random salt | | salt | -20 | bstr | Random salt |
+------+-------+------+-------------+ +------+-------+------+-------------+
Table 12: HKDF Algorithm Parameters Table 13: HKDF Algorithm Parameters
11.2. Context Information Structure 11.2. Context Information Structure
The context information structure is used to ensure that the derived The context information structure is used to ensure that the derived
keying material is "bound" to the context of the transaction. The keying material is "bound" to the context of the transaction. The
context information structure used here is based on that defined in context information structure used here is based on that defined in
[SP800-56A]. By using CBOR for the encoding of the context [SP800-56A]. By using CBOR for the encoding of the context
information structure, we automatically get the same type and length information structure, we automatically get the same type and length
separation of fields that is obtained by the use of ASN.1. This separation of fields that is obtained by the use of ASN.1. This
means that there is no need to encode the lengths for the base means that there is no need to encode the lengths for the base
skipping to change at page 51, line 45 skipping to change at page 51, line 45
sources: sources:
o Fields can be define by the application. This is commonly used to o Fields can be define by the application. This is commonly used to
assign fixed names to parties, but can be used for other items assign fixed names to parties, but can be used for other items
such as nonces. such as nonces.
o Fields can be defined by usage of the output. Examples of this o Fields can be defined by usage of the output. Examples of this
are the algorithm and key size that are being generated. are the algorithm and key size that are being generated.
o Fields can be defined by parameters from the message. We define a o Fields can be defined by parameters from the message. We define a
set of parameters in Table 13 which can be used to carry the set of parameters in Table 14 which can be used to carry the
values associated with the context structure. Examples of this values associated with the context structure. Examples of this
are identities and nonce values. These parameters are designed to are identities and nonce values. These parameters are designed to
be placed in the unprotected bucket of the recipient structure. be placed in the unprotected bucket of the recipient structure.
(They do not need to be in the protected bucket since they already (They do not need to be in the protected bucket since they already
are included in the cryptographic computation by virtue of being are included in the cryptographic computation by virtue of being
included in the context structure.) included in the context structure.)
+---------------+-------+-----------+-------------------------------+ +---------------+-------+-----------+-------------------------------+
| name | label | type | description | | name | label | type | description |
+---------------+-------+-----------+-------------------------------+ +---------------+-------+-----------+-------------------------------+
skipping to change at page 52, line 27 skipping to change at page 52, line 27
| PartyV | -24 | bstr | Party V identity Information | | PartyV | -24 | bstr | Party V identity Information |
| identity | | | | | identity | | | |
| | | | | | | | | |
| PartyV nonce | -25 | bstr / | Party V provided nonce | | PartyV nonce | -25 | bstr / | Party V provided nonce |
| | | int | | | | | int | |
| | | | | | | | | |
| PartyV other | -26 | bstr | Party V other provided | | PartyV other | -26 | bstr | Party V other provided |
| | | | information | | | | | information |
+---------------+-------+-----------+-------------------------------+ +---------------+-------+-----------+-------------------------------+
Table 13: Context Algorithm Parameters Table 14: Context Algorithm Parameters
We define a CBOR object to hold the context information. This object We define a CBOR object to hold the context information. This object
is referred to as CBOR_KDF_Context. The object is based on a CBOR is referred to as CBOR_KDF_Context. The object is based on a CBOR
array type. The fields in the array are: array type. The fields in the array are:
AlgorithmID This field indicates the algorithm for which the key AlgorithmID This field indicates the algorithm for which the key
material will be used. This field is required to be present. The material will be used. This field is required to be present. The
field exists in the context information so that if the same field exists in the context information so that if the same
environment is used for different algorithms, then completely environment is used for different algorithms, then completely
different keys will be generated each of those algorithms. (This different keys will be generated each of those algorithms. (This
skipping to change at page 54, line 19 skipping to change at page 54, line 19
other The field other is for free form data defined by the other The field other is for free form data defined by the
application. An example is that an application could defined application. An example is that an application could defined
two different strings to be placed here to generate different two different strings to be placed here to generate different
keys for a data stream vs a control stream. This field is keys for a data stream vs a control stream. This field is
optional and will only be present if the application defines a optional and will only be present if the application defines a
structure for this information. Applications that define this structure for this information. Applications that define this
SHOULD use CBOR to encode the data so that types and lengths SHOULD use CBOR to encode the data so that types and lengths
are correctly include. are correctly include.
SuppPrivInfo This field contains private information that is SuppPrivInfo This field contains private information that is
mutually known information. An example of this information would mutually known private information. An example of this
be a pre-existing shared secret. (This could for example, be used information would be a pre-existing shared secret. (This could
in combination with an ECDH key agreement to provide a secondary for example, be used in combination with an ECDH key agreement to
proof of identity.) The field is optional and will only be provide a secondary proof of identity.) The field is optional and
present if the application defines a structure for this will only be present if the application defines a structure for
information. Applications that define this SHOULD use CBOR to this information. Applications that define this SHOULD use CBOR
encode the data so that types and lengths are correctly included. to encode the data so that types and lengths are correctly
included.
The following CDDL fragment corresponds to the text above. The following CDDL fragment corresponds to the text above.
PartyInfo = ( PartyInfo = (
? nonce : bstr / int, ? nonce : bstr / int,
? identity : bstr, ? identity : bstr,
? other : bstr, ? other : bstr,
) )
COSE_KDF_Context = [ COSE_KDF_Context = [
skipping to change at page 55, line 13 skipping to change at page 55, line 14
a set of algorithms are specified for each of the classes. The names a set of algorithms are specified for each of the classes. The names
of the recipient algorithm classes used here are the same as are of the recipient algorithm classes used here are the same as are
defined in [RFC7516]. Other specifications use different terms for defined in [RFC7516]. Other specifications use different terms for
the recipient algorithm classes or do not support some of the the recipient algorithm classes or do not support some of the
recipient algorithm classes. recipient algorithm classes.
12.1. Direct Encryption 12.1. Direct Encryption
The direct encryption class algorithms share a secret between the The direct encryption class algorithms share a secret between the
sender and the recipient that is used either directly or after sender and the recipient that is used either directly or after
manipulation as the content key. When direct encryption mode is manipulation as the CEK. When direct encryption mode is used, it
used, it MUST be the only mode used on the message. MUST be the only mode used on the message.
The COSE_Enveloped structure for the recipient is organized as The COSE_Encrypt structure for the recipient is organized as follows:
follows:
o The 'protected' field MUST be a zero length item unless it is used o The 'protected' field MUST be a zero length item unless it is used
in the computation of the content key. in the computation of the content key.
o The 'alg' parameter MUST be present. o The 'alg' parameter MUST be present.
o A parameter identifying the shared secret SHOULD be present. o A parameter identifying the shared secret SHOULD be present.
o The 'ciphertext' field MUST be a zero length item. o The 'ciphertext' field MUST be a zero length item.
o The 'recipients' field MUST be absent. o The 'recipients' field MUST be absent.
12.1.1. Direct Key 12.1.1. Direct Key
This recipient algorithm is the simplest, the identified key is This recipient algorithm is the simplest, the identified key is
directly used as the key for the next layer down in the message. directly used as the key for the next layer down in the message.
There are no algorithm parameters defined for this algorithm. The There are no algorithm parameters defined for this algorithm. The
algorithm identifier value is assigned in Table 14. algorithm identifier value is assigned in Table 15.
When this algorithm is used, the protected field MUST be zero length. When this algorithm is used, the protected field MUST be zero length.
The key type MUST be 'Symmetric'. The key type MUST be 'Symmetric'.
+--------+-------+-------------------+ +--------+-------+-------------------+
| name | value | description | | name | value | description |
+--------+-------+-------------------+ +--------+-------+-------------------+
| direct | -6 | Direct use of CEK | | direct | -6 | Direct use of CEK |
+--------+-------+-------------------+ +--------+-------+-------------------+
Table 14: Direct Key Table 15: Direct Key
12.1.1.1. Security Considerations 12.1.1.1. Security Considerations
This recipient algorithm has several potential problems that need to This recipient algorithm has several potential problems that need to
be considered: be considered:
o These keys need to have some method to be regularly updated over o These keys need to have some method to be regularly updated over
time. All of the content encryption algorithms specified in this time. All of the content encryption algorithms specified in this
document have limits on how many times a key can be used without document have limits on how many times a key can be used without
significant loss of security. significant loss of security.
skipping to change at page 56, line 30 skipping to change at page 56, line 30
o Breaking one message means all messages are broken. If an o Breaking one message means all messages are broken. If an
adversary succeeds in determining the key for a single message, adversary succeeds in determining the key for a single message,
then the key for all messages is also determined. then the key for all messages is also determined.
12.1.2. Direct Key with KDF 12.1.2. Direct Key with KDF
These recipient algorithms take a common shared secret between the These recipient algorithms take a common shared secret between the
two parties and applies the HKDF function (Section 11.1) using the two parties and applies the HKDF function (Section 11.1) using the
context structure defined in Section 11.2 to transform the shared context structure defined in Section 11.2 to transform the shared
secret into the necessary key. The 'protected' field can be of non- secret into the CEK. The 'protected' field can be of non-zero
zero length. Either the 'salt' parameter of HKDF or the partyU length. Either the 'salt' parameter of HKDF or the partyU 'nonce'
'nonce' parameter of the context structure MUST be present. The parameter of the context structure MUST be present. The salt/nonce
salt/nonce parameter can be generated either randomly or parameter can be generated either randomly or deterministically. The
deterministically. The requirement is that it be a unique value for requirement is that it be a unique value for the shared secret in
the key/IV pair in question. question.
If the salt/nonce value is generated randomly, then it is suggested If the salt/nonce value is generated randomly, then it is suggested
that the length of the random value be the same length as the hash that the length of the random value be the same length as the hash
function underlying HKDF. While there is no way to guarantee that it function underlying HKDF. While there is no way to guarantee that it
will be unique, there is a high probability that it will be unique. will be unique, there is a high probability that it will be unique.
If the salt/nonce value is generated deterministically, it can be If the salt/nonce value is generated deterministically, it can be
guaranteed to be unique and thus there is no length requirement. guaranteed to be unique and thus there is no length requirement.
A new IV must be used if the same key is used in more than one A new IV must be used for each message if the same key is used. The
message. The IV can be modified in a predictable manner, a random IV can be modified in a predictable manner, a random manner or an
manner or an unpredictable manner. One unpredictable manner that can unpredictable manner (i.e. encrypting a counter).
be used is to use the HKDF function to generate the IV. If HKDF is
used for generating the IV, the algorithm identifier is set to "IV- The IV used for a key can also be generated from the same HKDF
functionality as the key is generated. If HKDF is used for
generating the IV, the algorithm identifier is set to "IV-
GENERATION". GENERATION".
When these algorithms are used, the key type MUST be 'symmetric'. When these algorithms are used, the key type MUST be 'symmetric'.
The set of algorithms defined in this document can be found in The set of algorithms defined in this document can be found in
Table 15. Table 16.
+---------------------+-------+-------------+-----------------------+ +---------------------+-------+-------------+-----------------------+
| name | value | KDF | description | | name | value | KDF | description |
+---------------------+-------+-------------+-----------------------+ +---------------------+-------+-------------+-----------------------+
| direct+HKDF-SHA-256 | -10 | HKDF | Shared secret w/ HKDF | | direct+HKDF-SHA-256 | -10 | HKDF | Shared secret w/ HKDF |
| | | SHA-256 | and SHA-256 | | | | SHA-256 | and SHA-256 |
| | | | | | | | | |
| direct+HKDF-SHA-512 | -11 | HKDF | Shared secret w/ HKDF | | direct+HKDF-SHA-512 | -11 | HKDF | Shared secret w/ HKDF |
| | | SHA-512 | and SHA-512 | | | | SHA-512 | and SHA-512 |
| | | | | | | | | |
| direct+HKDF-AES-128 | -12 | HKDF AES- | Shared secret w/ AES- | | direct+HKDF-AES-128 | -12 | HKDF AES- | Shared secret w/ AES- |
| | | MAC-128 | MAC 128-bit key | | | | MAC-128 | MAC 128-bit key |
| | | | | | | | | |
| direct+HKDF-AES-256 | -13 | HKDF AES- | Shared secret w/ AES- | | direct+HKDF-AES-256 | -13 | HKDF AES- | Shared secret w/ AES- |
| | | MAC-256 | MAC 256-bit key | | | | MAC-256 | MAC 256-bit key |
+---------------------+-------+-------------+-----------------------+ +---------------------+-------+-------------+-----------------------+
Table 15: Direct Key Table 16: Direct Key
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
o The 'kty' field MUST be present and it MUST be 'Symmetric'. o The 'kty' field MUST be present and it MUST be 'Symmetric'.
o If the 'alg' field present, it MUST match the KDF algorithm being o If the 'alg' field present, it MUST match the algorithm being
used. used.
o If the 'key_ops' field is present, it MUST include 'deriveKey or o If the 'key_ops' field is present, it MUST include 'deriveKey or
'deriveBits'. 'deriveBits'.
12.1.2.1. Security Considerations 12.1.2.1. Security Considerations
The shared secret needs to have some method to be regularly updated The shared secret needs to have some method to be regularly updated
over time. The shared secret forms the basis of trust. Although not over time. The shared secret forms the basis of trust. Although not
used directly, it should still be subject to scheduled rotation. used directly, it should still be subject to scheduled rotation.
While these methods do not provide for PFS, as the same shared secret
is used for all of the keys generated, if the key for any single
message is discovered only the message (or series of messages) using
that derived key are compromised. A new key derivation step will
generate a new key which requires the same amount of work to get the
key.
12.2. Key Wrapping 12.2. Key Wrapping
In key wrapping mode, the CEK is randomly generated and that key is In key wrapping mode, the CEK is randomly generated and that key is
then encrypted by a shared secret between the sender and the then encrypted by a shared secret between the sender and the
recipient. All of the currently defined key wrapping algorithms for recipient. All of the currently defined key wrapping algorithms for
COSE are AE algorithms. Key wrapping mode is considered to be COSE are AE algorithms. Key wrapping mode is considered to be
superior to direct encryption if the system has any capability for superior to direct encryption if the system has any capability for
doing random key generation. This is because the shared key is used doing random key generation. This is because the shared key is used
to wrap random data rather than data has some degree of organization to wrap random data rather than data has some degree of organization
and may in fact be repeating the same content. The use of Key and may in fact be repeating the same content. The use of Key
Wrapping loses the weak data origination that is provided by the Wrapping loses the weak data origination that is provided by the
direct encryption algorithms. direct encryption algorithms.
The COSE_Enveloped structure for the recipient is organized as The COSE_Encrypt structure for the recipient is organized as follows:
follows:
o The 'protected' field MUST be absent if the key wrap algorithm is o The 'protected' field MUST be absent if the key wrap algorithm is
an AE algorithm. an AE algorithm.
o The 'recipients' field is normally absent, but can be used. o The 'recipients' field is normally absent, but can be used.
Applications MUST deal with a recipient field present, not being Applications MUST deal with a recipient field present, not being
able to decrypt that recipient is an acceptable way of dealing able to decrypt that recipient is an acceptable way of dealing
with it. Failing to process the message is not an acceptable way with it. Failing to process the message is not an acceptable way
of dealing with it. of dealing with it.
skipping to change at page 58, line 38 skipping to change at page 58, line 48
The AES Key Wrapping algorithm is defined in [RFC3394]. This The AES Key Wrapping algorithm is defined in [RFC3394]. This
algorithm uses an AES key to wrap a value that is a multiple of 64 algorithm uses an AES key to wrap a value that is a multiple of 64
bits. As such, it can be used to wrap a key for any of the content bits. As such, it can be used to wrap a key for any of the content
encryption algorithms defined in this document. The algorithm encryption algorithms defined in this document. The algorithm
requires a single fixed parameter, the initial value. This is fixed requires a single fixed parameter, the initial value. This is fixed
to the value specified in Section 2.2.3.1 of [RFC3394]. There are no to the value specified in Section 2.2.3.1 of [RFC3394]. There are no
public parameters that vary on a per invocation basis. The protected public parameters that vary on a per invocation basis. The protected
header field MUST be empty. header field MUST be empty.
Keys may be obtained either from a key structure or from a recipient Keys may be obtained either from a key structure or from a recipient
structure. If the key obtained from a key structure, the key type structure. Implementations encrypting and decrypting MUST validate
MUST be 'Symmetric'. Implementations encrypting and decrypting MUST that the key type, key length and algorithm are correct and
validate that the key type, key length and algorithm are correct and
appropriate for the entities involved. appropriate for the entities involved.
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
o The 'kty' field MUST be present and it MUST be 'Symmetric'. o The 'kty' field MUST be present and it MUST be 'Symmetric'.
o If the 'alg' field present, it MUST match the AES Key Wrap o If the 'alg' field present, it MUST match the AES Key Wrap
algorithm being used. algorithm being used.
skipping to change at page 59, line 21 skipping to change at page 59, line 29
+--------+-------+----------+-----------------------------+ +--------+-------+----------+-----------------------------+
| name | value | key size | description | | name | value | key size | description |
+--------+-------+----------+-----------------------------+ +--------+-------+----------+-----------------------------+
| A128KW | -3 | 128 | AES Key Wrap w/ 128-bit key | | A128KW | -3 | 128 | AES Key Wrap w/ 128-bit key |
| | | | | | | | | |
| A192KW | -4 | 192 | AES Key Wrap w/ 192-bit key | | A192KW | -4 | 192 | AES Key Wrap w/ 192-bit key |
| | | | | | | | | |
| A256KW | -5 | 256 | AES Key Wrap w/ 256-bit key | | A256KW | -5 | 256 | AES Key Wrap w/ 256-bit key |
+--------+-------+----------+-----------------------------+ +--------+-------+----------+-----------------------------+
Table 16: AES Key Wrap Algorithm Values Table 17: AES Key Wrap Algorithm Values
12.2.1.1. Security Considerations for AES-KW 12.2.1.1. Security Considerations for AES-KW
The shared secret need to have some method to be regularly updated The shared secret need to have some method to be regularly updated
over time. The shared secret is the basis of trust. over time. The shared secret is the basis of trust.
12.3. Key Encryption 12.3. Key Encryption
Key Encryption mode is also called key transport mode in some Key Encryption mode is also called key transport mode in some
standards. Key Encryption mode differs from Key Wrap mode in that it standards. Key Encryption mode differs from Key Wrap mode in that it
uses an asymmetric encryption algorithm rather than a symmetric uses an asymmetric encryption algorithm rather than a symmetric
encryption algorithm to protect the key. This document does not encryption algorithm to protect the key. This document does not
define any Key Encryption mode algorithms. define any Key Encryption mode algorithms.
When using a key encryption algorithm, the COSE_Enveloped structure When using a key encryption algorithm, the COSE_Encrypt structure for
for the recipient is organized as follows: the recipient is organized as follows:
o The 'protected' field MUST be absent. o The 'protected' field MUST be absent.
o The plain text to be encrypted is the key from next layer down o The plain text to be encrypted is the key from next layer down
(usually the content layer). (usually the content layer).
o At a minimum, the 'unprotected' field MUST contain the 'alg' o At a minimum, the 'unprotected' field MUST contain the 'alg'
parameter and SHOULD contain a parameter identifying the parameter and SHOULD contain a parameter identifying the
asymmetric key. asymmetric key.
skipping to change at page 60, line 36 skipping to change at page 60, line 45
static-static key agreement is used, then some piece of unique static-static key agreement is used, then some piece of unique
data for the KDF is required to ensure that a different key is data for the KDF is required to ensure that a different key is
created for each message. created for each message.
When direct key agreement mode is used, there MUST be only one When direct key agreement mode is used, there MUST be only one
recipient in the message. This method creates the key directly and recipient in the message. This method creates the key directly and
that makes it difficult to mix with additional recipients. If that makes it difficult to mix with additional recipients. If
multiple recipients are needed, then the version with key wrap needs multiple recipients are needed, then the version with key wrap needs
to be used. to be used.
The COSE_Enveloped structure for the recipient is organized as The COSE_Encrypt structure for the recipient is organized as follows:
follows:
o At a minimum, headers MUST contain the 'alg' parameter and SHOULD o At a minimum, headers MUST contain the 'alg' parameter and SHOULD
contain a parameter identifying the recipient's asymmetric key. contain a parameter identifying the recipient's asymmetric key.
o The headers SHOULD identify the senders key for the static-static o The headers SHOULD identify the senders key for the static-static
versions and MUST contain the senders ephemeral key for the versions and MUST contain the senders ephemeral key for the
ephemeral-static versions. ephemeral-static versions.
12.4.1. ECDH 12.4.1. ECDH
The mathematics for Elliptic Curve Diffie-Hellman can be found in The mathematics for Elliptic Curve Diffie-Hellman can be found in
[RFC6090]. [RFC6090]. In this document the algorithm is extended to be used
with the two curves defined in [RFC7748].
ECDH is parameterized by the following: ECDH is parameterized by the following:
o Curve Type/Curve: The curve selected controls not only the size of o Curve Type/Curve: The curve selected controls not only the size of
the shared secret, but the mathematics for computing the shared the shared secret, but the mathematics for computing the shared
secret. The curve selected also controls how a point in the curve secret. The curve selected also controls how a point in the curve
is represented and what happens for the identity points on the is represented and what happens for the identity points on the
curve. In this specification, we allow for a number of different curve. In this specification, we allow for a number of different
curves to be used. A set of curves are defined in Table 20. curves to be used. A set of curves are defined in Table 22.
Since the only the math is changed by changing the curve, the Since the only the math is changed by changing the curve, the
curve is not fixed for any of the algorithm identifiers we define. curve is not fixed for any of the algorithm identifiers we define.
Instead, it is defined by the points used.
o Ephemeral-static or static-static: The key agreement process may o Ephemeral-static or static-static: The key agreement process may
be done using either a static or an ephemeral key for the sender's be done using either a static or an ephemeral key for the sender's
side. When using ephemeral keys, the sender MUST generate a new side. When using ephemeral keys, the sender MUST generate a new
ephemeral key for every key agreement operation. The ephemeral ephemeral key for every key agreement operation. The ephemeral
key is placed in the 'ephemeral key' parameter and MUST be present key is placed in the 'ephemeral key' parameter and MUST be present
for all algorithm identifiers that use ephemeral keys. When using for all algorithm identifiers that use ephemeral keys. When using
static keys, the sender MUST either generate a new random value or static keys, the sender MUST either generate a new random value or
otherwise create a unique value to be placed in either in the KDF otherwise create a unique value. For the KDF functions used, this
parameters or the context structure. For the KDF functions used, means either in the 'salt' parameter for HKDF (Table 13) or in the
this means either in the 'salt' parameter for HKDF (Table 12) or 'PartyU nonce' parameter for the context structure (Table 14) MUST
in the 'PartyU nonce' parameter for the context structure be present. (Both may be present if desired.) The value in the
(Table 13) MUST be present. (Both may be present if desired.) parameter MUST be unique for the pair of keys being used. It is
The value in the parameter MUST be unique for the pair of keys acceptable to use a global counter that is incremented for every
being used. It is acceptable to use a global counter that is static-static operation and use the resulting value. When using
incremented for every static-static operation and use the static keys, the static key should be identified to the recipient.
resulting value. When using static keys, the static key should be The static key can be identified either by providing the key
identified to the recipient. The static key can be identified ('static key') or by providing a key identifier for the static key
either by providing the key ('static key') or by providing a key ('static key id'). Both of these parameters are defined in
identifier for the static key ('static key id'). Both of these Table 19
parameters are defined in Table 18
o Key derivation algorithm: The result of an ECDH key agreement o Key derivation algorithm: The result of an ECDH key agreement
process does not provide a uniformly random secret. As such, it process does not provide a uniformly random secret. As such, it
needs to be run through a KDF in order to produce a usable key. needs to be run through a KDF in order to produce a usable key.
Processing the secret through a KDF also allows for the Processing the secret through a KDF also allows for the
introduction of both context material, how the key is going to be introduction of context material: how the key is going to be used,
used, and one time material in the event of a static-static key and one time material for static-static key agreement. All of the
agreement. algorithm define in this documeent use one of the HKDF algorithms
defined in Section 11.1 with the context structure defined in
Section 11.2.
o Key Wrap algorithm: No key wrap algorithm is used. This is o Key Wrap algorithm: No key wrap algorithm is used. This is
represented in Table 17 as 'none'. The key size for the context represented in Table 18 as 'none'. The key size for the context
structure is the content layer encryption algorithm size. structure is the content layer encryption algorithm size.
The set of direct ECDH algorithms defined in this document are found The set of direct ECDH algorithms defined in this document are found
in Table 17. in Table 18.
+-----------+-------+---------+------------+--------+---------------+ +-----------+-------+---------+------------+--------+---------------+
| name | value | KDF | Ephemeral- | Key | description | | name | value | KDF | Ephemeral- | Key | description |
| | | | Static | Wrap | | | | | | Static | Wrap | |
+-----------+-------+---------+------------+--------+---------------+ +-----------+-------+---------+------------+--------+---------------+
| ECDH-ES + | -25 | HKDF - | yes | none | ECDH ES w/ | | ECDH-ES + | -25 | HKDF - | yes | none | ECDH ES w/ |
| HKDF-256 | | SHA-256 | | | HKDF - | | HKDF-256 | | SHA-256 | | | HKDF - |
| | | | | | generate key | | | | | | | generate key |
| | | | | | directly | | | | | | | directly |
| | | | | | | | | | | | | |
skipping to change at page 62, line 25 skipping to change at page 62, line 35
| | | | | | | | | | | | | |
| ECDH-SS + | -27 | HKDF - | no | none | ECDH SS w/ | | ECDH-SS + | -27 | HKDF - | no | none | ECDH SS w/ |
| HKDF-256 | | SHA-256 | | | HKDF - | | HKDF-256 | | SHA-256 | | | HKDF - |
| | | | | | generate key | | | | | | | generate key |
| | | | | | directly | | | | | | | directly |
| | | | | | | | | | | | | |
| ECDH-SS + | -28 | HKDF - | no | none | ECDH SS w/ | | ECDH-SS + | -28 | HKDF - | no | none | ECDH SS w/ |
| HKDF-512 | | SHA-512 | | | HKDF - | | HKDF-512 | | SHA-512 | | | HKDF - |
| | | | | | generate key | | | | | | | generate key |
| | | | | | directly | | | | | | | directly |
| | | | | | |
| ECDH-ES + | -29 | HKDF - | yes | A128KW | ECDH ES w/ |
| A128KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 128 |
| | | | | | bit key |
| | | | | | |
| ECDH-ES + | -30 | HKDF - | yes | A192KW | ECDH ES w/ |
| A192KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 192 |
| | | | | | bit key |
| | | | | | |
| ECDH-ES + | -31 | HKDF - | yes | A256KW | ECDH ES w/ |
| A256KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 256 |
| | | | | | bit key |
| | | | | | |
| ECDH-SS + | -32 | HKDF - | no | A128KW | ECDH SS w/ |
| A128KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 128 |
| | | | | | bit key |
| | | | | | |
| ECDH-SS + | -33 | HKDF - | no | A192KW | ECDH SS w/ |
| A192KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 192 |
| | | | | | bit key |
| | | | | | |
| ECDH-SS + | -34 | HKDF - | no | A256KW | ECDH SS w/ |
| A256KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 256 |
| | | | | | bit key |
+-----------+-------+---------+------------+--------+---------------+ +-----------+-------+---------+------------+--------+---------------+
Table 17: ECDH Algorithm Values Table 18: ECDH Algorithm Values
+-----------+-------+----------+-----------+------------------------+ +-----------+-------+----------+-----------+------------------------+
| name | label | type | algorithm | description | | name | label | type | algorithm | description |
+-----------+-------+----------+-----------+------------------------+ +-----------+-------+----------+-----------+------------------------+
| ephemeral | -1 | COSE_Key | ECDH-ES | Ephemeral Public key | | ephemeral | -1 | COSE_Key | ECDH-ES | Ephemeral Public key |
| key | | | | for the sender | | key | | | | for the sender |
| | | | | | | | | | | |
| static | -2 | COSE_Key | ECDH-ES | Static Public key for | | static | -2 | COSE_Key | ECDH-ES | Static Public key for |
| key | | | | the sender | | key | | | | the sender |
| | | | | | | | | | | |
| static | -3 | bstr | ECDH-SS | Static Public key | | static | -3 | bstr | ECDH-SS | Static Public key |
| key id | | | | identifier for the | | key id | | | | identifier for the |
| | | | | sender | | | | | | sender |
+-----------+-------+----------+-----------+------------------------+ +-----------+-------+----------+-----------+------------------------+
Table 18: ECDH Algorithm Parameters Table 19: ECDH Algorithm Parameters
This document defines these algorithms to be used with the curves This document defines these algorithms to be used with the curves
P-256, P-384, P-521. Implementations MUST verify that the key type P-256, P-384, P-521, X25519, and X448. Implementations MUST verify
and curve are correct. Different curves are restricted to different that the key type and curve are correct. Different curves are
key types. Implementations MUST verify that the curve and algorithm restricted to different key types. Implementations MUST verify that
are appropriate for the entities involved. the curve and algorithm are appropriate for the entities involved.
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
o The 'kty' field MUST be present and it MUST be 'EC2'. o The 'kty' field MUST be present and it MUST be 'EC2' or 'OKP'.
o If the 'alg' field present, it MUST match the Key Agreement o If the 'alg' field present, it MUST match the Key Agreement
algorithm being used. algorithm being used.
o If the 'key_ops' field is present, it MUST include 'derive key' or o If the 'key_ops' field is present, it MUST include 'derive key' or
'derive bits' for the private key. 'derive bits' for the private key.
o If the 'key_ops' field is present, it MUST be empty for the public o If the 'key_ops' field is present, it MUST be empty for the public
key. key.
12.5. Key Agreement with KDF 12.5. Key Agreement with KDF
Key Agreement with Key Wrapping uses a randomly generated CEK. The Key Agreement with Key Wrapping uses a randomly generated CEK. The
CEK is then encrypted using a Key Wrapping algorithm and a key CEK is then encrypted using a Key Wrapping algorithm and a key
derived from the shared secret computed by the key agreement derived from the shared secret computed by the key agreement
algorithm. algorithm.
The COSE_Enveloped structure for the recipient is organized as The COSE_Encrypt structure for the recipient is organized as follows:
follows:
o The 'protected' field is fed into the KDF context structure. o The 'protected' field is fed into the KDF context structure.
o The plain text to be encrypted is the key from next layer down o The plain text to be encrypted is the key from next layer down
(usually the content layer). (usually the content layer).
o The 'alg' parameter MUST be present in the layer. o The 'alg' parameter MUST be present in the layer.
o A parameter identifying the recipient's key SHOULD be present. A o A parameter identifying the recipient's key SHOULD be present. A
parameter identifying the sender's key SHOULD be present. parameter identifying the sender's key SHOULD be present.
12.5.1. ECDH 12.5.1. ECDH
These algorithms are defined in Table 17. These algorithms are defined in Table 20.
ECDH with Key Agreement is parameterized by the same parameters as ECDH with Key Agreement is parameterized by the same parameters as
for ECDH Section 12.4.1 with the following modifications: for ECDH Section 12.4.1 with the following modifications:
o Key Wrap Algorithm: Any of the key wrap algorithms defined in o Key Wrap Algorithm: Any of the key wrap algorithms defined in
Section 12.2.1 are supported. The size of the key used for the Section 12.2.1 are supported. The size of the key used for the
key wrap algorithm is fed into the KDF function. The set of key wrap algorithm is fed into the KDF function. The set of
identifiers are found in Table 17. identifiers are found in Table 20.
+-----------+-------+---------+------------+--------+---------------+
| name | value | KDF | Ephemeral- | Key | description |
| | | | Static | Wrap | |
+-----------+-------+---------+------------+--------+---------------+
| ECDH-ES + | -29 | HKDF - | yes | A128KW | ECDH ES w/ |
| A128KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 128 |
| | | | | | bit key |
| | | | | | |
| ECDH-ES + | -30 | HKDF - | yes | A192KW | ECDH ES w/ |
| A192KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 192 |
| | | | | | bit key |
| | | | | | |
| ECDH-ES + | -31 | HKDF - | yes | A256KW | ECDH ES w/ |
| A256KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 256 |
| | | | | | bit key |
| | | | | | |
| ECDH-SS + | -32 | HKDF - | no | A128KW | ECDH SS w/ |
| A128KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 128 |
| | | | | | bit key |
| | | | | | |
| ECDH-SS + | -33 | HKDF - | no | A192KW | ECDH SS w/ |
| A192KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 192 |
| | | | | | bit key |
| | | | | | |
| ECDH-SS + | -34 | HKDF - | no | A256KW | ECDH SS w/ |
| A256KW | | SHA-256 | | | Concat KDF |
| | | | | | and AES Key |
| | | | | | wrap w/ 256 |
| | | | | | bit key |
+-----------+-------+---------+------------+--------+---------------+
Table 20: ECDH Algorithm Values
When using a COSE key for this algorithm, the following checks are When using a COSE key for this algorithm, the following checks are
made: made:
o The 'kty' field MUST be present and it MUST be 'EC2'. o The 'kty' field MUST be present and it MUST be 'EC2' or 'OKP'.
o If the 'alg' field present, it MUST match the Key Agreement o If the 'alg' field present, it MUST match the Key Agreement
algorithm being used. algorithm being used.
o If the 'key_ops' field is present, it MUST include 'derive key' or o If the 'key_ops' field is present, it MUST include 'derive key' or
'derive bits' for the private key. 'derive bits' for the private key.
o If the 'key_ops' field is present, it MUST be empty for the public o If the 'key_ops' field is present, it MUST be empty for the public
key. key.
13. Keys 13. Keys
The COSE_Key object defines a way to hold a single key object. It is The COSE_Key object defines a way to hold a single key object. It is
still required that the members of individual key types be defined. still required that the members of individual key types be defined.
This section of the document is where we define an initial set of This section of the document is where we define an initial set of
members for specific key types. members for specific key types.
For each of the key types, we define both public and private members. For each of the key types, we define both public and private members.
The public members are what is transmitted to others for their usage. The public members are what is transmitted to others for their usage.
We define private members mainly for the purpose of archival of keys Private members allow for the archival of keys by individuals.
by individuals. However, there are some circumstances in which However, there are some circumstances in which private keys may be
private keys may be distributed to entities in a protocol. Examples distributed to entities in a protocol. Examples include: entities
include: entities that have poor random number generation, that have poor random number generation, centralized key creation for
centralized key creation for multi-cast type operations, and multi-cast type operations, and protocols in which a shared secret is
protocols in which a shared secret is used as a bearer token for used as a bearer token for authorization purposes.
authorization purposes.
Key types are identified by the 'kty' member of the COSE_Key object. Key types are identified by the 'kty' member of the COSE_Key object.
In this document, we define four values for the member: In this document, we define four values for the member:
+-----------+-------+--------------------------------------------+ +-----------+-------+--------------------------------------------+
| name | value | description | | name | value | description |
+-----------+-------+--------------------------------------------+ +-----------+-------+--------------------------------------------+
| OPK | 1 | Octet Key Pair |
| | | |
| EC2 | 2 | Elliptic Curve Keys w/ X,Y Coordinate pair | | EC2 | 2 | Elliptic Curve Keys w/ X,Y Coordinate pair |
| | | | | | | |
| Symmetric | 4 | Symmetric Keys | | Symmetric | 4 | Symmetric Keys |
| | | | | | | |
| Reserved | 0 | This value is reserved | | Reserved | 0 | This value is reserved |
+-----------+-------+--------------------------------------------+ +-----------+-------+--------------------------------------------+
Table 19: Key Type Values Table 21: Key Type Values
13.1. Elliptic Curve Keys 13.1. Elliptic Curve Keys
Two different key structures could be defined for Elliptic Curve Two different key structures could be defined for Elliptic Curve
keys. One version uses both an x and a y coordinate, potentially keys. One version uses both an x and a y coordinate, potentially
with point compression. This is the traditional EC point with point compression ('EC2'). This is the traditional EC point
representation that is used in [RFC5480]. The other version uses representation that is used in [RFC5480]. The other version uses
only the x coordinate as the y coordinate is either to be recomputed only the x coordinate as the y coordinate is either to be recomputed
or not needed for the key agreement operation. Currently no or not needed for the key agreement operation ('OKP').
algorithms are defined using this key structure.
+-------+----------+-------+------------------------------------+ Applications MUST check that the curve and the key type are
| name | key type | value | description | consistent and reject a key if they are not.
+-------+----------+-------+------------------------------------+
| P-256 | EC2 | 1 | NIST P-256 also known as secp256r1 |
| | | | |
| P-384 | EC2 | 2 | NIST P-384 also known as secp384r1 |
| | | | |
| P-521 | EC2 | 3 | NIST P-521 also known as secp521r1 |
+-------+----------+-------+------------------------------------+
Table 20: EC Curves +---------+----------+-------+------------------------------------+
| name | key type | value | description |
+---------+----------+-------+------------------------------------+
| P-256 | EC2 | 1 | NIST P-256 also known as secp256r1 |
| | | | |
| P-384 | EC2 | 2 | NIST P-384 also known as secp384r1 |
| | | | |
| P-521 | EC2 | 3 | NIST P-521 also known as secp521r1 |
| | | | |
| X25519 | OKP | 4 | X25519 for use w/ ECDH only |
| | | | |
| X448 | OKP | 5 | X448 for use w/ ECDH only |
| | | | |
| Ed25519 | OKP | 6 | Ed25519 for use w/ EdDSA only |
| | | | |
| Ed448 | OKP | 7 | Ed448 for use w/ EdDSA only |
+---------+----------+-------+------------------------------------+
Table 22: EC Curves
13.1.1. Double Coordinate Curves 13.1.1. Double Coordinate Curves
The traditional way of sending EC curves has been to send either both The traditional way of sending EC curves has been to send either both
the x and y coordinates, or the x coordinate and a sign bit for the y the x and y coordinates, or the x coordinate and a sign bit for the y
coordinate. The latter encoding has not been recommended in the IETF coordinate. The latter encoding has not been recommended in the IETF
due to potential IPR issues. However, for operations in constrained due to potential IPR issues. However, for operations in constrained
environments, the ability to shrink a message by not sending the y environments, the ability to shrink a message by not sending the y
coordinate is potentially useful. coordinate is potentially useful.
For EC keys with both coordinates, the 'kty' member is set to 2 For EC keys with both coordinates, the 'kty' member is set to 2
(EC2). The key parameters defined in this section are summarized in (EC2). The key parameters defined in this section are summarized in
Table 21. The members that are defined for this key type are: Table 23. The members that are defined for this key type are:
crv contains an identifier of the curve to be used with the key. crv contains an identifier of the curve to be used with the key.
The curves defined in this document for this key type can be found The curves defined in this document for this key type can be found
in Table 20. Other curves may be registered in the future and in Table 22. Other curves may be registered in the future and
private curves can be used as well. private curves can be used as well.
x contains the x coordinate for the EC point. The integer is x contains the x coordinate for the EC point. The integer is
converted to an octet string as defined in [SEC1]. Leading zero converted to an octet string as defined in [SEC1]. Leading zero
octets MUST be preserved. octets MUST be preserved.
y contains either the sign bit or the value of y coordinate for the y contains either the sign bit or the value of y coordinate for the
EC point. When encoding the value y, the integer is converted to EC point. When encoding the value y, the integer is converted to
an octet string (as defined in [SEC1]) and encoded as a CBOR bstr. an octet string (as defined in [SEC1]) and encoded as a CBOR bstr.
Leading zero octets MUST be preserved. The compressed point Leading zero octets MUST be preserved. The compressed point
skipping to change at page 67, line 23 skipping to change at page 68, line 38
| | | | tstr | the COSE Curve Registry | | | | | tstr | the COSE Curve Registry |
| | | | | | | | | | | |
| x | 2 | -2 | bstr | X Coordinate | | x | 2 | -2 | bstr | X Coordinate |
| | | | | | | | | | | |
| y | 2 | -3 | bstr / | Y Coordinate | | y | 2 | -3 | bstr / | Y Coordinate |
| | | | bool | | | | | | bool | |
| | | | | | | | | | | |
| d | 2 | -4 | bstr | Private key | | d | 2 | -4 | bstr | Private key |
+------+-------+-------+---------+----------------------------------+ +------+-------+-------+---------+----------------------------------+
Table 21: EC Key Parameters Table 23: EC Key Parameters
13.2. Symmetric Keys 13.2. Octet Key Pair
A new key type is defined for Octet Key Pairs (OKP). Do not assume
that keys using this type are elliptic curves. This key type could
be used for other curve types (for example mathematics based on
hyper-elliptic surfaces).
The key parameters defined in this section are summarized in
Table 24. The members that are defined for this key type are:
crv contains an identifier of the curve to be used with the key.
The curves defined in this document for this key type can be found
in Table 22. Other curves may be registered in the future and
private curves can be used as well.
x contains the x coordinate for the EC point. The octet string
represents a little-endian encoding of x.
d contains the private key.
For public keys, it is REQUIRED that 'crv' and 'x' be present in the
structure. For private keys, it is REQUIRED that 'crv' and 'd' be
present in the structure. For private keys, it is RECOMMENDED that
'x' also be present, but it can be recomputed from the required
elements and omitting it saves on space.
+------+-------+-------+--------+-----------------------------------+
| name | key | value | type | description |
| | type | | | |
+------+-------+-------+--------+-----------------------------------+
| crv | 1 | -1 | int / | EC Curve identifier - Taken from |
| | | | tstr | the COSE General Registry |
| | | | | |
| x | 1 | -2 | bstr | X Coordinate |
| | | | | |
| d | 1 | -4 | bstr | Private key |
+------+-------+-------+--------+-----------------------------------+
Table 24: EC Key Parameters
13.3. Symmetric Keys
Occasionally it is required that a symmetric key be transported Occasionally it is required that a symmetric key be transported
between entities. This key structure allows for that to happen. between entities. This key structure allows for that to happen.
For symmetric keys, the 'kty' member is set to 3 (Symmetric). The For symmetric keys, the 'kty' member is set to 3 (Symmetric). The
member that is defined for this key type is: member that is defined for this key type is:
k contains the value of the key. k contains the value of the key.
This key structure contains only private key information, care must This key structure contains only private key information, care must
be taken that it is never transmitted accidentally. For public keys, be taken that it is never transmitted accidentally. For public keys,
there are no required fields. For private keys, it is REQUIRED that there are no required fields. For private keys, it is REQUIRED that
'k' be present in the structure. 'k' be present in the structure.
+------+----------+-------+------+-------------+ +------+----------+-------+------+-------------+
| name | key type | value | type | description | | name | key type | value | type | description |
+------+----------+-------+------+-------------+ +------+----------+-------+------+-------------+
| k | 4 | -1 | bstr | Key Value | | k | 4 | -1 | bstr | Key Value |
+------+----------+-------+------+-------------+ +------+----------+-------+------+-------------+
Table 22: Symmetric Key Parameters Table 25: Symmetric Key Parameters
14. CBOR Encoder Restrictions 14. CBOR Encoder Restrictions
There has been an attempt to limit the number of places where the There has been an attempt to limit the number of places where the
document needs to impose restrictions on how the CBOR Encoder needs document needs to impose restrictions on how the CBOR Encoder needs
to work. We have managed to narrow it down to the following to work. We have managed to narrow it down to the following
restrictions: restrictions:
o The restriction applies to the encoding the Sig_structure, the o The restriction applies to the encoding the Sig_structure, the
Enc_structure, and the MAC_structure. Enc_structure, and the MAC_structure.
skipping to change at page 69, line 46 skipping to change at page 72, line 11
* Minimum requirements for the S/MIME, which have been updated * Minimum requirements for the S/MIME, which have been updated
over time [RFC2633][RFC5751]. over time [RFC2633][RFC5751].
16. IANA Considerations 16. IANA Considerations
16.1. CBOR Tag assignment 16.1. CBOR Tag assignment
It is requested that IANA assign the following tags from the "Concise It is requested that IANA assign the following tags from the "Concise
Binary Object Representation (CBOR) Tags" registry. It is requested Binary Object Representation (CBOR) Tags" registry. It is requested
that the tags for COSE_Sign1, COSE_Encrypted and COSE_Mac0 be that the tags for COSE_Sign1, COSE_Encrypt1 and COSE_Mac0 be assigned
assigned in the 1 to 23 value range (i.e. one byte long when in the 1 to 23 value range (i.e. one byte long when encoded). It is
encoded). It is requested that the rest of the tags be assigned in requested that the rest of the tags be assigned in the 24 to 255
the 24 to 255 value range (i.e. two bytes long when encoded). value range (i.e. two bytes long when encoded).
The tags to be assigned are in table Table 1. The tags to be assigned are in table Table 1.
16.2. COSE Header Parameter Registry 16.2. COSE Header Parameter Registry
It is requested that IANA create a new registry entitled "COSE Header It is requested that IANA create a new registry entitled "COSE Header
Parameters". The registry is to be created as Expert Review Parameters". The registry is to be created as Expert Review
Required. Expert review guidelines are provided in Section 16.10 Required. Expert review guidelines are provided in Section 16.10
The columns of the registry are: The columns of the registry are:
skipping to change at page 70, line 24 skipping to change at page 72, line 37
the registration entry. The value is not used in the protocol. the registration entry. The value is not used in the protocol.
Names are to be unique in the table. Names are to be unique in the table.
label This is the value used for the label. The label can be either label This is the value used for the label. The label can be either
an integer or a string. Registration in the table is based on the an integer or a string. Registration in the table is based on the
value of the label requested. Integer values between 1 and 255 value of the label requested. Integer values between 1 and 255
and strings of length 1 are designated as Standards Track Document and strings of length 1 are designated as Standards Track Document
required. Integer values from 256 to 65535 and strings of length required. Integer values from 256 to 65535 and strings of length
2 are designated as Specification Required. Integer values of 2 are designated as Specification Required. Integer values of
greater than 65535 and strings of length greater than 2 are greater than 65535 and strings of length greater than 2 are
designated as first come, first served. Integer values in the designated as expert review. Integer values in the range -1 to
range -1 to -65536 are delegated to the "COSE Header Algorithm -65536 are delegated to the "COSE Header Algorithm Label"
Label" registry. Integer values beyond -65536 are marked as registry. Integer values beyond -65536 are marked as private use.
private use.
value This contains the CBOR type for the value portion of the value This contains the CBOR type for the value portion of the
label. label.
value registry This contains a pointer to the registry used to value registry This contains a pointer to the registry used to
contain values where the set is limited. contain values where the set is limited.
description This contains a brief description of the header field. description This contains a brief description of the header field.
specification This contains a pointer to the specification defining specification This contains a pointer to the specification defining
skipping to change at page 71, line 27 skipping to change at page 73, line 41
label. label.
value registry This contains a pointer to the registry used to value registry This contains a pointer to the registry used to
contain values where the set is limited. contain values where the set is limited.
description This contains a brief description of the header field. description This contains a brief description of the header field.
specification This contains a pointer to the specification defining specification This contains a pointer to the specification defining
the header field (where public). the header field (where public).
The initial contents of the registry can be found in Table 12, The initial contents of the registry can be found in Table 13,
Table 13, and Table 18. The specification column for all rows in Table 14, and Table 19. The specification column for all rows in
that table should be this document. that table should be this document.
16.4. COSE Algorithm Registry 16.4. COSE Algorithm Registry
It is requested that IANA create a new registry entitled "COSE It is requested that IANA create a new registry entitled "COSE
Algorithm Registry". The registry is to be created as Expert Review Algorithm Registry". The registry is to be created as Expert Review
Required. Expert review guidelines are provided in Section 16.10 Required. Expert review guidelines are provided in Section 16.10
The columns of the registry are: The columns of the registry are:
value The value to be used to identify this algorithm. Algorithm value The value to be used to identify this algorithm. Algorithm
values MUST be unique. The value can be a positive integer, a values MUST be unique. The value can be a positive integer, a
negative integer or a string. Integer values between -256 and 255 negative integer or a string. Integer values between -256 and 255
and strings of length 1 are designated as Standards Track Document and strings of length 1 are designated as Standards Track Document
required. Integer values from -65536 to 65535 and strings of required. Integer values from -65536 to 65535 and strings of
length 2 are designated as Specification Required. Integer values length 2 are designated as Specification Required. Integer values
of greater than 65535 and strings of length greater than 2 are of greater than 65535 and strings of length greater than 2 are
designated as first come, first served. Integer values beyond designated as expert review. Integer values beyond -65536 are
-65536 are marked as private use. marked as private use.
description A short description of the algorithm. description A short description of the algorithm.
specification A document where the algorithm is defined (if publicly specification A document where the algorithm is defined (if publicly
available). available).
The initial contents of the registry can be found in Table 9, The initial contents of the registry can be found in Table 10,
Table 8, Table 10, Table 5, Table 6, Table 7, Table 14, Table 15, Table 9, Table 11, Table 5, Table 7, Table 8, Table 15, Table 16,
Table 16, and Table 17. The specification column for all rows in Table 17, and Table 18. The specification column for all rows in
that table should be this document. that table should be this document.
NOTE: The assignment of algorithm identifiers in this document was NOTE: The assignment of algorithm identifiers in this document was
done so that positive numbers were used for the first level objects done so that positive numbers were used for the first level objects
(COSE_Sign, COSE_Sign1, COSE_Enveloped, COSE_Encrypted, COSE_Mac and (COSE_Sign, COSE_Sign1, COSE_Encrypt, COSE_Encrypt1, COSE_Mac and
COSE_Mac0). Negative numbers were used for second level objects COSE_Mac0). Negative numbers were used for second level objects
(COSE_Signature and COSE_recipient). Expert reviewers should (COSE_Signature and COSE_recipient). Expert reviewers should
consider this practice, but are not expected to be restricted by this consider this practice, but are not expected to be restricted by this
precedent. precedent.
16.5. COSE Key Common Parameter Registry 16.5. COSE Key Common Parameter Registry
It is requested that IANA create a new registry entitled "COSE Key It is requested that IANA create a new registry entitled "COSE Key
Common Parameter" Registry. The registry is to be created as Expert Common Parameter" Registry. The registry is to be created as Expert
Review Required. Expert review guidelines are provided in Review Required. Expert review guidelines are provided in
skipping to change at page 72, line 37 skipping to change at page 74, line 52
name This is a descriptive name that enables easier reference to the name This is a descriptive name that enables easier reference to the
item. It is not used in the encoding. item. It is not used in the encoding.
label The value to be used to identify this algorithm. Key map label The value to be used to identify this algorithm. Key map
labels MUST be unique. The label can be a positive integer, a labels MUST be unique. The label can be a positive integer, a
negative integer or a string. Integer values between 0 and 255 negative integer or a string. Integer values between 0 and 255
and strings of length 1 are designated as Standards Track Document and strings of length 1 are designated as Standards Track Document
required. Integer values from 256 to 65535 and strings of length required. Integer values from 256 to 65535 and strings of length
2 are designated as Specification Required. Integer values of 2 are designated as Specification Required. Integer values of
greater than 65535 and strings of length greater than 2 are greater than 65535 and strings of length greater than 2 are
designated as first come, first served. Integer values in the designated as expert review. Integer values in the range -1 to
range -1 to -65536 are used for key parameters specific to a -65536 are used for key parameters specific to a single algorithm
single algorithm delegated to the "COSE Key Type Parameter Label" delegated to the "COSE Key Type Parameter Label" registry.
registry. Integer values beyond -65536 are marked as private use. Integer values beyond -65536 are marked as private use.
CBOR Type This field contains the CBOR type for the field CBOR Type This field contains the CBOR type for the field
registry This field denotes the registry that values come from, if registry This field denotes the registry that values come from, if
one exists. one exists.
description This field contains a brief description for the field description This field contains a brief description for the field
specification This contains a pointer to the public specification specification This contains a pointer to the public specification
for the field if one exists for the field if one exists
skipping to change at page 73, line 35 skipping to change at page 75, line 48
range of values is from -256 to -1. Labels are expected to be range of values is from -256 to -1. Labels are expected to be
reused for different keys. reused for different keys.
CBOR type This field contains the CBOR type for the field CBOR type This field contains the CBOR type for the field
description This field contains a brief description for the field description This field contains a brief description for the field
specification This contains a pointer to the public specification specification This contains a pointer to the public specification
for the field if one exists for the field if one exists
This registry will be initially populated by the values in Table 21 This registry will be initially populated by the values in Table 23
and Table 22. The specification column for all of these entries will and Table 25. The specification column for all of these entries will
be this document. be this document.
16.7. COSE Elliptic Curve Registry 16.7. COSE Elliptic Curve Registry
It is requested that IANA create a new registry "COSE Elliptic Curve It is requested that IANA create a new registry "COSE Elliptic Curve
Parameters". The registry is to be created as Expert Review Parameters". The registry is to be created as Expert Review
Required. Expert review guidelines are provided in Section 16.10 Required. Expert review guidelines are provided in Section 16.10
The columns of the table are: The columns of the table are:
name This is a descriptive name that enables easier reference to the name This is a descriptive name that enables easier reference to the
item. It is not used in the encoding. item. It is not used in the encoding.
value This is the value used to identify the curve. These values value This is the value used to identify the curve. These values
MUST be unique. The integer values from -256 to 255 are MUST be unique. The integer values from -256 to 255 are
designated as Standards Track Document Required. The integer designated as Standards Track Document Required. The integer
values from 256 to 65535 and -65536 to -257 are designated as values from 256 to 65535 and -65536 to -257 are designated as
Specification Required. Integer values over 65535 are designated Specification Required. Integer values over 65535 are designated
as first come, first served. Integer values less than -65536 are as expert review. Integer values less than -65536 are marked as
marked as private use. private use.
key type This designates the key type(s) that can be used with this key type This designates the key type(s) that can be used with this
curve. curve.
description This field contains a brief description of the curve. description This field contains a brief description of the curve.
specification This contains a pointer to the public specification specification This contains a pointer to the public specification
for the curve if one exists. for the curve if one exists.
This registry will be initially populated by the values in Table 19. This registry will be initially populated by the values in Table 21.
The specification column for all of these entries will be this The specification column for all of these entries will be this
document. document.
16.8. Media Type Registrations 16.8. Media Type Registrations
16.8.1. COSE Security Message 16.8.1. COSE Security Message
This section registers the "application/cose" media type in the This section registers the "application/cose" media type in the
"Media Types" registry. These media types are used to indicate that "Media Types" registry. These media types are used to indicate that
the content is a COSE_MSG. the content is a COSE_MSG.
skipping to change at page 77, line 22 skipping to change at page 80, line 5
Change Controller: IESG Change Controller: IESG
Provisional registration? No Provisional registration? No
16.9. CoAP Content Format Registrations 16.9. CoAP Content Format Registrations
This section registers a set of content formats for CoAP. ID This section registers a set of content formats for CoAP. ID
assignment in the 24-255 range is requested. assignment in the 24-255 range is requested.
+----------------------------------+----------+-------+-------------+ +---------------------------------+----------+-------+--------------+
| Media Type | Encoding | ID | Reference | | Media Type | Encoding | ID | Reference |
+----------------------------------+----------+-------+-------------+ +---------------------------------+----------+-------+--------------+
| application/cose; cose-type | | TBD10 | [This | | application/cose; cose-type | | TBD10 | [This |
| ="cose-sign" | | | Document] | | ="cose-sign" | | | Document] |
| | | | | | | | | |
| application/cose; cose-type | | TBD11 | [This | | application/cose; cose-type | | TBD11 | [This |
| ="cose-sign1" | | | Document] | | ="cose-sign1" | | | Document] |
| | | | | | | | | |
| application/cose; cose-type | | TBD12 | [This | | application/cose; cose-type | | TBD12 | [This |
| ="cose-enveloped" | | | Document] | | ="cose-encrypt" | | | Document] |
| | | | | | | | | |
| application/cose; cose-type | | TBD13 | [This | | application/cose; cose-type | | TBD13 | [This |
| ="cose-encrypted" | | | Document] | | ="cose-encrypt1" | | | Document] |
| | | | | | | | | |
| application/cose; cose-type | | TBD14 | [This | | application/cose; cose-type | | TBD14 | [This |
| ="cose-mac" | | | Document] | | ="cose-mac" | | | Document] |
| | | | | | | | | |
| application/cose; cose-type | | TBD15 | [This | | application/cose; cose-type | | TBD15 | [This |
| ="cose-mac0" | | | Document] | | ="cose-mac0" | | | Document] |
| | | | | | | | | |
| application/cose-key | | TBD16 | [This | | application/cose-key | | TBD16 | [This |
| | | | Document] | | | | | Document] |
| | | | | | | | | |
| application/cose-key-set | | TBD17 | [This | | application/cose-key-set | | TBD17 | [This |
| | | | Document | | | | | Document |
+----------------------------------+----------+-------+-------------+ +---------------------------------+----------+-------+--------------+
Table 23 Table 26
16.10. Expert Review Instructions 16.10. Expert Review Instructions
All of the IANA registries established in this document are defined All of the IANA registries established in this document are defined
as expert review. This section gives some general guidelines for as expert review. This section gives some general guidelines for
what the experts should be looking for, but they are being designated what the experts should be looking for, but they are being designated
as experts for a reason so they should be given substantial latitude. as experts for a reason so they should be given substantial latitude.
Expert reviewers should take into consideration the following points: Expert reviewers should take into consideration the following points:
skipping to change at page 79, line 5 skipping to change at page 81, line 33
o When algorithms are registered, vanity registrations should be o When algorithms are registered, vanity registrations should be
discouraged. One way to do this is to require applications to discouraged. One way to do this is to require applications to
provide additional documentation on security analysis of provide additional documentation on security analysis of
algorithms. Another thing that should be considered is to request algorithms. Another thing that should be considered is to request
for an opinion on the algorithm from the Cryptographic Forum for an opinion on the algorithm from the Cryptographic Forum
Research Group. Algorithms which do not meet the security Research Group. Algorithms which do not meet the security
requirements of the community and the messages structures should requirements of the community and the messages structures should
not be registered. not be registered.
17. Security Considerations 17. Implementation Status
This section records the status of known implementations of the
protocol defined by this specification at the time of posting of this
Internet-Draft, and is based on a proposal described in [RFC6982].
The description of implementations in this section is intended to
assist the IETF in its decision processes in progressing drafts to
RFCs. Please note that the listing of any individual implementation
here does not imply endorsement by the IETF. Furthermore, no effort
has been spent to verify the information presented here that was
supplied by IETF contributors. This is not intended as, and must not
be construed to be, a catalog of available implementations or their
features. Readers are advised to note that other implementations may
exist.
According to [RFC6982], "this will allow reviewers and working groups
to assign due consideration to documents that have the benefit of
running code, which may serve as evidence of valuable experimentation
and feedback that have made the implemented protocols more mature.
It is up to the individual working groups to use this information as
they see fit".
17.1. Author's Versions
There are three different implementations that have been created by
the author of the document both to create the examples that are
included in the document and to validate the structures and
methodology used in the design of COSE.
Implemenation Location: https://github.com/cose-wg
Primary Maintainer: Jim Schaad
Languages: There are three different languages that are current
supported: JAVA, C# and C.
Cryptography: The JAVA and C# libraries use Bouncy Castle to
provide the required cryptography. The C version uses OPENSSL
Version 1.0 for the cryptography.
Coverage: The libraries currently do not have full support for
counter signatures of either variety. They do have support to
allow for implicit algorithm support as they allow for the
application to set attributes which are not to be sent in the
message.
Testing: All of the examples in the example library are generated
by the C# library and then validated using the JAVA and C
libraries. All three libraries have tests to allow for the
creating of a the same messages that are in the example library
followed by validating them. These are not compared against the
example library. The JAVA and C# libraries have unit testing
included. Not all of the MUST statements in the document have
been implemented as part of the libraries. One such statement is
the requirement that unique labels be present.
Licensing: Revised BSD License
17.2. COSE Testing Library
Implemenation Location: https://github.com/cose-wg/Examples
Primary Maintainer: Jim Schaad
Description: A set of tests for the COSE library is provided as
part of the implementation effort. Both success and fail tests
has been provided. All of the examples in this document are are
part of this example set.
Coverage: The attempt has been to have test cases for every
message type and algorithm in the document. Current examples
dealing with counter signatures, EdDSA and ECDH with Curve24459
and Goldilocks are missing.
Licensing: Public Domain
18. Security Considerations
There are a number of security considerations that need to be taken There are a number of security considerations that need to be taken
into account by implementers of this specification. The security into account by implementers of this specification. The security
considerations that are specific to an individual algorithm are considerations that are specific to an individual algorithm are
placed next to the description of the algorithm. While some placed next to the description of the algorithm. While some
considerations have been highlighted here, additional considerations considerations have been highlighted here, additional considerations
may be found in the documents listed in the references. may be found in the documents listed in the references.
Implementations need to protect the private key for any individuals. Implementations need to protect the private key for any individuals.
There are some cases in this document that need to be highlighted on There are some cases in this document that need to be highlighted on
skipping to change at page 80, line 38 skipping to change at page 84, line 49
analysis of encrypted messages based on the length of the message. analysis of encrypted messages based on the length of the message.
This specification does not provide for a uniform method of providing This specification does not provide for a uniform method of providing
padding as part of the message structure. An observer can padding as part of the message structure. An observer can
distinguish between two different strings (for example 'YES' and distinguish between two different strings (for example 'YES' and
'NO') based on length for all of the content encryption algorithms 'NO') based on length for all of the content encryption algorithms
that are defined in this document. This means that it is up to that are defined in this document. This means that it is up to
applications to document how content padding is to be done in order applications to document how content padding is to be done in order
to prevent or discourage such analysis. (For example the strings to prevent or discourage such analysis. (For example the strings
could be defined as 'YES' and 'NO '.) could be defined as 'YES' and 'NO '.)
18. Acknowledgments Timing Issues - TBD
This document is a product of the COSE working group of the IETF.
19. References 19. References
19.1. Normative References 19.1. Normative References
[AES-GCM] Dworkin, M., "NIST Special Publication 800-38D: [AES-GCM] Dworkin, M., "NIST Special Publication 800-38D:
Recommendation for Block Cipher Modes of Operation: Recommendation for Block Cipher Modes of Operation:
Galois/Counter Mode (GCM) and GMAC.", Nov 2007. Galois/Counter Mode (GCM) and GMAC.", Nov 2007.
[DSS] U.S. National Institute of Standards and Technology, [DSS] U.S. National Institute of Standards and Technology,
skipping to change at page 82, line 8 skipping to change at page 86, line 17
<http://www.rfc-editor.org/info/rfc7539>. <http://www.rfc-editor.org/info/rfc7539>.
[SEC1] Standards for Efficient Cryptography Group, "SEC 1: [SEC1] Standards for Efficient Cryptography Group, "SEC 1:
Elliptic Curve Cryptography", May 2009. Elliptic Curve Cryptography", May 2009.
19.2. Informative References 19.2. Informative References
[I-D.greevenbosch-appsawg-cbor-cddl] [I-D.greevenbosch-appsawg-cbor-cddl]
Vigano, C. and H. Birkholz, "CBOR data definition language Vigano, C. and H. Birkholz, "CBOR data definition language
(CDDL): a notational convention to express CBOR data (CDDL): a notational convention to express CBOR data
structures", draft-greevenbosch-appsawg-cbor-cddl-07 (work structures", draft-greevenbosch-appsawg-cbor-cddl-08 (work
in progress), October 2015. in progress), March 2016.
[I-D.irtf-cfrg-eddsa]
Josefsson, S. and I. Liusvaara, "Edwards-curve Digital
Signature Algorithm (EdDSA)", draft-irtf-cfrg-eddsa-05
(work in progress), March 2016.
[PVSig] Brown, D. and D. Johnson, "Formal Security Proofs for a [PVSig] Brown, D. and D. Johnson, "Formal Security Proofs for a
Signature Scheme with Partial Message Recover", February Signature Scheme with Partial Message Recover", February
2000. 2000.
[RFC2633] Ramsdell, B., Ed., "S/MIME Version 3 Message [RFC2633] Ramsdell, B., Ed., "S/MIME Version 3 Message
Specification", RFC 2633, DOI 10.17487/RFC2633, June 1999, Specification", RFC 2633, DOI 10.17487/RFC2633, June 1999,
<http://www.rfc-editor.org/info/rfc2633>. <http://www.rfc-editor.org/info/rfc2633>.
[RFC2898] Kaliski, B., "PKCS #5: Password-Based Cryptography [RFC2898] Kaliski, B., "PKCS #5: Password-Based Cryptography
skipping to change at page 83, line 35 skipping to change at page 87, line 48
[RFC6151] Turner, S. and L. Chen, "Updated Security Considerations [RFC6151] Turner, S. and L. Chen, "Updated Security Considerations
for the MD5 Message-Digest and the HMAC-MD5 Algorithms", for the MD5 Message-Digest and the HMAC-MD5 Algorithms",
RFC 6151, DOI 10.17487/RFC6151, March 2011, RFC 6151, DOI 10.17487/RFC6151, March 2011,
<http://www.rfc-editor.org/info/rfc6151>. <http://www.rfc-editor.org/info/rfc6151>.
[RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature [RFC6979] Pornin, T., "Deterministic Usage of the Digital Signature
Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature
Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August Algorithm (ECDSA)", RFC 6979, DOI 10.17487/RFC6979, August
2013, <http://www.rfc-editor.org/info/rfc6979>. 2013, <http://www.rfc-editor.org/info/rfc6979>.
[RFC6982] Sheffer, Y. and A. Farrel, "Improving Awareness of Running
Code: The Implementation Status Section", RFC 6982,
DOI 10.17487/RFC6982, July 2013,
<http://www.rfc-editor.org/info/rfc6982>.
[RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March
2014, <http://www.rfc-editor.org/info/rfc7159>. 2014, <http://www.rfc-editor.org/info/rfc7159>.
[RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained
Application Protocol (CoAP)", RFC 7252, Application Protocol (CoAP)", RFC 7252,
DOI 10.17487/RFC7252, June 2014, DOI 10.17487/RFC7252, June 2014,
<http://www.rfc-editor.org/info/rfc7252>. <http://www.rfc-editor.org/info/rfc7252>.
[RFC7515] Jones, M., Bradley, J., and N. Sakimura, "JSON Web [RFC7515] Jones, M., Bradley, J., and N. Sakimura, "JSON Web
skipping to change at page 84, line 13 skipping to change at page 88, line 30
<http://www.rfc-editor.org/info/rfc7516>. <http://www.rfc-editor.org/info/rfc7516>.
[RFC7517] Jones, M., "JSON Web Key (JWK)", RFC 7517, [RFC7517] Jones, M., "JSON Web Key (JWK)", RFC 7517,
DOI 10.17487/RFC7517, May 2015, DOI 10.17487/RFC7517, May 2015,
<http://www.rfc-editor.org/info/rfc7517>. <http://www.rfc-editor.org/info/rfc7517>.
[RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518, [RFC7518] Jones, M., "JSON Web Algorithms (JWA)", RFC 7518,
DOI 10.17487/RFC7518, May 2015, DOI 10.17487/RFC7518, May 2015,
<http://www.rfc-editor.org/info/rfc7518>. <http://www.rfc-editor.org/info/rfc7518>.
[RFC7748] Langley, A., Hamburg, M., and S. Turner, "Elliptic Curves
for Security", RFC 7748, DOI 10.17487/RFC7748, January
2016, <http://www.rfc-editor.org/info/rfc7748>.
[SP800-56A] [SP800-56A]
Barker, E., Chen, L., Roginsky, A., and M. Smid, "NIST Barker, E., Chen, L., Roginsky, A., and M. Smid, "NIST
Special Publication 800-56A: Recommendation for Pair-Wise Special Publication 800-56A: Recommendation for Pair-Wise
Key Establishment Schemes Using Discrete Logarithm Key Establishment Schemes Using Discrete Logarithm
Cryptography", May 2013. Cryptography", May 2013.
Appendix A. Making Mandatory Algorithm Header Optional Appendix A. Making Mandatory Algorithm Header Optional
There has been a minority of the working group who have expressed a There has been a portion of the working group who have expressed a
strong desire to relax the rule that the algorithm identifier be strong desire to relax the rule that the algorithm identifier be
required to appear in each level of a COSE mesage. There are two required to appear in each level of a COSE message. There are two
basic reasons that have been advanced to support this position. basic reasons that have been advanced to support this position.
First, the resulting message will be smaller if the algorithm First, the resulting message will be smaller if the algorithm
identifier is omitted from the most common messages in a CoAP identifier is omitted from the most common messages in a CoAP
environment. Second, there is a potential bug that will arise if environment. Second, there is a potential bug that will arise if
full checking is not done correctly between the different places that full checking is not done correctly between the different places that
an algorithm identifier could be placed. (The message itself, an an algorithm identifier could be placed. (The message itself, an
application statement, the key structure that the sender possesses application statement, the key structure that the sender possesses
and the key structure the recipient possesses.) and the key structure the recipient possesses.)
This appendix lays out how such a change can be made and the details This appendix lays out how such a change can be made and the details
that an application needs to specify in order to use this option. that an application needs to specify in order to use this option.
Two different sets of details are specified: Those needed to omit an Two different sets of details are specified: Those needed to omit an
algorithm identifier and those needed to use a variant on the counter algorithm identifier and those needed to use a variant on the counter
signature attribute which contains no attributes about itself. signature attribute which contains no attributes about itself.
A.1. Algorithm Identification A.1. Algorithm Identification
In this section are laid out three sets of recommendations. The In this section are laid out three sets of recommendations. The
first set of recommendations apply to having an implicit algorithm first set of recommendations apply to having an implicit algorithm
skipping to change at page 85, line 9 skipping to change at page 89, line 27
recommendations apply to having implicit algorithms for multiple COSE recommendations apply to having implicit algorithms for multiple COSE
message constructs. message constructs.
RFC 2119 language is deliberately not used here, this specification RFC 2119 language is deliberately not used here, this specification
can provide recommendations, but it cannot enforce them. can provide recommendations, but it cannot enforce them.
This set of recommendations applies to the case where an application This set of recommendations applies to the case where an application
is distributing a fixed algorithm along with the key information for is distributing a fixed algorithm along with the key information for
use in a single COSE message object. This normally applies to the use in a single COSE message object. This normally applies to the
smallest of the COSE messages, specifically COSE_Sign1, COSE_Mac0 and smallest of the COSE messages, specifically COSE_Sign1, COSE_Mac0 and
COSE_Encrypted, but could apply to the other structures as well. COSE_Encrypt1, but could apply to the other structures as well.
The following items should be taken into account: The following items should be taken into account:
o Applications need to list the set of COSE structures that implicit o Applications need to list the set of COSE structures that implicit
algorithms are to be used in. Applications need to require that algorithms are to be used in. Applications need to require that
the receipt of an explicit algorithm identifier in one of these the receipt of an explicit algorithm identifier in one of these
structures will lead to the message being rejected. This structures will lead to the message being rejected. This
requirement is stated so that there will never be a case where requirement is stated so that there will never be a case where
there is any ambiguity about the question of which algorithm there is any ambiguity about the question of which algorithm
should be used, the implicit or the explicit one. This applies should be used, the implicit or the explicit one. This applies
even if the transported algorithm is a protected attribute. This even if the transported algorithm identifier is a protected
applies even if the transported algorithm is the same as the attribute. This applies even if the transported algorithm is the
implicit algorithm. same as the implicit algorithm.
o Applications need to define the set of information that is to be o Applications need to define the set of information that is to be
considered to be part of a context when omitting algorithm considered to be part of a context when omitting algorithm
identifiers. At a minimum this would be the key identifier, the identifiers. At a minimum this would be the key identifier (if
key, the algorithm and the COSE structures it can be used for. needed), the key, the algorithm and the COSE structure it can be
Applications should restrict the use of a single key to a single used for. Applications should restrict the use of a single key to
algorithm. As noted for some of the algorithms in this document, a single algorithm. As noted for some of the algorithms in this
the use of the same key in different related algorithms can lead document, the use of the same key in different related algorithms
to leakage of information about the key, leakage about the data or can lead to leakage of information about the key, leakage about
the ability to perform forgeries. the data or the ability to perform forgeries.
o In many cases applications which make the algorithm identifier o In many cases applications which make the algorithm identifier
will also want to make the context identifier implicit for the implicit will also want to make the context identifier implicit
same reason. That is omitting the context identifier will for the same reason. That is omitting the context identifier will
decrease the message size (potentially significantly depending on decrease the message size (potentially significantly depending on
the length of the identifier). Applications that do this will the length of the identifier). Applications that do this will
need to describe the circumstances where the context identifier is need to describe the circumstances where the context identifier is
to be omitted and how the context identifier is to be inferred in to be omitted and how the context identifier is to be inferred in
these cases. (Exhaustive search would normally not be considered these cases. (Exhaustive search over all of the keys would
to be acceptable.) An example of how this can be done is to tie normally not be considered to be acceptable.) An example of how
the context to a transaction identifier. Both would be sent on this can be done is to tie the context to a transaction
the original message, but only the transaction identifier would identifier. Both would be sent on the original message, but only
need to be sent after that point as the context is tied into the the transaction identifier would need to be sent after that point
transaction identifier. Another way would be to associate a as the context is tied into the transaction identifier. Another
context with a network address. All messages coming from a single way would be to associate a context with a network address. All
network address can be assumed to be associated with a specific messages coming from a single network address can be assumed to be
context. (In this case the address would probably be distributed associated with a specific context. (In this case the address
as part of the context.) would normally be distributed as part of the context.)
o Applications cannot rely on key identifiers being unique unless o Applications cannot rely on key identifiers being unique unless
they take significant efforts to ensure that they are computed in they take significant efforts to ensure that they are computed in
such a way as to create this guarantee. Even when an application such a way as to create this guarantee. Even when an application
does this, the uniqueness might be violated if the application is does this, the uniqueness might be violated if the application is
run in different contexts (i.e. with a different security run in different contexts (i.e. with a different context provider)
coordinator) or if the system the application runs on combines or if the system combines the security contexts from different
security contexts from different applications together into a applications together into a single store.
single store.
o Applications should continue the practice of protecting the o Applications should continue the practice of protecting the
algorithm identifier. Since this is not done by placing it in the algorithm identifier. Since this is not done by placing it in the
protected attributes field, applications should define an protected attributes field, applications should define an
application specific external data structure which includes this application specific external data structure which includes this
value. This external data field can be used as such for content value. This external data field can be used as such for content
encryption, MAC and signature algorithms. It can be used in the encryption, MAC and signature algorithms. It can be used in the
SuppPrivInfo field for those algorithms which use a KDF function SuppPrivInfo field for those algorithms which use a KDF function
to derive a key value. Applications may also want to protect to derive a key value. Applications may also want to protect
other information that is part of the context structure as well. other information that is part of the context structure as well.
It should be noted that those fields, such as the key or a base IV It should be noted that those fields, such as the key or a base
are already protected by virtue of being used in the cryptogrpahic IV, protected by virtue of being used in the cryptogrpahic
computation and do not need to be included in the external data computation and do not need to be included in the external data
field. field.
The second case is having multiple implicit algorithm identifiers The second case is having multiple implicit algorithm identifiers
specified for a multiple layer COSE message. An example of how this specified for a multiple layer COSE message. An example of how this
would work is that the encryption context that an application would work is the encryption context that an application specifies
specifies contains a content encryption algorithm, a key wrap contains a content encryption algorithm, a key wrap algorithm, a key
algorithm, a key identifier, and a shared secret. The sender would identifier, and a shared secret. The sender omits sending the
then omit sending the algorithm identifier at both the content layer algorithm identifier for both the content layer and the recipient
and the recipient layer leaving only the key identifier in situations layer leaving only the key identifier. The receiver then uses the
where it could not be implied. key identifier to get the implicit algorithm identifiers.
The following additional items need to be taken into consideration: The following additional items need to be taken into consideration:
o Applications that want to support this will need to define a o Applications that want to support this will need to define a
structure that allows for, and clearly identifies, both the COSE structure that allows for, and clearly identifies, both the COSE
structure to be used with a given key and the structure and structure to be used with a given key and the structure and
algorithm to be used for the secondary layer. The key for the algorithm to be used for the secondary layer. The key for the
secondary layer is computed normally in the recipient layer. secondary layer is computed per normal from the recipient layer.
o
The third case is having multiple implicit algorithm identifiers, but The third case is having multiple implicit algorithm identifiers, but
targeted at potentially unrelated layers or different COSE messages. targeted at potentially unrelated layers or different COSE messages.
There are a number of different scenarios where this might be There are a number of different scenarios where this might be
applicable. Some of these scenarios are: applicable. Some of these scenarios are:
o Two contexts are distributed as a pair. Each of the contexts is o Two contexts are distributed as a pair. Each of the contexts is
for use with a COSE_Encrypt message. Each context will consist of for use with a COSE_Encrypt message. Each context will consist of
distinct secret keys and IVs and potentially even different distinct secret keys and IVs and potentially even different
algorithms. One context is for sending messages from party A to algorithms. One context is for sending messages from party A to
skipping to change at page 87, line 30 skipping to change at page 91, line 43
the message came from an individual without being able to decrypt the message came from an individual without being able to decrypt
the message and see the content. the message and see the content.
o Two contexts are distributed as a pair. The first context o Two contexts are distributed as a pair. The first context
contains a key for dealing with MAC messages, the second context contains a key for dealing with MAC messages, the second context
contains a key for dealing with encrypted messages. This allows contains a key for dealing with encrypted messages. This allows
for a unified distribution of keys to participants for different for a unified distribution of keys to participants for different
types of messages which have different keys, but where the keys types of messages which have different keys, but where the keys
may be used in coordinated manner. may be used in coordinated manner.
For these cases, the following items need to be considered: For these cases, the following additional items need to be
considered:
o Applications need to ... o Applications need to ensure that the multiple contexts stay
associated. If one of the contexts is invalidated for any reason,
all of the contexts associated with it should also be invalidated.
A.2. Counter Signature Without Headers A.2. Counter Signature Without Headers
TBD There is a group of people who want to have a counter signature
parameter that is directly tied to the value being signed and thus
o No parameter for counter sig the authenticated and unauthenticated buckets can be removed from the
message being sent. The focus on this is an even smaller size, as
o Define to be signed structure all of the information on the process of creating the counter
signature is implicit rather than being explicitly carried in the
o id how key is decided message. This includes not only the algorithm identifier as
presented above, but also items such as the key identification is
o external data struture includes alg id always external to the signature structure. This means that the
entities that are doing the validation of the counter signature are
o bind key in distribution required to infer which key is to be used from context rather than
being explicit. One way of doing this would be to presume that all
data coming from a specific port (or to a specific URL) is to be
validated by a specific key. (Note that this does not require that
the key identifier be part of the value signed as it does not serve a
cryptographic purpose. If the key validates the counter signature,
then it should be presumed that the entity associated with that key
produced the signature.)
o single alg of key structure When computing the signature for the bare counter signature header,
the same Sig_structure defined in Section 4.4. The sign_protected
field is omitted as there is no protected header field in in this
counter signature header. The value of "CounterSignature0" is placed
in the context field of the Sig_stucture.
o uniques of kid not real +-------------------------------+-------+------------+-------------+
| name | label | value type | description |
+-------------------------------+-------+------------+-------------+
| counter signature w/o headers | 9 | bstr | |
+-------------------------------+-------+------------+-------------+
o very specialized for small size Table 27
o kid can be either implied OR show as kid of what is counter signed
Appendix B. Three Levels of Recipient Information Appendix B. Three Levels of Recipient Information
All of the currently defined recipient algorithms classes only use All of the currently defined recipient algorithms classes only use
two levels of the COSE_Enveloped structure. The first level is the two levels of the COSE_Encrypt structure. The first level is the
message content and the second level is the content key encryption. message content and the second level is the content key encryption.
However, if one uses a recipient algorithm such as RSA-KEM (see However, if one uses a recipient algorithm such as RSA-KEM (see
Appendix A of RSA-KEM [RFC5990], then it make sense to have three Appendix A of RSA-KEM [RFC5990], then it make sense to have three
levels of the COSE_Enveloped structure. levels of the COSE_Encrypt structure.
These levels would be: These levels would be:
o Level 0: The content encryption level. This level contains the o Level 0: The content encryption level. This level contains the
payload of the message. payload of the message.
o Level 1: The encryption of the CEK by a KEK. o Level 1: The encryption of the CEK by a KEK.
o Level 2: The encryption of a long random secret using an RSA key o Level 2: The encryption of a long random secret using an RSA key
and a key derivation function to convert that secret into the KEK. and a key derivation function to convert that secret into the KEK.
skipping to change at page 88, line 38 skipping to change at page 93, line 23
o Level 0: Has a content encrypted with AES-GCM using a 128-bit key. o Level 0: Has a content encrypted with AES-GCM using a 128-bit key.
o Level 1: Uses the AES Key wrap algorithm with a 128-bit key. o Level 1: Uses the AES Key wrap algorithm with a 128-bit key.
o Level 2: Uses ECDH Ephemeral-Static direct to generate the level 1 o Level 2: Uses ECDH Ephemeral-Static direct to generate the level 1
key. key.
In effect this example is a decomposed version of using the ECDH- In effect this example is a decomposed version of using the ECDH-
ES+A128KW algorithm. ES+A128KW algorithm.
Size of binary file is 184 bytes
992(
[
/ protected / h'a10101' / {
\ alg \ 1:1 \ AES-GCM 128 \
} / ,
/ unprotected / {
/ iv / 5:h'02d1f7e6f26c43d4868d87ce'
},
/ ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e28529bf9be9d
e3bea1788f681200d875242f6',
/ recipients / [
[
/ protected / h'',
/ unprotected / {
/ alg / 1:-3 / A128KW /
},
/ ciphertext / h'f4b117264ab6d4d1476e0204bb15db58c5834461e83
5e884',
/ recipients / [
[
/ protected / h'a1013818' / {
\ alg \ 1:-25 \ ECDH-ES + HKDF-256 \
} / ,
/ unprotected / {
/ ephemeral / -1:{
/ kty / 1:2,
/ crv / -1:1,
/ x / -2:h'b2add44368ea6d641f9ca9af308b4079aeb519f11
e9b8a55a600b21233e86e68',
/ y / -3:false
},
/ kid / 4:'meriadoc.brandybuck@buckland.example'
},
/ ciphertext / h''
]
]
]
]
]
)
Appendix C. Examples Appendix C. Examples
This appendix includes a set of examples that show the different This appendix includes a set of examples that show the different
features and message types that have been defined in this document. features and message types that have been defined in this document.
To make the examples easier to read, they are presented using the To make the examples easier to read, they are presented using the
extended CBOR diagnostic notation (defined in extended CBOR diagnostic notation (defined in
[I-D.greevenbosch-appsawg-cbor-cddl]) rather than as a binary dump. [I-D.greevenbosch-appsawg-cbor-cddl]) rather than as a binary dump.
A GITHUB project has been created at https://github.com/cose-wg/ A GITHUB project has been created at https://github.com/cose-wg/
Examples that contains not only the examples presented in this Examples that contains not only the examples presented in this
skipping to change at page 93, line 37 skipping to change at page 96, line 37
/ kid / 4:'11' / kid / 4:'11'
}, },
/ signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5
51ce5705b793914348e14eea4aee6e0c9f09db4ef3ddeca8f3506cd1a98a8fb64327 51ce5705b793914348e14eea4aee6e0c9f09db4ef3ddeca8f3506cd1a98a8fb64327
be470355c9657ce0' be470355c9657ce0'
] ]
] ]
] ]
) )
C.1.4. Signature w/ Operation Time and Criticality C.1.4. Signature w/ Criticality
This example uses the following: This example uses the following:
o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256-1 o Signature Algorithm: ECDSA w/ SHA-256, Curve P-256-1
o There is an operation time of 2014-02-14T12:00Z
o There is a criticality marker on the "reserved" header parameter o There is a criticality marker on the "reserved" header parameter
Size of binary file is 132 bytes Size of binary file is 126 bytes
991( 991(
[ [
/ protected / h'a2687265736572766564f40281687265736572766564' / / protected / h'a2687265736572766564f40281687265736572766564' /
{ {
"reserved":false, "reserved":false,
\ crit \ 2:[ \ crit \ 2:[
"reserved" "reserved"
] ]
} / , } / ,
/ unprotected / {}, / unprotected / {},
/ payload / 'This is the content.', / payload / 'This is the content.',
/ signatures / [ / signatures / [
[ [
/ protected / h'a20126081a56bffbc0' / { / protected / h'a10126' / {
\ alg \ 1:-7 \ ECDSA 256 \, \ alg \ 1:-7 \ ECDSA 256 \
8:1455422400
} / , } / ,
/ unprotected / { / unprotected / {
/ kid / 4:'11' / kid / 4:'11'
}, },
/ signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5 / signature / h'eae868ecc176883766c5dc5ba5b8dca25dab3c2e56a5
51ce5705b793914348e150d023101a60dddbf0c11f6cdaf5708e12925c67dbb5d1db 51ce5705b793914348e1ff259ead2c38d8a7d8a9c87c2ce534d762dab059773115a6
d16b2474483e367b' 176fa780e85b6b25'
] ]
] ]
] ]
) )
C.2. Single Signer Examples C.2. Single Signer Examples
C.2.1. Single ECDSA signature C.2.1. Single ECDSA signature
This example uses the following: This example uses the following:
skipping to change at page 95, line 28 skipping to change at page 98, line 28
C.3. Examples of Enveloped Messages C.3. Examples of Enveloped Messages
C.3.1. Direct ECDH C.3.1. Direct ECDH
This example uses the following: This example uses the following:
o CEK: AES-GCM w/ 128-bit key o CEK: AES-GCM w/ 128-bit key
o Recipient class: ECDH Ephemeral-Static, Curve P-256 o Recipient class: ECDH Ephemeral-Static, Curve P-256
Size of binary file is 152 bytes Size of binary file is 185 bytes
992( 992(
[ [
/ protected / h'a10101' / { / protected / h'a10101' / {
\ alg \ 1:1 \ AES-GCM 128 \ \ alg \ 1:1 \ AES-GCM 128 \
} / , } / ,
/ unprotected / { / unprotected / {
/ iv / 5:h'c9cf4df2fe6c632bf7886413' / iv / 5:h'c9cf4df2fe6c632bf7886413'
}, },
/ ciphertext / h'40970cd7ab5fbd10f505bf7a86e6fc0a99a31224b3b5895 / ciphertext / h'40970cd7ab5fbd10f505bf7a86e6fc0a99a3122475fbed3
c9fc7892ba138233e0e65af84', 36488c3220f884f011ba219ea',
/ recipients / [ / recipients / [
[ [
/ protected / h'a1013818' / { / protected / h'a1013818' / {
\ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \
} / , } / ,
/ unprotected / { / unprotected / {
/ ephemeral / -1:{ / ephemeral / -1:{
/ kty / 1:2, / kty / 1:2,
/ crv / -1:1, / crv / -1:1,
/ x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf
bf054e1c7b4d91d6280', bf054e1c7b4d91d6280',
/ y / -3:true / y / -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069
170d924b7e03bf822bb'
}, },
/ kid / 4:'meriadoc.brandybuck@buckland.example' / kid / 4:'meriadoc.brandybuck@buckland.example'
}, },
/ ciphertext / h'' / ciphertext / h''
] ]
] ]
] ]
) )
C.3.2. Direct plus Key Derivation C.3.2. Direct plus Key Derivation
skipping to change at page 97, line 15 skipping to change at page 100, line 15
Size of binary file is 92 bytes Size of binary file is 92 bytes
992( 992(
[ [
/ protected / h'a1010a' / { / protected / h'a1010a' / {
\ alg \ 1:10 \ AES-CCM-16-64-128 \ \ alg \ 1:10 \ AES-CCM-16-64-128 \
} / , } / ,
/ unprotected / { / unprotected / {
/ iv / 5:h'89f52f65a1c580933b5261a76c' / iv / 5:h'89f52f65a1c580933b5261a76c'
}, },
/ ciphertext / h'89bedc91e9909346a8fe87834445679ee12b2c953cbb685 / ciphertext / h'89bedc91e9909346a8fe87834445679ee12b2c95f57feed
25aa7675f', 836e6d4bd',
/ recipients / [ / recipients / [
[ [
/ protected / h'a10129' / { / protected / h'a10129' / {
\ alg \ 1:-10 \ alg \ 1:-10
} / , } / ,
/ unprotected / { / unprotected / {
/ salt / -20:'aabbccddeeffgghh', / salt / -20:'aabbccddeeffgghh',
/ kid / 4:'our-secret' / kid / 4:'our-secret'
}, },
/ ciphertext / h'' / ciphertext / h''
skipping to change at page 97, line 40 skipping to change at page 100, line 40
) )
C.3.3. Counter Signature on Encrypted Content C.3.3. Counter Signature on Encrypted Content
This example uses the following: This example uses the following:
o CEK: AES-GCM w/ 128-bit key o CEK: AES-GCM w/ 128-bit key
o Recipient class: ECDH Ephemeral-Static, Curve P-256 o Recipient class: ECDH Ephemeral-Static, Curve P-256
Size of binary file is 327 bytes Size of binary file is 360 bytes
992( 992(
[ [
/ protected / h'a10101' / { / protected / h'a10101' / {
\ alg \ 1:1 \ AES-GCM 128 \ \ alg \ 1:1 \ AES-GCM 128 \
} / , } / ,
/ unprotected / { / unprotected / {
/ iv / 5:h'c9cf4df2fe6c632bf7886413', / iv / 5:h'c9cf4df2fe6c632bf7886413',
/ countersign / 7:[ / countersign / 7:[
/ protected / h'a1013823' / { / protected / h'a1013823' / {
\ alg \ 1:-36 \ alg \ 1:-36
} / , } / ,
/ unprotected / { / unprotected / {
/ kid / 4:'bilbo.baggins@hobbiton.example' / kid / 4:'bilbo.baggins@hobbiton.example'
}, },
/ signature / h'00aa98cbfd382610a375d046a275f30266e8d0faacb9 / signature / h'00aa98cbfd382610a375d046a275f30266e8d0faacb9
069fde06e37825ae7825419c474f416ded0c8e3e7b55bff68f2a704135bdf99186f6 069fde06e37825ae7825419c474f416ded0c8e3e7b55bff68f2a704135bdf99186f6
6659461c8cf929cc7fb3013ac242342ddd8443c6292a1f8c78c5985aa7d86f34c0f1 6659461c8cf929cc7fb301d57eb4d42d95dc0a61b72ee49dda4ce431d434dc7e02c2
ba0b3dee5f4b59737b230da980886137da6f2ca79cc5c40ee89b771c71cdb1ee966e cdff49d9189cfbffdaf0444f10bfe9a9ebd96bee2c0d76743936f6f56ac62c8ed4d3
cfc7d4b2cdc1410a' ee3758390d877901'
] ]
}, },
/ ciphertext / h'40970cd7ab5fbd10f505bf7a86e6fc0a99a31224b3b5895 / ciphertext / h'40970cd7ab5fbd10f505bf7a86e6fc0a99a3122475fbed3
c9fc7892ba138233e0e65af84', 36488c3220f884f011ba219ea',
/ recipients / [ / recipients / [
[ [
/ protected / h'a1013818' / { / protected / h'a1013818' / {
\ alg \ 1:-25 \ ECDH-ES + HKDF-256 \ \ alg \ 1:-25 \ ECDH-ES + HKDF-256 \
} / , } / ,
/ unprotected / { / unprotected / {
/ ephemeral / -1:{ / ephemeral / -1:{
/ kty / 1:2, / kty / 1:2,
/ crv / -1:1, / crv / -1:1,
/ x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf / x / -2:h'98f50a4ff6c05861c8860d13a638ea56c3f5ad7590bbf
bf054e1c7b4d91d6280', bf054e1c7b4d91d6280',
/ y / -3:true / y / -3:h'f01400b089867804b8e9fc96c3932161f1934f4223069
170d924b7e03bf822bb'
}, },
/ kid / 4:'meriadoc.brandybuck@buckland.example' / kid / 4:'meriadoc.brandybuck@buckland.example'
}, },
/ ciphertext / h'' / ciphertext / h''
] ]
] ]
] ]
) )
C.3.4. Encrypted Content with External Data C.3.4. Encrypted Content with External Data
skipping to change at page 99, line 25 skipping to change at page 102, line 25
Size of binary file is 174 bytes Size of binary file is 174 bytes
992( 992(
[ [
/ protected / h'a10101' / { / protected / h'a10101' / {
\ alg \ 1:1 \ AES-GCM 128 \ \ alg \ 1:1 \ AES-GCM 128 \
} / , } / ,
/ unprotected / { / unprotected / {
/ iv / 5:h'02d1f7e6f26c43d4868d87ce' / iv / 5:h'02d1f7e6f26c43d4868d87ce'
}, },
/ ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e2852951f6f24 / ciphertext / h'64f84d913ba60a76070a9a48f26e97e863e28529d8f5335
9e6c3616233a911748a80be95', e5f0165eee976b4a5f6c6f09d',
/ recipients / [ / recipients / [
[ [
/ protected / h'a101381f' / { / protected / h'a101381f' / {
\ alg \ 1:-32 \ ECHD-SS+A128KW \ \ alg \ 1:-32 \ ECHD-SS+A128KW \
} / , } / ,
/ unprotected / { / unprotected / {
/ static kid / -3:'peregrin.took@tuckborough.example', / static kid / -3:'peregrin.took@tuckborough.example',
/ kid / 4:'meriadoc.brandybuck@buckland.example', / kid / 4:'meriadoc.brandybuck@buckland.example',
/ U nonce / -22:h'0101' / U nonce / -22:h'0101'
}, },
skipping to change at page 100, line 12 skipping to change at page 103, line 12
Size of binary file is 54 bytes Size of binary file is 54 bytes
993( 993(
[ [
/ protected / h'a1010a' / { / protected / h'a1010a' / {
\ alg \ 1:10 \ AES-CCM-16-64-128 \ \ alg \ 1:10 \ AES-CCM-16-64-128 \
} / , } / ,
/ unprotected / { / unprotected / {
/ iv / 5:h'89f52f65a1c580933b5261a78c' / iv / 5:h'89f52f65a1c580933b5261a78c'
}, },
/ ciphertext / h'5974e1b99a3a4cc09a659aa2e9e7fff161d38ce74693c90 / ciphertext / h'5974e1b99a3a4cc09a659aa2e9e7fff161d38ce7edd5617
dcda22121' 388e77baf'
] ]
) )
C.4.2. Encrypted Message w/ a Partial IV C.4.2. Encrypted Message w/ a Partial IV
This example uses the following: This example uses the following:
o CEK: AES-CCM w/ 128-bit key and a 64-bit tag o CEK: AES-CCM w/ 128-bit key and a 64-bit tag
o Prefix for IV is 89F52F65A1C580933B52 o Prefix for IV is 89F52F65A1C580933B52
skipping to change at page 100, line 35 skipping to change at page 103, line 35
Size of binary file is 43 bytes Size of binary file is 43 bytes
993( 993(
[ [
/ protected / h'a1010a' / { / protected / h'a1010a' / {
\ alg \ 1:10 \ AES-CCM-16-64-128 \ \ alg \ 1:10 \ AES-CCM-16-64-128 \
} / , } / ,
/ unprotected / { / unprotected / {
/ partial iv / 6:h'61a7' / partial iv / 6:h'61a7'
}, },
/ ciphertext / h'252a8911d465c125b6764739700f0141ed09192d2e16ce9 / ciphertext / h'252a8911d465c125b6764739700f0141ed09192da5c69e5
e579fea11' 33abf852b'
] ]
) )
C.5. Examples of MAC messages C.5. Examples of MAC messages
C.5.1. Shared Secret Direct MAC C.5.1. Shared Secret Direct MAC
This example users the following: This example users the following:
o MAC: AES-CMAC, 256-bit key, truncated to 64 bits o MAC: AES-CMAC, 256-bit key, truncated to 64 bits
skipping to change at page 103, line 39 skipping to change at page 106, line 39
o MAC: HMAC w/ SHA-256, 128-bit key o MAC: HMAC w/ SHA-256, 128-bit key
o Recipient class: Uses three different methods o Recipient class: Uses three different methods
1. ECDH Ephemeral-Static, Curve P-521, AES-Key Wrap w/ 128-bit 1. ECDH Ephemeral-Static, Curve P-521, AES-Key Wrap w/ 128-bit
key key
2. AES-Key Wrap w/ 256-bit key 2. AES-Key Wrap w/ 256-bit key
Size of binary file is 310 bytes Size of binary file is 377 bytes
994( 994(
[ [
/ protected / h'a10105' / { / protected / h'a10105' / {
\ alg \ 1:5 \ HMAC 256//256 \ \ alg \ 1:5 \ HMAC 256//256 \
} / , } / ,
/ unprotected / {}, / unprotected / {},
/ payload / 'This is the content.', / payload / 'This is the content.',
/ tag / h'bf48235e809b5c42e995f2b7d5fa13620e7ed834e337f6aa43df16 / tag / h'bf48235e809b5c42e995f2b7d5fa13620e7ed834e337f6aa43df16
1e49e9323e', 1e49e9323e',
/ recipients / [ / recipients / [
skipping to change at page 104, line 25 skipping to change at page 107, line 25
/ protected / h'a101381c' / { / protected / h'a101381c' / {
\ alg \ 1:-29 \ ECHD-ES+A128KW \ \ alg \ 1:-29 \ ECHD-ES+A128KW \
} / , } / ,
/ unprotected / { / unprotected / {
/ ephemeral / -1:{ / ephemeral / -1:{
/ kty / 1:2, / kty / 1:2,
/ crv / -1:3, / crv / -1:3,
/ x / -2:h'0043b12669acac3fd27898ffba0bcd2e6c366d53bc4db / x / -2:h'0043b12669acac3fd27898ffba0bcd2e6c366d53bc4db
71f909a759304acfb5e18cdc7ba0b13ff8c7636271a6924b1ac63c02688075b55ef2 71f909a759304acfb5e18cdc7ba0b13ff8c7636271a6924b1ac63c02688075b55ef2
d613574e7dc242f79c3', d613574e7dc242f79c3',
/ y / -3:true / y / -3:h'00812dd694f4ef32b11014d74010a954689c6b6e8785b
333d1ab44f22b9d1091ae8fc8ae40b687e5cfbe7ee6f8b47918a07bb04e9f5b1a51a
334a16bc09777434113'
}, },
/ kid / 4:'bilbo.baggins@hobbiton.example' / kid / 4:'bilbo.baggins@hobbiton.example'
}, },
/ ciphertext / h'c07072310285bbd3f0675774418138e14388ed47a4a / ciphertext / h'c07072310285bbd3f0675774418138e14388ed47a4a
81219d42a8bfbe3a5559c19de83435d21c6bc' 81219d42a8bfbe3a5559c19de83435d21c6bc'
], ],
[ [
/ protected / h'', / protected / h'',
/ unprotected / { / unprotected / {
/ alg / 1:-5 / A256KW /, / alg / 1:-5 / A256KW /,
skipping to change at page 108, line 38 skipping to change at page 111, line 38
-1:h'849b5786457c1491be3a76dcea6c4271' -1:h'849b5786457c1491be3a76dcea6c4271'
}, },
{ {
1:4, 1:4,
2:'018c0ae5-4d9b-471b-bfd6-eef314bc7037', 2:'018c0ae5-4d9b-471b-bfd6-eef314bc7037',
-1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4 -1:h'849b57219dae48de646d07dbb533566e976686457c1491be3a76dcea6c4
27188' 27188'
} }
] ]
Appendix D. Document Updates Acknowledgments
D.1. Version -09 to -10
o Add more examples
o Revise Design changes
o Add context string for recursive recipient structures
o Change and assign some algorithm numbers
D.2. Version -08 to -09
o Integrate CDDL syntax into the text
o Define Expert review guidelines
o Expand application profiling guidelines
o Expand text around Partial IV
o Creation time becomes Operation time
o Add tagging for all structures so that they cannot be moved
o Add optional parameter to cose media type
o Add single signature and mac structures
D.3. Version -07 to -08
o Redefine sequence number into a the Partial IV.
D.4. Version -06 to -07
o Editorial Changes
o Make new IANA registries be Expert Review
D.5. Version -05 to -06
o Remove new CFRG Elliptical Curve key agreement algorithms.
o Remove RSA algorithms
o Define a creation time and sequence number for discussions.
o Remove message type field from all structures.
o Define CBOR tagging for all structures with IANA registrations.
D.6. Version -04 to -05
o Removed the jku, x5c, x5t, x5t#S256, x5u, and jwk headers.
o Add enveloped data vs encrypted data structures.
o Add counter signature parameter.
D.7. Version -03 to -04
o Change top level from map to array.
o Eliminate the term "key management" from the document.
o Point to content registries for the 'content type' attribute
o Push protected field into the KDF functions for recipients.
o Remove password based recipient information.
o Create EC Curve Registry.
D.8. Version -02 to -03
o Make a pass over all of the algorithm text.
o Alter the CDDL so that Keys and KeySets are top level items and
the key examples validate.
o Add sample key structures.
o Expand text on dealing with Externally Supplied Data.
o Update the examples to match some of the renumbering of fields.
D.9. Version -02 to -03
o Add a set of straw man proposals for algorithms. It is possible/
expected that this text will be moved to a new document.
o Add a set of straw man proposals for key structures. It is
possible/expected that this text will be moved to a new document.
o Provide guidance on use of externally supplied authenticated data.
o Add external authenticated data to signing structure.
D.10. Version -01 to -2
o Add first pass of algorithm information
o Add direct key derivation example.
D.11. Version -00 to -01
o Add note on where the document is being maintained and
contributing notes.
o Put in proposal on MTI algorithms.
o Changed to use labels rather than keys when talking about what
indexes a map.
o Moved nonce/IV to be a common header item.
o Expand section to discuss the common set of labels used in
COSE_Key maps.
o Start marking element 0 in registries as reserved. This document is a product of the COSE working group of the IETF.
o Update examples. The following individuals are to blame for getting me started on this
project in the first place: Richard Barnes, Matt Miller, and Martin
Thomson.
Editorial Comments The initial version of the draft was based to some degree on the
outputs of the JOSE and S/MIME working groups.
[CREF1] JLS: I have not gone through the document to determine what The following individuals provided input into the final form of the
needs to be here yet. We mostly want to grab terms that are document: Carsten Bormann, John Bradley, Brain Campbell, Mike Jones,
used in unusual ways or are not generally understood. Ilari Liusvaara, Francesca Palombini, Goran Selander, and Ludwig
Seitz.
Author's Address Author's Address
Jim Schaad Jim Schaad
August Cellars August Cellars
Email: ietf@augustcellars.com Email: ietf@augustcellars.com
 End of changes. 213 change blocks. 
778 lines changed or deleted 846 lines changed or added

This html diff was produced by rfcdiff 1.45. The latest version is available from http://tools.ietf.org/tools/rfcdiff/