Internet-Draft Encryption Key Derivation in COSE July 2024
Tschofenig Expires 9 January 2025 [Page]
Workgroup:
COSE
Internet-Draft:
draft-tschofenig-cose-cek-hkdf-sha256-00
Published:
Intended Status:
Standards Track
Expires:
Author:
H. Tschofenig
H-BRS

Encryption Key Derivation in the COSE using HKDF with SHA-256

Abstract

This document specifies the derivation of the content-encryption key in CBOR Object Signing and Encryption (COSE). This mechanism protects against attacks where an attacker manipulates the content-encryption algorithm identifier.

About This Document

This note is to be removed before publishing as an RFC.

Status information for this document may be found at https://datatracker.ietf.org/doc/draft-tschofenig-cose-cek-hkdf-sha256/.

Discussion of this document takes place on the COSE Working Group mailing list (mailto:cose@ietf.org), which is archived at https://datatracker.ietf.org/wg/cose/about/. Subscribe at https://www.ietf.org/mailman/listinfo/cose/.

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on 9 January 2025.

Table of Contents

1. Introduction

This document specifies the derivation of the content-encryption key for COSE. The use of this mechanism provides protection against where the attacker manipulates the content-encryption algorithm identifier. This attack has been demonstrated against CMS and the mitigation can be found in [I-D.ietf-lamps-cms-cek-hkdf-sha256]. This attack is generic and can apply to other protocols with similar characteristics, such as COSE. However, the attack requires several preconditions:

  1. The attacker intercepts a COSE Encrypt payload that uses either AES-CCM or AES-GCM [RFC5084].

  2. The attacker converts the intercepted content into a "garbage" COSE Encrypt payload composed of AES-CBC guess blocks.

  3. The attacker sends the "garbage" message to the victim, who then reveals the result of the decryption to the attacker.

  4. If any of the transformed plaintext blocks match the guess for that block, then the attacker learns the plaintext for that block.

With highly structured messages, one block can reveal the only sensitive part of the original message.

This attack is thwarted if the encryption key depends upon the delivery of the unmodified algorithm identifier.

The mitigation for this attack has two parts:

CEK' = HKDF(CEK, COSE_Encrypt.alg)

2. Conventions and Definitions

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

3. Use of of HKDF with SHA-256 to Derive Encryption Keys

The mitigation uses the HMAC-based Extract-and-Expand Key Derivation Function (HKDF) [RFC5869] to derive output keying material (OKM) from input key material (IKM). HKDF is used with the SHA-256 hash function [FIPS180].

If an attacker were to change the originator-provided COSE_Encrypt algorithm identifier then the recipient will derive a different content-encryption key.

The CEK_HKDF function uses the HKDF-Extract and HKDF- Expand functions to derive the OKM from the IKM:

Inputs:
  IKM        Input keying material
  alg        COSE_Key algorithm identifier

Output:
  OKM      output keying material (same size as IKM)

The output OKM is calculated as follows:

  OKM_SIZE = len(IKM)
  IF OKM_SIZE > 8160 THEN raise error

  salt = "CBOR Object Signing and Encryption"
  PRK = HKDF-Extract(salt, IKM)

  OKM = HKDF-Expand(PRK, alg, OKM_SIZE)

4. Security Considerations

This mitigation always uses HKDF with SHA-256. One KDF algorithm was selected to avoid the need for negotiation. In the future, if a weakness is found in the KDF algorithm, a new attribute will need to be assigned for use with an alternative KDF algorithm.

If the attacker removes the cek-hkdf header parameter from the COSE_Encrypt header prior to delivery to the recipient, then the recipient will not attempt to derive CEK', which will deny the recipient access to the content, but will not assist the attacker in recovering the plaintext content.

If the attacker changes the value of the COSE_Encrypt alg parameter prior to delivery to the recipient, then the recipient will derive a different CEK', which will not assist the attacker in recovering the plaintext content. Providing the algorithm identifer as an input to the key derivation function is sufficient to mitigate the attack described in [RS2023], but this mitigation includes both the object identifier and the parameters to protect against some yet-to-be-discovered attack that only manipulates the parameters.

Implementations MUST protect the content-encryption keys, this includes the CEK and CEK'. Compromise of a content-encryption key may result in disclosure of the associated encrypted content. Compromise of a content-authenticated-encryption key may result in disclosure of the associated encrypted content or allow modification of the authenticated content and the additional authenticated data (AAD).

Implementations MUST randomly generate content-encryption keys and content-authenticated-encryption keys. Content key distribution methods are described in Section 8.5 of [RFC9052] and in Section 6 of [RFC9053]. These algorithms define derivation and protection of content-encryption keys.

5. IANA Considerations

IANA is requested to add a new header parameter to the "COSE Common Header Parameters" established with [RFC9052].

+-----------+-------+--------------+-------------+------------------+
| Name      | Label | Value Type   | Value       | Description      |
|           |       |              | Registry    |                  |
+-----------+-------+--------------+-------------+------------------+
| cek-hkdf  | TBD   | bool         | N/A         | CEK-HKDF-SHA256  |
+-----------+-------+--------------+-------------+------------------+

6. References

6.1. Normative References

[FIPS180]
National Institute of Standards and Technology (NIST), "Secure Hash Standard (SHS), FIPS PUB 180-4", , <https://csrc.nist.gov/pubs/fips/180-4/upd1/final>.
[RFC2119]
Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, , <https://www.rfc-editor.org/rfc/rfc2119>.
[RFC5084]
Housley, R., "Using AES-CCM and AES-GCM Authenticated Encryption in the Cryptographic Message Syntax (CMS)", RFC 5084, DOI 10.17487/RFC5084, , <https://www.rfc-editor.org/rfc/rfc5084>.
[RFC5869]
Krawczyk, H. and P. Eronen, "HMAC-based Extract-and-Expand Key Derivation Function (HKDF)", RFC 5869, DOI 10.17487/RFC5869, , <https://www.rfc-editor.org/rfc/rfc5869>.
[RFC8174]
Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, , <https://www.rfc-editor.org/rfc/rfc8174>.
[RFC9052]
Schaad, J., "CBOR Object Signing and Encryption (COSE): Structures and Process", STD 96, RFC 9052, DOI 10.17487/RFC9052, , <https://www.rfc-editor.org/rfc/rfc9052>.
[RFC9053]
Schaad, J., "CBOR Object Signing and Encryption (COSE): Initial Algorithms", RFC 9053, DOI 10.17487/RFC9053, , <https://www.rfc-editor.org/rfc/rfc9053>.

6.2. Informative References

[I-D.ietf-lamps-cms-cek-hkdf-sha256]
Housley, R., "Encryption Key Derivation in the Cryptographic Message Syntax (CMS) using HKDF with SHA-256", Work in Progress, Internet-Draft, draft-ietf-lamps-cms-cek-hkdf-sha256-02, , <https://datatracker.ietf.org/doc/html/draft-ietf-lamps-cms-cek-hkdf-sha256-02>.
[RS2023]
Strenzke, F. and J. Roth, "AEAD-to-CBC Downgrade Attacks on CMS", , <https://datatracker.ietf.org/meeting/118/materials/slides-118-lamps-attack-against-aead-in-cms>.

Appendix A. Acknowledgments

The author would like to thank Russ Housley and Ken Takayama for their feedback. The content of this document re-uses from the work done by Russ and applies it to COSE.

Author's Address

Hannes Tschofenig
University of Applied Sciences Bonn-Rhein-Sieg