<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc [
 <!ENTITY nbsp    "&#160;">
 <!ENTITY zwsp   "&#8203;">
 <!ENTITY nbhy   "&#8209;">
 <!ENTITY wj     "&#8288;">
]>
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" category="std" consensus="true" docName="draft-ietf-dtn-bpsec-cose-16" ipr="trust200902" sortRefs="false" symRefs="true" submissionType="IETF" tocInclude="true" updates="9172" version="3" xml:lang="en">
  <front>
    <title abbrev="BPSec COSE">Bundle Protocol Security (BPSec) COSE Context</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-dtn-bpsec-cose-16"/>
    <author fullname="Brian Sipos" initials="B." surname="Sipos">
      <organization abbrev="JHU/APL">The Johns Hopkins University Applied Physics Laboratory</organization>
      <address>
        <postal>
          <street>11100 Johns Hopkins Rd.</street>
          <city>Laurel</city>
          <region>MD</region>
          <code>20723</code>
          <country>United States of America</country>
        </postal>
        <email>brian.sipos+ietf@gmail.com</email>
      </address>
    </author>
    <date/>
    <area>Transport</area>
    <workgroup>Delay-Tolerant Networking</workgroup>
    <keyword>COSE</keyword>
    <keyword>DTN</keyword>
    <keyword>PKIX</keyword>
    <abstract>
      <t>
This document defines a security context suitable for using CBOR Object Signing and Encryption (COSE) algorithms within Bundle Protocol Security (BPSec) integrity and confidentiality blocks.
A profile for COSE, focused on asymmetric-key algorithms, and for public key certificates are also defined for BPSec interoperation.
      </t>
    </abstract>
  </front>
  <middle>
    <section anchor="sec-intro">
      <name>Introduction</name>
      <t>
The Bundle Protocol Security (BPSec) Specification <xref target="RFC9172"/> defines structure and encoding for Block Integrity Block (BIB) and Block Confidentiality Block (BCB) types but does not specify any security contexts to be used by either of the security block types.
The CBOR Object Signing and Encryption (COSE) specifications <xref target="RFC9052"/> and <xref target="RFC9053"/> defines a structure, encoding, and algorithms to use for cryptographic signing and encryption.
      </t>
      <t>
This document describes how to use the algorithms and encodings of COSE within BPSec blocks to apply those algorithms to Bundle security in <xref target="sec-bpsec-context"/>.
A bare minimum of interoperability algorithms and algorithm parameters is specified by this document in <xref target="sec-COSE-profile"/>.
The focus of the recommended algorithms is to allow BPSec to be used in a Public Key Infrastructure (PKI) as described in <xref target="sec-pkix-env"/> using a certificate profile defined in <xref target="sec-pkix-profile"/>.
      </t>
      <t>
Examples of specific security operations are provided in <xref target="sec-example-ops"/> to aid in implementation support of the interoperability algorithms of <xref target="sec-interop-alg"/>.
Examples of public key certificates are provided in <xref target="sec-example-pkc"/> which are compatible with the profile in <xref target="sec-pkix-profile"/> and specific corresponding algorithms.
      </t>
      <section>
        <name>Scope</name>
        <t>
This document describes a profile of COSE which is tailored for use in BPSec and a method of including full COSE messages within BPSec security blocks.
This document does not address:
        </t>
        <ul spacing="normal">
          <li>
Policies or mechanisms for issuing Public Key Infrastructure Using X.509 (PKIX) certificates; provisioning, deploying, or accessing certificates and private keys; deploying or accessing certificate revocation lists (CRLs); or configuring security parameters on an individual entity or across a network.
          </li>
          <li>
Uses of COSE beyond the profile defined in this document.
          </li>
          <li>
How those COSE algorithms are intended to be used within a larger security context.
Many header parameters used by COSE (e.g., key identifiers) depend on the network environment and security policy related to that environment.
          </li>
        </ul>
      </section>
      <section anchor="sec-pkix-env">
        <name>PKIX Environments and CA Policy</name>
        <t>
This specification gives requirements about how to use PKIX certificates issued by a Certificate Authority (CA), but does not define any mechanisms for how those certificates come to be.
        </t>
        <t>
To support the PKIX uses defined in this document, the CA(s) issuing certificates for BP nodes are aware of the end use of the certificate, have a mechanism for verifying ownership of a Node ID, and are issuing certificates directly for that Node ID.
BPSec security verifiers and acceptors authenticate the Node ID of security sources when verifying integrity (see <xref target="sec-context-auth"/>) using a public key provided by a PKIX certificate (see <xref target="sec-context-auth"/>) following the certificate profile of <xref target="sec-pkix-profile"/>.
        </t>
      </section>
      <section>
        <name>Use of CDDL</name>
        <t>
This document defines CBOR structure using the Concise Data Definition Language (CDDL) of <xref target="RFC8610"/>.
The entire CDDL structure can be extracted from the XML version of this document using the XPath expression:
        </t>
        <sourcecode>'//sourcecode[@type="cddl"]'</sourcecode>
        <t>
The following initial fragment defines the top-level rules of this document's CDDL, including the ASB data structure with its parameter/result sockets and rules needed for validating the example CBOR content.
        </t>
        <sourcecode type="cddl">
start = bpsec-cose-asb /
  primary-block / extension-block /
  external_aad / COSE_KDF_Context /
  MAC_structure / Sig_structure / Enc_structure / COSE_KeySet
        </sourcecode>
        <t>
The definitions for the rules <tt>MAC_structure</tt>, <tt>Sig_structure</tt>, <tt>Enc_structure</tt>, and <tt>COSE_KeySet</tt> are taken from COSE <xref target="RFC9052"/>.
The definition for the rule <tt>COSE_CertHash</tt> is taken from COSE X.509 <xref target="RFC9360"/>.
The definitions for the rules <tt>eid</tt>, <tt>primary-block</tt>, and <tt>extension-block</tt>, <tt>block-control-flags</tt>, the socket <tt>$extension-block</tt>, and the generic rule <tt>extension-block-use</tt> are taken from BP <xref target="RFC9171"/>.
The BPSec specification <xref target="RFC9172"/> did not define its extension blocks using CDDL, so a supplementary definition for BPSec is provided in <xref target="sec-cddl-bpsec"/>.
        </t>
      </section>
      <section>
        <name>Terminology</name>
        <t>
The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>", "<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.
        </t>
        <t>
The following terms are taken from BPSec <xref target="RFC9172"/>.
        </t>
        <dl>
          <dt>Security Operation:</dt>
          <dd>
The application of a given security service to a security target.
A security operation is implemented by a security block.
          </dd>
          <dt>Security Context:</dt>
          <dd>
The set of assumptions, algorithms, configurations, and policies used to implement security services.
Each BPSec security context is identified by a code point present in an ASB.
          </dd>
          <dt>Abstract Security Block (ASB):</dt>
          <dd>
The structure of a bundle integrity block (BIB) an a bundle confidentiality block (BCB).
          </dd>
          <dt>(Security) Parameter:</dt>
          <dd>
A context-specific option which applies to all security operations in an ASB.
          </dd>
          <dt>(Security) Result:</dt>
          <dd>
A context-specific output for a single security operation in an ASB.
          </dd>
          <dt>Security Source:</dt>
          <dd>
A BPA that adds a security block to a bundle.
          </dd>
          <dt>Security Acceptor:</dt>
          <dd>
A BPA that processes and dispositions one or more security blocks in a bundle.
Security acceptors act as the endpoint of a security service represented in a security block.
          </dd>
          <dt>Security Verifier:</dt>
          <dd>
A BPA that verifies the data integrity of one or more security blocks in a bundle.
Unlike security acceptors, security verifiers do not act as the endpoint of a security service, and they do not remove verified security blocks
          </dd>
        </dl>
        <t>
The following terms are taken from COSE <xref target="RFC9052"/> <xref target="RFC9053"/>.
        </t>
        <dl>
          <dt>Additional Authenticated Data (AAD):</dt>
          <dd>
This is structured data defined by COSE to provide context inputs to integrity operations (signing or MAC) or additional data for confidentiality operations (encryption).
A portion of the AAD is provided from outside of the COSE processor as "external AAD" bytes.
          </dd>
          <dt>Key Derivation Function (KDF) Context:</dt>
          <dd>
This is structure data defined by COSE to provide context inputs to key derivation functions.
A portion of the KDF context is provided from outside of the COSE processor as "other" bytes.
          </dd>
          <dt>Key Identifier (KID):</dt>
          <dd>
A general purpose correlator for key material stored outside of COSE messages and referenced from within COSE messages.
          </dd>
          <dt>Initialization Vector (IV):</dt>
          <dd>
An input to authenticated encryption algorithms separate from the secret key, plaintext/ciphertext, or AAD.
          </dd>
        </dl>
        <t>
The following terms are specific to this document.
        </t>
        <dl>
          <dt>Participating Nodes:</dt>
          <dd>
For each security operation, the collection of security source node and all possible security verifiers and acceptors.
Different security operations can have a different set of participating nodes (see <xref target="sec-ops-participating"/>).
          </dd>
          <dt>Middlebox:</dt>
          <dd>
An intermediate BP node along a bundle's path between source and destination node, which may or may not be a participating node.
A middlebox which is not a participating node can alter a bundle in ways which affect security operations (see <xref target="sec-ops-aad-scope"/> and <xref target="sec-threat-aad-mod"/>).
          </dd>
          <dt>Additional Header Maps:</dt>
          <dd>
These are parameters to the COSE context which allow de-duplicating header parameters from COSE messages in an ASB (see <xref target="sec-ASB-param-additional"/> and <xref target="sec-ops-additional-hdrs"/>).
          </dd>
        </dl>
      </section>
    </section>
    <section anchor="sec-bpsec-context">
      <name>BPSec Security Context</name>
      <t>
This document specifies a single security context for use in both BPSec integrity and confidentiality blocks.
This is done to save code points allocated to this specification and to simplify the encoding of COSE-in-BPSec; the BPSec block type uniquely defines the acceptable parameters and results which can be present.
      </t>
      <t>
The COSE security context <bcp14>SHALL</bcp14> have the Security Context ID specified in <xref target="sec-iana-bundle"/>.
      </t>
      <t>
Both types of security block can use parameters (defined in <xref target="sec-ASB-parameters"/>) to carry information applicable to all security operations and results (defined in <xref target="sec-ASB-results"/>) containing a specific COSE message for each security operation.
      </t>
      <figure anchor="fig-context-CDDL">
        <name>COSE context declaration CDDL</name>
        <sourcecode type="cddl"><![CDATA[
; Specialize the ASB for this context
$ext-data-asb /= bpsec-cose-asb
bpsec-cose-asb = bpsec-context-use<
  3, ; Context ID COSE
  $bpsec-cose-param,
  $bpsec-cose-result
>
]]></sourcecode>
      </figure>
      <section anchor="sec-bpsec-context-scope">
        <name>Security Scope</name>
        <t>
The scope here refers to the set of information used by the security context to cryptographically bind with the plaintext data being integrity-protected or confidentiality-protected.
This information is generically referred to as additional authenticated data (AAD), which is also the term used by COSE to describe the same kind of data.
COSE distinguishes between its internal portion of AAD, derived from COSE message content, and <em>external AAD</em> provided by the embedding application, which in this case is the BPSec security context.
        </t>
        <t>
The sources for external AAD within this COSE context are described below, controlled by the <xref target="sec-ASB-param-AAD-scope">AAD Scope parameter</xref>, and implemented as defined in <xref target="sec-secctx-aad"/>.
The purpose of this parameter is similar to the "AAD Scope" parameter and "Integrity Scope" parameter of the Default Security Contexts <xref target="RFC9173"/> but expanded to allow including <em>any</em> block in the bundle as AAD.
        </t>
        <dl newline="true">
          <dt>Primary Block:</dt>
          <dd>
The primary block identifies a bundle and, once created, the contents of this block are immutable.
Changes to the primary block associated with the security target indicate that the target is no longer in its original bundle.
Including the primary block as part of AAD ensures that security target block-type-specific data (BTSD) appears in the same bundle that the security source intended.
          </dd>
          <dt>Other Canonical Block BTSD:</dt>
          <dd>
Including the BTSD of an other, non-target block as part of AAD ensures that that other block's BTSD does not change after the security operation is added.
This can guarantee that not only has the security target BTSD not changed but the additional blocks' BTSD have not changed.
          </dd>
          <dt>Other Canonical Block Metadata:</dt>
          <dd>
Including block metadata, which identifies and types a block, as part of AAD ensures that the block presence does not change after the security operation is added.
This metadata explicitly excludes the CRC type and value fields because the CRC is derived from the BTSD.
The metadata of the security block and the target block are also allowed (as described below), which binds the security result to that specific target block.
          </dd>
          <dt>Target Block Metadata:</dt>
          <dd>
One special case of including block metadata as AAD is for the target block itself, which ensures that the target BTSD is bound to its specific containing block.
This case uses AAD Scope key -1 and the value flag for metadata to indicate that the block metadata is taken from the target of the security operation.
          </dd>
          <dt>Containing Security Block Metadata:</dt>
          <dd>
Another special case of including block metadata is for the security block containing the security operation itself, which ensures that the security operation is bound to its specific containing block.
This case uses AAD scope key -2 and the value flag for metadata to indicate that the block metadata is taken from the containing security block.
          </dd>
          <dt>Containing Security Block BTSD:</dt>
          <dd>
            <t>
The BTSD content of the security block itself (as defined in <xref section="3.6" target="RFC9172"/>) is also partially covered by AAD as explained below.
            </t>
            <ul>
              <li>
The Security Targets field can be included indirectly by using AAD scope key -1 to ensure the AAD includes each target block number.
              </li>
              <li>
The Security Context ID is not included directly, but modification of this field will cause processing (verification or acceptance) of the associated security operations to fail.
              </li>
              <li>
The Security Source field is always included as external AAD, so is protected from modification.
              </li>
              <li>
The Security Context Flags and Security Context Parameters are not all included directly, but the modification of parameters will cause processing of security operations to fail.
The Additional Protected parameter is the portion of this data which is included in the external AAD.
              </li>
              <li>
The Security Results are also not included directly, but these are the COSE messages themselves which are designed to be handled as plaintext.
There are portions of each COSE message (result) which is included in the internal AAD (via <tt>MAC_structure</tt>, <tt>Sig_structure</tt>, or <tt>Enc_structure</tt>) as defined by COSE <xref target="RFC9052"/>.
              </li>
            </ul>
          </dd>
        </dl>
        <t>
Because of these options, it is possible for a security source to create a COSE context integrity operation which covers every block of a bundle at the time the BIB is added (excluding CRC Type and value fields).
By using a minimal AAD scope it is also possible for an integrity operation to cover only the BTSD of its single target block independently of the block metadata or bundle primary block associated with the target at the time the BIB is added.
Likewise, it is possible for a COSE context confidentiality operation to be bound to every other block of a bundle at the time the BCB is added or bound to no context outside the BTSD of the target block.
        </t>
      </section>
      <section anchor="sec-ASB-parameters">
        <name>Parameters</name>
        <t>
Each COSE context parameter value <bcp14>SHALL</bcp14> consist of the COSE structure indicated by <xref target="tab-ASB-parameters"/> in its decoded CBOR item form.
        </t>
        <t>
Each security block <bcp14>SHALL</bcp14> contain no more than one instance of each parameter ID.
Security verifiers and acceptors <bcp14>SHALL</bcp14> treat a security block with multiple instances of any parameter ID as invalid.
There is no well-defined behavior for a security acceptor to handle multiple Additional Protected or AAD Scope parameters.
        </t>
        <table anchor="tab-ASB-parameters">
          <name>COSE Context Parameters</name>
          <thead>
            <tr>
              <th>Parameter ID</th>
              <th>Parameter Structure</th>
              <th>Reference</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>3</td>
              <td><tt>additional-protected</tt></td>
              <td><xref target="sec-ASB-param-additional"/> of this document</td>
            </tr>
            <tr>
              <td>4</td>
              <td><tt>additional-unprotected</tt></td>
              <td><xref target="sec-ASB-param-additional"/> of this document</td>
            </tr>
            <tr>
              <td>5</td>
              <td><tt>AAD-scope</tt></td>
              <td><xref target="sec-ASB-param-AAD-scope"/> of this document</td>
            </tr>
          </tbody>
        </table>
        <t>
When a parameter is not present and a default value is defined below, a security verifier or acceptor <bcp14>SHALL</bcp14> use that default value to process the target:
        </t>
        <ul>
          <li>The default <tt>additional-protected</tt> is <tt>''</tt> (an empty byte string).</li>
          <li>The default <tt>additional-unprotected</tt> is <tt>''</tt> (an empty byte string).</li>
          <li>The default <tt>AAD-scope</tt> is <tt>{0:0b1,-1:0b1,-2:0b1}</tt> (a map which indicates the AAD contains the metadata of the primary, target, and security blocks).</li>
        </ul>
        <section anchor="sec-ASB-param-additional">
          <name>Additional Header Maps</name>
          <t>
The two parameters Additional Protected and Additional Unprotected allow de-duplicating header items which are common to all COSE results.
Both additional header values contain a CBOR map which is to be merged with each of the result's unprotected headers.
Although the additional header items are all treated as unprotected from the perspective of the COSE message, the additional protected map is included within the <xref target="sec-secctx-aad">external AAD</xref>.
The expected use of additional header map is to contain a certificate (chain) or identifier (see <xref target="sec-asym-keys"/>) which applies to all results in the same security block.
          </t>
          <t>
Following the same pattern as COSE, when both additional header maps are present in a single security block they <bcp14>SHALL</bcp14> not contain any duplicated labels.
Security verifiers and acceptors <bcp14>SHALL</bcp14> treat a pair of additional header maps containing duplicated labels as invalid.
          </t>
          <t>
Security sources <bcp14>SHOULD NOT</bcp14> include an additional header parameter which represents an empty map.
Security verifiers and acceptors <bcp14>SHALL</bcp14> handle empty header map parameters, specifically the Additional Protected parameter because it is part of the external AAD.
          </t>
          <t>
Security verifiers and acceptors <bcp14>SHALL</bcp14> treat the aggregate of both additional header maps as being present in the <tt>unprotected</tt> header map of the highest-layers of the COSE message of each result in the security block (across all security targets).
For single-layer messages (<em>i.e.</em>, COSE_Encrypt0, COSE_MAC0, and COSE_Sign1) the additional headers apply to the message itself (layer 0) and for other messages the additional headers apply to the final recipients.
If the same header label is present in a additional header map and a COSE layer's headers the item in the result header <bcp14>SHALL</bcp14> take precedence (<em>i.e.</em>, the additional header items are added only if they are not already present in a layer's header).
          </t>
          <t>
Additional header maps <bcp14>SHALL</bcp14> NOT contain any private key material.
The security parameters are all stored in the bundle as plaintext and are visible to any bundle handlers.
          </t>
          <figure anchor="fig-additional-cddl">
            <name>Additional Headers CDDL</name>
            <sourcecode type="cddl">
$bpsec-cose-param /= [3, additional-protected]
additional-protected = empty_or_serialized_map

$bpsec-cose-param /= [4, additional-unprotected]
additional-unprotected = empty_or_serialized_map
            </sourcecode>
          </figure>
        </section>
        <section anchor="sec-ASB-param-AAD-scope">
          <name>AAD Scope</name>
          <t>
The AAD Scope parameter controls what data is included in the AAD for both integrity and confidentiality operations.
The AAD Scope parameter <bcp14>SHALL</bcp14> be encoded as a CBOR map containing keys referencing bundle blocks (as <tt>uint</tt> or <tt>nint</tt> items) and values representing a collection of bit flags (as <tt>uint</tt> items) as defined below.
          </t>
          <t>
Non-negative integer AAD Scope keys <bcp14>SHALL</bcp14> be interpreted as block numbers in the bundle containing the AAD Scope parameter.
Negative integer AAD Scope keys <bcp14>SHALL</bcp14> be interpreted as special (non-block-number) identifiers according to the IANA registry defined in <xref target="sec-iana-bundle"/>.
That registry contains the following initial values from <xref target="tab-AAD-scope-keys"/> as well as reserved blocks for experimental and private use.
          </t>
          <table anchor="tab-AAD-scope-keys">
            <name>AAD Scope Special Keys</name>
            <thead>
              <tr>
                <th>Value</th>
                <th>Name</th>
                <th>Description</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>-1</td>
                <td>Target block</td>
                <td>Include the target block of the security operation associated with the AAD.</td>
              </tr>
              <tr>
                <td>-2</td>
                <td>Security block</td>
                <td>Include the security block containing the security operation associated with the AAD.</td>
              </tr>
            </tbody>
          </table>
          <t>
AAD Scope values <bcp14>SHALL</bcp14> be interpreted as bit flags according to the IANA registry defined in <xref target="sec-iana-bundle"/> with initial values defined in <xref target="tab-AAD-scope-flags"/>.
Any AAD Scope value bits <bcp14>SHALL</bcp14> NOT all be set to zero, which would represent the lack of presence in the AAD and serves no purpose.
When the map key identifies the primary block (block number zero) the bits <bcp14>SHALL</bcp14> only have <tt>AAD-metadata</tt> set, as the primary block has no BTSD.
When the map key identifies the containing security block the bits <bcp14>SHALL</bcp14> only have <tt>AAD-metadata</tt> set, as the security block BTSD does not yet exist.
When the map key identifies the target block the bits <bcp14>SHALL</bcp14> only have <tt>AAD-metadata</tt> set, as the target block BTSD is already part of the security operation (integrity or confidentiality).
All unassigned bits <bcp14>SHALL</bcp14> be set to zero (which will be elided by CBOR encoding) by security sources.
All unassigned bits <bcp14>SHALL</bcp14> be ignored by security verifiers and acceptors.
          </t>
          <table anchor="tab-AAD-scope-flags">
            <name>AAD Scope Flags</name>
            <thead>
              <tr>
                <th><t>Bit Position</t><t>(from LSbit)</t></th>
                <th>Name</th>
                <th>Description</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>0</td>
                <td><tt>AAD-metadata</tt></td>
                <td>If bit is set, indicates that the block metadata is included in the AAD.</td>
              </tr>
              <tr>
                <td>1</td>
                <td><tt>AAD-btsd</tt></td>
                <td>If bit is set, indicates that the BTSD is included in the AAD.</td>
              </tr>
            </tbody>
          </table>
          <t>
A CDDL representation of this definition is included in <xref target="fig-AAD-scope-cddl"/> for reference.
          </t>
          <figure anchor="fig-AAD-scope-cddl">
            <name>AAD Scope CDDL</name>
            <sourcecode type="cddl">
$bpsec-cose-param /= [5, AAD-scope]
AAD-scope = {
    *AAD-scope-key => AAD-scope-val
}
; All uint keys are block numbers
AAD-scope-key = uint / ($blk-id-special .within (-1 .. -65536))
$blk-id-special /= -1 ; target block
$blk-id-special /= -2 ; security block

AAD-scope-val = uint .bits $AAD-scope-flags
$AAD-scope-flags /= 0 ; AAD-metadata
$AAD-scope-flags /= 1 ; AAD-btsd
            </sourcecode>
          </figure>
          <t>
The default value for this parameter (in <xref target="sec-ASB-parameters"/>) includes the primary, target, and security block metadata.
          </t>
        </section>
      </section>
      <section anchor="sec-ASB-results">
        <name>Results</name>
        <t>
Each COSE context result contains a COSE message, but the types of message allowed depend upon the security block type in which the result is present: only MAC or signature messages are allowed in a BIB and only encryption messages are allowed in a BCB.
        </t>
        <t>
Additionally, this context restricts each security operation (embodied as a security target with a result array) to be associated with only a single COSE message (<em>i.e.</em>, a single result for each target).
Within the security context defined in this section, each abstract security block <bcp14>SHALL</bcp14> contain exactly one result per security target.
Security verifiers and acceptors <bcp14>SHALL</bcp14> treat other combinations of results-per-target as invalid.
Security policies can be tailored for this constraint, which has a side effect that each security operation also has only a single set of COSE layer 0 header parameters (<em>e.g.</em>, COSE algorithm).
        </t>
        <t>
The code points for Result ID values are identical to the  existing COSE message-marking tags in <xref section="2" target="RFC9052"/>.
This avoids the need for value-mapping between code points of the two registries.
        </t>
        <t>
When embedding COSE messages, the message CBOR structure <bcp14>SHALL</bcp14> be encoded as a byte string used as the result value.
This allows a security verifier or acceptor to skip over unwanted results without needing to decode the result structure.
When embedding COSE messages, the CBOR-tagged form <bcp14>SHALL</bcp14> NOT be used.
The Result ID values already provide the same information as the COSE tags (using the same code points).
        </t>
        <t>
These generic requirements are formalized in the CDDL fragment of <xref target="fig-results-CDDL"/>.
        </t>
        <figure anchor="fig-results-CDDL">
          <name>COSE context results CDDL</name>
          <sourcecode type="cddl">
$bpsec-cose-result /= [16, bstr .cbor COSE_Encrypt0]
$bpsec-cose-result /= [17, bstr .cbor COSE_Mac0]
$bpsec-cose-result /= [18, bstr .cbor COSE_Sign1]
$bpsec-cose-result /= [96, bstr .cbor COSE_Encrypt]
$bpsec-cose-result /= [97, bstr .cbor COSE_Mac]
$bpsec-cose-result /= [98, bstr .cbor COSE_Sign]
          </sourcecode>
        </figure>
        <section anchor="sec-ASB-results-BIB">
          <name>Integrity Messages</name>
          <t>
When used within a Block Integrity Block, the COSE context <bcp14>SHALL</bcp14> allow only the Result IDs from <xref target="tab-BIB-results"/>.
Each integrity result value <bcp14>SHALL</bcp14> consist of the COSE message indicated by <xref target="tab-BIB-results"/> in its non-tagged encoded form.
        </t>
          <table anchor="tab-BIB-results">
            <name>COSE Integrity Results</name>
            <thead>
              <tr>
                <th>Result ID</th>
                <th>Result Structure</th>
                <th>Reference</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>97</td>
                <td>encoded <tt>COSE_Mac</tt></td>
                <td>
                  <xref target="RFC9052"/>
                </td>
              </tr>
              <tr>
                <td>17</td>
                <td>encoded <tt>COSE_Mac0</tt></td>
                <td>
                  <xref target="RFC9052"/>
                </td>
              </tr>
              <tr>
                <td>98</td>
                <td>encoded <tt>COSE_Sign</tt></td>
                <td>
                  <xref target="RFC9052"/>
                </td>
              </tr>
              <tr>
                <td>18</td>
                <td>encoded <tt>COSE_Sign1</tt></td>
                <td>
                  <xref target="RFC9052"/>
                </td>
              </tr>
            </tbody>
          </table>
          <t>
Each integrity result <bcp14>SHALL</bcp14> use the "detached" payload form with <tt>null</tt> payload value.
The integrity result for COSE_Mac and COSE_Mac0 messages are computed by the procedure in <xref section="6.3" target="RFC9052"/>.
The integrity result for COSE_Sign and COSE_Sign1 messages are computed by the procedure in <xref section="4.4" target="RFC9052"/>.
          </t>
          <t>
The COSE "protected attributes from the application" used for a signature or MAC result <bcp14>SHALL</bcp14> be the encoded data defined in <xref target="sec-secctx-aad"/>.
The COSE payload used for a signature or MAC result <bcp14>SHALL</bcp14> be one of the following:
the encoded form of the primary block if the target is the primary block (block number zero), or
the BTSD content of the target if the target is not the primary block (block number non-zero).
          </t>
        </section>
        <section anchor="sec-ASB-results-BCB">
          <name>Confidentiality Messages</name>
          <t>
When used within a Block Confidentiality Block, COSE context <bcp14>SHALL</bcp14> allow only the Result IDs from <xref target="tab-BCB-results"/>.
Each confidentiality result value <bcp14>SHALL</bcp14> consist of the COSE message indicated by <xref target="tab-BCB-results"/> in its non-tagged encoded form.
          </t>
          <table anchor="tab-BCB-results">
            <name>COSE Confidentiality Results</name>
            <thead>
              <tr>
                <th>Result ID</th>
                <th>Result Structure</th>
                <th>Reference</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>96</td>
                <td>encoded <tt>COSE_Encrypt</tt></td>
                <td>
                  <xref target="RFC9052"/>
                </td>
              </tr>
              <tr>
                <td>16</td>
                <td>encoded <tt>COSE_Encrypt0</tt></td>
                <td>
                  <xref target="RFC9052"/>
                </td>
              </tr>
            </tbody>
          </table>
          <t>
Only algorithms which support Authenticated Encryption with Authenticated Data (AEAD) <bcp14>SHALL</bcp14> be usable in the first (content) layer of a confidentiality result.
Because COSE encryption with AEAD appends the authentication tag with the ciphertext, the size of the BTSD will grow after an encryption operation.
Security verifiers and acceptors <bcp14>SHALL NOT</bcp14> assume that the size of the plaintext is the same as the size of the ciphertext.
          </t>
          <t>
Each confidentiality result <bcp14>SHALL</bcp14> use the "detached" payload form with <tt>null</tt> payload value.
The confidentiality result for COSE_Encrypt and COSE_Encrypt0 messages are computed by the procedure in <xref section="5.3" target="RFC9052"/>.
          </t>
          <t>
The COSE "protected attributes from the application" used for an encryption result <bcp14>SHALL</bcp14> be the encoded data defined in <xref target="sec-secctx-aad"/>.
The COSE payload used for an encryption result <bcp14>SHALL</bcp14> be the BTSD content of the target.
Because confidentiality of the primary block is disallowed by BPSec, there is no logic here for handling a BCB with a target on the primary block.
          </t>
        </section>
      </section>
      <section>
        <name>Key Considerations</name>
        <t>
This specification does not impose any additional key requirements beyond those already specified for each COSE algorithm required in <xref target="sec-COSE-profile"/>.
        </t>
        <t>
It is expected, but not required, that keys referenced and used by COSE messages in this context will themselves be managed as COSE Key objects as defined in <xref section="7" target="RFC9052"/>.
Using native COSE Key objects simplifies the work of an implementation to align with the key and credential identifiers contained in COSE header parameters.
        </t>
      </section>
      <section>
        <name>Canonicalization Algorithms</name>
        <t>
Generating or processing COSE messages for the COSE context follows the profile defined in <xref target="sec-COSE-profile"/> with the "protected attributes from the application" (<em>i.e.</em>, the external AAD) generated as defined in <xref target="sec-secctx-aad"/>, any use of KDF context information as defined in <xref target="sec-secctx-kdfctx"/>, and the detached payload being the BTSD content from the target block as defined in <xref target="sec-secctx-payload"/>.
        </t>
        <section anchor="sec-secctx-aad">
          <name>Generating External AAD</name>
          <t>
The COSE external AAD content defined in this section is used for both integrity and confidentiality messages.
The encoding of this content is different from AAD of <xref section="4.7.2" target="RFC9173"/> and the front items of IPPT of <xref section="3.7" target="RFC9173"/> due to support for <xref target="sec-ASB-param-AAD-scope">AAD scope</xref> covering the ASB security source field and covering an arbitrary number of blocks in the same bundle.
          </t>
          <t>
If the AAD Scope map contains any key which is a positive integer (block number) referencing a block which does not exist in the current bundle or any key which is a negative integer (special key) not supported by the processing entity the generation of the AAD <bcp14>SHALL</bcp14> be considered failed.
          </t>
          <t>
This external AAD <bcp14>SHALL</bcp14> be encoded in accordance with the core deterministic encoding requirements of <xref section="4.2.1" target="RFC8949"/>.
The external AAD content <bcp14>SHALL</bcp14> consist of an encoded CBOR sequence, generated by concatenating the following byte string parts:
          </t>
          <ol>
            <li>
The first part <bcp14>SHALL</bcp14> be the encoded Security Source EID associated with the ASB containing this security operation.
This is a CBOR array of length 2 in accordance with <xref section="4.2.5.1" target="RFC9171"/>.
            </li>
            <li>
The second part <bcp14>SHALL</bcp14> be the encoded AAD Scope value itself.
This is a CBOR map in accordance with <xref target="sec-ASB-param-AAD-scope"/>.
Because of deterministic encoding, the negative keys will occur after positive keys.
            </li>
            <li>
              <t>
For each entry of the AAD Scope map, in ascending block number order followed by the negative special keys in descending order, the next items <bcp14>SHALL</bcp14> be one or both of the following:
              </t>
              <ol type="a">
                <li>
                  <t>
If the map value has the <tt>AAD-metadata</tt> flag set, the next part is block metadata taken from either:
                  </t>
                  <ul>
                    <li>
If the map key is block number zero, the next part <bcp14>SHALL</bcp14> be the encoded form of the primary block of the containing bundle.
This is the full primary block, including its definite-length array head.
This part will be identical to the encoded primary block from the containing bundle if that primary block conforms to encoding requirements of <xref section="4.3.1" target="RFC9171"/>.
                    </li>
                    <li>
Otherwise, next part <bcp14>SHALL</bcp14> be the encoded form of the first three fields of the block (<em>i.e.</em>, the block type code, block number, and control flags) identified by the block number in the map key.
This is just the three encoded CBOR unsigned integer fields concatenated with no framing (array or otherwise).
                    </li>
                  </ul>
                </li>
                <li>
If the map value has the <tt>AAD-btsd</tt> flag set and the map key is <em>not</em> block number zero, the next part <bcp14>SHALL</bcp14> be the re-encoded BTSD of the block identified by the block number in the map key.
This is a definite-length CBOR byte string.
This part will be identical to the encoded BTSD item from the target block itself if that target block conforms to encoding requirements of <xref section="4.3.2" target="RFC9171"/>.
                </li>
              </ol>
            </li>
            <li>
The last part <bcp14>SHALL</bcp14> be the encoded form of the <xref target="sec-ASB-param-additional">Additional Protected parameter</xref>.
This is a definite-length CBOR byte string.
This has a default value of an empty string, defined in <xref target="sec-ASB-parameters"/>.
            </li>
          </ol>
          <t>
Be aware that, because of deterministic encoding requirements here, there is no guarantee that AAD parts containing the same CBOR data as the ASB or containing bundle (<em>e.g.</em>, the Security Source field), result in the same encoded byte string.
When generated by the same entity they are expected to be the same, but an entity verifying or accepting a security operation <bcp14>SHALL</bcp14> treat bundle and block contents as untrusted input and re-encode the AAD parts.
          </t>
          <t>
A CDDL representation of this data is shown below in <xref target="fig-AAD-CDDL"/>.
          </t>
          <figure anchor="fig-AAD-CDDL">
            <name>COSE context AAD CDDL</name>
            <sourcecode type="cddl">
; Not a formal COSE CDDL extension point
external_aad /= bstr .cborseq AAD-list

AAD-list = [
    security-source: eid,
    AAD-scope,
    *AAD-block,
    ; copy of additional-protected (or default empty bstr)
    additional-protected
]
; each AAD item is a group, not a sub-array
AAD-block = (
    ? primary-block,   ; present for block number zero
    ? block-metadata,  ; present if AAD-metadata flag set
    ? bstr,            ; present if AAD-btsd flag set
)
; Selected fields of a canonical block
block-metadata = (
    block-type-code: uint,
    block-number: uint,
    block-control-flags,
)
            </sourcecode>
          </figure>
          <t>
All of the examples of security operations under <xref target="sec-example-ops"/> make use of an explicit <xref target="sec-ASB-param-AAD-scope">AAD Scope parameter</xref> and this external AAD generation.
          </t>
        </section>
        <section anchor="sec-secctx-kdfctx">
          <name>Generating KDF Context</name>
          <t>
The KDF context items defined in this section are used as input to recipient-layer processing of COSE messages which make use of the structure <tt>COSE_KDF_Context</tt> defined in <xref section="5.2" target="RFC9053"/>.
Within that structure the following items are specialized for this BPSec context.
          </t>
          <aside>
            <t>
For the interoperability algorithms of <xref target="sec-interop-alg"/> the only algorithms which use KDF context are direct+HKDF and the ECDH family (all variations).
            </t>
          </aside>
          <t>
The <tt>AlgorithmID</tt> item is fully defined by COSE and not affected by this application.
Due to constraints imposed in <xref target="sec-interop-hdr"/> to not use in-message context values, all of the items within <tt>PartyUInfo</tt> and <tt>PartyVInfo</tt> will be the <tt>null</tt> value.
The remaining application-defined inputs to the KDF context are the optional supplemental public info "other" item and optional supplemental private info item.
The supplemental private info item <bcp14>SHALL NOT</bcp14> be used by this application of COSE.
The supplemental public info "other" item <bcp14>SHALL</bcp14> be present and its content consists of an encoded CBOR sequence, generated by concatenating the following byte string parts:
          </t>
          <ol>
            <li>
The first part <bcp14>SHALL</bcp14> be the encoded CBOR text string "BPSec".
            </li>
            <li>
The second part <bcp14>SHALL</bcp14> be the encoded Security Source EID associated with the ASB containing this security operation.
This is a CBOR array of length 2 in accordance with <xref section="4.2.5.1" target="RFC9171"/>.
            </li>
            <li>
The third part <bcp14>SHALL</bcp14> be the encoded form of the <xref target="sec-ASB-param-additional">Additional Protected parameter</xref>.
This is a definite-length CBOR byte string.
            </li>
          </ol>
          <t>
The Security Source EID and Additional Protected parameter in this data will be identical to that of the external AAD in <xref target="sec-secctx-aad"/>.
          </t>
          <t>
A CDDL representation of this data is shown below in <xref target="fig-KDF-other-CDDL"/>.
          </t>
          <figure anchor="fig-KDF-other-CDDL">
            <name>COSE context KDF public info "other" CDDL</name>
            <sourcecode type="cddl">
; Not a formal COSE CDDL extension point
KDF-SuppPubInfo-other = bstr .cborseq KDF-other-list

KDF-other-list = [
    "BPSec",
    security-source: eid,
    ; copy of additional-protected (or default empty bstr)
    additional-protected
]
            </sourcecode>
          </figure>
          <t>
Examples of KDF context use are in <xref target="fig-ex-encrypt-sym-hkdf-kdfctx"/> of <xref target="sec-example-ops-encrypt-sym-hkdf"/>, <xref target="fig-ex-encrypt-ecc-kw-kdfctx"/> of <xref target="sec-example-ops-encrypt-ecc-kw"/>, and <xref target="fig-ex-encrypt-ecc-hkdf-kdfctx"/> of <xref target="sec-example-ops-encrypt-ecc-hkdf"/>.
          </t>
        </section>
        <section anchor="sec-secctx-payload">
          <name>Payload Data</name>
          <t>
When correlating between BPSec target BTSD and COSE plaintext or payload, any byte string <bcp14>SHALL</bcp14> be handled in its decoded CBOR item form.
This means the CBOR head in an encoded form is ignored for the purposes of security processing; only the BTSD content bytes are significant.
This also means that if the target BTSD was encoded in a non-conforming way, for example in indefinite-length form or with a non-minimum-size length, the security processing always treats it in a deterministically encoded CBOR form.
        </t>
        </section>
      </section>
      <section>
        <name>Processing</name>
        <t>
This section describes block-level requirements for handling COSE security data.
        </t>
        <t>
All security results generated for BIB or BCB blocks <bcp14>SHALL</bcp14> conform to the COSE profile of <xref target="sec-COSE-profile"/> with header augmentation as defined in <xref target="sec-ASB-param-additional"/>.
        </t>
        <section anchor="sec-context-auth">
          <name>Node Authentication</name>
          <t>
This section explains how the certificate profile of <xref target="sec-pkix-profile"/> is used by a security acceptor to both validate an end-entity certificate and to use that certificate to authenticate the security source for an integrity result.
For a confidentiality result, some of the requirements in this section are implicit in an implementation using a private key associated with a certificate used by a result recipient.
It is an implementation matter to ensure that a BP agent is configured to generate or receive results associated with valid certificates.
          </t>
          <t>
A security source <bcp14>MAY</bcp14> prohibit generating a result (either integrity or confidentiality) for an end-entity certificate which is not considered valid according to <xref target="sec-context-auth-valid-cert"/>.
Generating a result which is likely to be discarded is wasteful of bundle size and transport resources.
          </t>
          <section>
            <name>Certificate Identification</name>
            <t>
Because of the standard policy of using separate certificates for transport, signing, and encryption (see <xref target="sec-pkix-multiple-certs"/>) a single Node ID is likely to be associated with multiple certificates, and any or all of those certificates <bcp14>MAY</bcp14> be present within an "x5bag" in an Additional Protected parameter (see <xref target="sec-ASB-param-additional"/>).
When present, a security verifier or acceptor <bcp14>SHALL</bcp14> use an "x5chain" or "x5t" to identify an end-entity certificate to use for result processing.
Security verifiers and acceptors <bcp14>SHALL</bcp14> NOT assume that a validated certificate containing a NODE-ID matching a security source is enough to associate a certificate with a COSE message or recipient (see <xref target="sec-asym-keys"/>).
            </t>
          </section>
          <section anchor="sec-context-auth-valid-cert">
            <name>Certificate Validation</name>
            <t>
For each end-entity certificate contained in or identified by by a COSE result, a security verifier or acceptor <bcp14>SHALL</bcp14> perform the certification path validation of <xref section="6" target="RFC5280"/> up to one of the acceptor's trusted CA certificates.
When evaluating a certificate Validity time interval, a security verifier or acceptor <bcp14>SHALL</bcp14> use the Bundle Creation Time of the primary block as the reference instead of the current time.
If enabled by local policy, the entity <bcp14>SHALL</bcp14> perform an OCSP check of each certificate providing OCSP authority information in accordance with <xref target="RFC6960"/>.
If certificate validation fails or if security policy disallows a certificate for any reason, the acceptor <bcp14>SHALL</bcp14> treat the associated security result as failed.
Leaving out part of the certification chain can cause the entity to fail to validate a certificate if the left-out certificates are unknown to the entity (see <xref target="sec-threat-untrust-cert"/>).
            </t>
            <t>
For each end-entity certificate contained in or identified by a COSE context result, a security verifier or acceptor <bcp14>SHALL</bcp14> apply security policy to the Key Usage extension (if present) and Extended Key Usage extension (if present) in accordance with <xref section="4.2.1.12" target="RFC5280"/> and the profile in <xref target="sec-pkix-profile"/>.
            </t>
          </section>
          <section anchor="sec-context-auth-valid-nodeid">
            <name>Node ID Authentication</name>
            <t>
If required by security policy, for each end-entity certificate referenced by a COSE context integrity result a security verifier or acceptor <bcp14>SHALL</bcp14> validate the certificate NODE-ID in accordance with <xref section="6" target="RFC6125"/> using the NODE-ID reference identifier from the Security Source of the containing security block.
If the NODE-ID validation result is Failure or if the result is Absent and security policy requires an authenticated Node ID, a security verifier or acceptor <bcp14>SHALL</bcp14> treat the result as failed.
            </t>
          </section>
        </section>
        <section anchor="sec-context-auth-policy-rec">
          <name>Policy Recommendations</name>
          <t>
A RECOMMENDED security policy is to enable the use of OCSP checking when internet connectivity is present.
A <bcp14>RECOMMENDED</bcp14> security policy is that if an Extended Key Usage is present that it needs to contain <tt>id-kp-bundleSecurity</tt> of <xref target="IANA-SMI"/> to be usable as an end-entity certificate for COSE security results.
A <bcp14>RECOMMENDED</bcp14> security policy is to require a validated Node ID (of <xref target="sec-context-auth-valid-nodeid"/>) and to ignore any other identifiers in the end-entity certificate.
          </t>
          <t>
This policy relies on and informs the certificate requirements in <xref target="sec-asym-keys-policy-rec"/> and <xref target="sec-pkix-profile"/>.
This policy assumes that a DTN-aware CA (see <xref target="sec-pkix-env"/>) will only issue a certificate for a Node ID when it has verified that the private key holder actually controls the DTN node; this is needed to avoid the threat identified in <xref target="sec-threat-node-impersonation"/>.
This policy requires that a certificate contain a NODE-ID and allows the certificate to also contain network-level identifiers.
A tailored policy on a more controlled network could relax the requirement on Node ID validation and/or Extended Key Usage presence.
          </t>
        </section>
      </section>
    </section>
    <section anchor="sec-COSE-profile">
      <name>COSE Profile</name>
      <t>
This section contains requirements which apply to the use of COSE within the BPSec security context defined in this document.
Other variations of COSE within BPSec can be used but are not expected to be interoperable or usable by all security verifiers and acceptors.
      </t>
      <t>
This interoperability profile supports using shared symmetric keys with modern key strengths, as well as asymmetric (public and private) keypairs when needed by security policy.
The focus of this profile is to enable interoperation between participating nodes (security sources, verifiers, and acceptors) on an open network, where explicit COSE parameters make it easier for verifiers and acceptors to avoid assumptions and avoid out-of-band parameters.
The requirements of this profile still allow the use of potentially not-easily-interoperable algorithms, message, and recipient configurations for use by private networks, where message size is more important than explicit COSE parameters.
      </t>
      <t>
This profile also enables the use of COSE algorithms that are not explicitly part of this interoperability minimum set, including future algorithms not yet registered as COSE code points.
Using such algorithms requires only that all participating nodes are known to support each code point being used.
      </t>
      <section anchor="sec-COSE-messages">
        <name>COSE Messages</name>
        <t>
When generating a BPSec result, security sources <bcp14>SHALL</bcp14> use only COSE labels with a uint value.
When processing a BPSec result, security verifiers and acceptors <bcp14>MAY</bcp14> handle COSE labels with with a tstr value.
        </t>
        <t>
The algorithms required by this profile can be combined in different ways depending on the needs of security sources.
An example of combining with breadth is single COSE_Sign message which contains multiple signatures (in layer 1) from the same source but using different key families (see <xref target="sec-ops-multi-sig"/> for more detail).
An example of combining with depth is a a single COSE_Encrypt message which uses a single shared content encryption key (CEK) for target encryption (layer 0) and multiple recipients (layer 1) using different key wrapping or encapsulation algorithms.
        </t>
        <t>
All of the COSE algorithms needed by this profile can operate within COSE messages having one or two layers.
The messages COSE_Sign1, COSE_Mac0, and COSE_Encrypt0 are by definition limited to one layer.
The messages COSE_Signature, COSE_Mac, and COSE_Encrypt are by definition at least two layers (the content layer and signature/recipient layer).
Security sources <bcp14>SHALL NOT</bcp14> produce COSE messages with more than two layers.
Implementations of this profile <bcp14>MAY</bcp14> be limited to no more than two COSE message layers.
Future use cases could update this profile to expand that minimum, and implementations are free to support larger depths.
        </t>
        <t>
To ensure interoperability, implementations of this profile have only a guaranteed minimum breadth of messages.
All implementations of this profile <bcp14>SHALL</bcp14> support at least 10 signatures per COSE_Signature message.
All implementations of this profile <bcp14>SHALL</bcp14> support at least 10 recipients per COSE_Mac or COSE_Encrypt message.
Future use cases could update this profile to expand that minimum, and implementations are free to support much larger breadths.
        </t>
        <t>
This profile imposes no minimum capabilities of the internal key store, credential store, or trust store of an implementation.
Whether or not an implementation uses COSE Key objects internally, how key identifiers are managed, or how time-variance of key, credential, or trust validity are handled have no effect on its ability to perform COSE messaging.
        </t>
        <t>
COSE messages conforming to this profile <bcp14>SHALL</bcp14> contain an explicit algorithm identifier in the first (content) layer in accordance with <xref target="RFC9052"/>.
When available, each COSE message <bcp14>SHALL</bcp14> contain a key identifier in the last layer for all signatures or recipients.
See <xref target="sec-sym-keys"/> and <xref target="sec-asym-keys"/> for specifics about key identifiers.
When a key identifier is not available, BPSec verifiers and acceptors <bcp14>SHALL</bcp14> use the Security Source and the Bundle Source to imply which keys can be used for security operations.
Using implied keys has an interoperability risk, see <xref target="sec-threat-unident-key"/> for details.
A BPSec security operation always occurs within the context of an immutable primary block with its fields (specifically the Source Node ID) and an abstract security block (ASB) with its Security Source EID.
        </t>
      </section>
      <section anchor="sec-interop-alg">
        <name>Interoperability Algorithms</name>
        <t>
The minimum set of COSE algorithms needed for interoperability is listed in this section and organized by the family of associated key material.
This profile intentionally does not prohibit the use of any other algorithms in specific implementations, devices, or networks and is meant only to provide a starting point for general purpose implementations.
It also does not address post-quantum algorithms which have been published by NIST but are still undergoing standardization in the IETF (see <xref target="sec-ops-alg-choice"/> and <xref target="sec-threat-algo-vuln"/>).
The full set of COSE algorithms available is managed by IANA <xref target="IANA-COSE"/>.
        </t>
        <t>
Each algorithm in this profile is marked as being US CNSS CNSA 1.0 conformant <xref target="CNSA1"/> or CNSA 2.0 conformant <xref target="CNSA2"/> to aid in further narrowing of network-specific profiles and implementations.
All of these algorithms in this profile are approved by US NIST FIPS 140-3 <xref target="NIST-FIPS-140"/>, however FIPS 140 certification involves review of software and hardware design and implementation detail outside the scope of this document.
        </t>
        <t>
The threshold for minimum security strength to be included in this interoperability minimum is roughly equivalent to CNSA 1.0 and the CCSDS Space Data Link Security rationale green book <xref target="CCSDS-SDLS"/>.
The breadth of algorithm variety is intended to cover many different current use cases beyond simple symmetric key security and be compatible with current PKIX mechanisms and strategies.
        </t>
        <section>
          <name>Hashing Algorithms</name>
          <t>
Implementations conforming to this specification <bcp14>SHALL</bcp14> support the non-keyed hash algorithms in <xref target="tab-interop-algs-hash"/> if they will operate with public key certificates.
          </t>
          <table anchor="tab-interop-algs-hash">
            <name>Hash Algorithms</name>
            <thead>
              <tr>
                <th>Name</th>
                <th>Code</th>
                <th>Conformance</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>SHA-256/64</td>
                <td>-15</td>
                <td></td>
              </tr>
              <tr>
                <td>SHA-256</td>
                <td>-16</td>
                <td></td>
              </tr>
              <tr>
                <td>SHA-512/256</td>
                <td>-17</td>
                <td></td>
              </tr>
              <tr>
                <td>SHA-384</td>
                <td>-43</td>
                <td>CNSA 1.0 and 2.0</td>
              </tr>
              <tr>
                <td>SHA-512</td>
                <td>-44</td>
                <td>CNSA 2.0</td>
              </tr>
            </tbody>
          </table>
          <t>
These algorithms are currently used in the <tt>COSE_CertHash</tt> of "x5t" header parameters, which are expected to be included as unprotected (see <xref target="sec-asym-keys"/>).
The truncated algorithms are useful for certificate filtering using shorter thumbprints, so are included here even though they fall below the CNSA 1.0 minimum strength for protecting data.
          </t>
        </section>
        <section>
          <name>Symmetric Algorithms</name>
          <t>
Implementations conforming to this specification <bcp14>SHALL</bcp14> support the symmetric keyed algorithms in <xref target="tab-interop-algs-sym"/>.
          </t>
          <aside>
            <t>
The symmetric keyed algorithms here are not a super-set of those available in the BPSec default security contexts <xref target="RFC9173"/>, this list includes only those which are CNSA 1.0 or 2.0 conformant.
            </t>
          </aside>
          <t>
The "direct" algorithm is really just a recipient placeholder to allow using a content key identifier in a that COSE layer, so has no cryptographic function or effect on security strength.
          </t>
          <table anchor="tab-interop-algs-sym">
            <name>Symmetric Algorithms</name>
            <thead>
              <tr>
                <th>BPSec Block</th>
                <th>COSE Layer</th>
                <th>Name</th>
                <th>Code</th>
                <th>Conformance</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>Integrity</td>
                <td>0</td>
                <td>HMAC 384/384</td>
                <td>6</td>
                <td>CNSA 1.0 and 2.0</td>
              </tr>
              <tr>
                <td>Integrity</td>
                <td>0</td>
                <td>HMAC 512/512</td>
                <td>7</td>
                <td>CNSA 2.0</td>
              </tr>
              <tr>
                <td>Confidentiality</td>
                <td>0</td>
                <td>A256GCM</td>
                <td>3</td>
                <td>CNSA 1.0 and 2.0</td>
              </tr>
              <tr>
                <td>Integrity or Confidentiality</td>
                <td>1</td>
                <td>A256KW</td>
                <td>-5</td>
                <td>CNSA 1.0 and 2.0</td>
              </tr>
              <tr>
                <td>Integrity or Confidentiality</td>
                <td>1</td>
                <td>direct</td>
                <td>-6</td>
                <td><em>N/A</em></td>
              </tr>
              <tr>
                <td>Integrity or Confidentiality</td>
                <td>1</td>
                <td>direct+HKDF-SHA-512</td>
                <td>-11</td>
                <td>CNSA 1.0 and 2.0</td>
              </tr>
            </tbody>
          </table>
          <t>
When generating a BIB result from a symmetric content key, sources <bcp14>SHALL</bcp14> use a COSE_Mac0 message or a COSE_Mac with a direct recipient.
When generating a BIB result from one or more symmetric key-encryption key (KEK) or key-derivation key (KDK), sources <bcp14>SHALL</bcp14> use a COSE_Mac message with recipient(s) containing an indirect (wrapped or derived) CEK.
          </t>
          <t>
The key length used for HMAC algorithms <bcp14>SHALL</bcp14> be equal to the hash function output length.
This is consistent with COSE requirements on derived keys for HMAC but more strict to apply to all content keys used for HMAC.
          </t>
          <t>
When generating a BCB result from a symmetric CEK, sources <bcp14>SHALL</bcp14> use a COSE_Encrypt0 message or a COSE_Encrypt with a direct recipient.
When generating a BCB result from one or more symmetric KEK or KDK, sources <bcp14>SHALL</bcp14> use a COSE_Encrypt message with recipient(s) containing an indirect (wrapped or derived) CEK.
          </t>
          <t>
Security sources <bcp14>SHALL</bcp14> manage the life-cycle of multiple-use CEKs to avoid overuse and vulnerabilities associated with large amount of plaintext processed with the same key.
Security verifiers and acceptors <bcp14>SHOULD</bcp14> keep track of CEKs to avoid overuse and vulnerabilities associated with multiple failures with the same key.
Details are discussed in <xref target="sec-threat-overuse"/>.
          </t>
          <t>
All COSE message results using symmetric keys include a key identifier as required by <xref target="sec-sym-keys"/>.
For COSE_Mac0 and COSE_Encrypt0 the key identifier will be header parameter(s) in the only layer.
For COSE_Mac and COSE_Encrypt key identifiers will be header parameter(s) in the recipient layer(s).
          </t>
          <t>
When a COSE_Mac or COSE_Encrypt is used with a single recipient, the direct HKDF algorithms (code -10 and -11) are <bcp14>RECOMMENDED</bcp14> over the key wrapped algorithms (code -3 through -5) to reduce message size and the need for symmetric key generation.
The use of HKDF also binds to the content layer algorithm code point and mitigates the possibility of a <xref target="sec-threat-downgrade">downgrade attack</xref>.
          </t>
        </section>
        <section>
          <name>ECC Algorithms</name>
          <t>
Implementations conforming to this specification <bcp14>SHALL</bcp14> support the elliptic curve cryptography (ECC) algorithms in <xref target="tab-interop-algs-ecc"/> if they will operate with ECC key material using NIST curves.
          </t>
          <aside>
            <t>
The ECC-based algorithms are CNSA 1.0 conformant <xref target="CNSA1"/> only when used with a key having curve P-384.
            </t>
            <t>
The current ECC-based algorithms using AES key wrap (code -29 through -34) use HKDF with SHA-256, so do not conform to CNSA 1.0.
            </t>
          </aside>
          <table anchor="tab-interop-algs-ecc">
            <name>ECC Algorithms</name>
            <thead>
              <tr>
                <th>BPSec Block</th>
                <th>COSE Layer</th>
                <th>Name</th>
                <th>Code</th>
                <th>Conformance</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>Integrity</td>
                <td>0 or 1</td>
                <td>ESP384</td>
                <td>-51</td>
                <td>CNSA 1.0</td>
              </tr>
              <tr>
                <td>Integrity</td>
                <td>0 or 1</td>
                <td>ESP512</td>
                <td>-52</td>
                <td></td>
              </tr>
              <tr>
                <td>Confidentiality</td>
                <td>1</td>
                <td>ECDH-ES + HKDF-512</td>
                <td>-26</td>
                <td>CNSA 1.0</td>
              </tr>
              <tr>
                <td>Confidentiality</td>
                <td>1</td>
                <td>ECDH-SS + HKDF-512</td>
                <td>-28</td>
                <td>CNSA 1.0</td>
              </tr>
              <tr>
                <td>Confidentiality</td>
                <td>1</td>
                <td>ECDH-ES + A256KW</td>
                <td>-31</td>
                <td></td>
              </tr>
              <tr>
                <td>Confidentiality</td>
                <td>1</td>
                <td>ECDH-SS + A256KW</td>
                <td>-34</td>
                <td></td>
              </tr>
            </tbody>
          </table>
          <t>
When generating a BIB result from an ECC private key, implementations <bcp14>SHALL</bcp14> use a COSE_Sign or COSE_Sign1 using the private key directly.
When a COSE_Sign or COSE_Sign1 is used with an ECC private key, the top-layer headers <bcp14>SHALL</bcp14> include a corresponding public key identifier (see <xref target="sec-asym-keys"/>).
          </t>
          <t>
When generating a BCB result from an ECC public key, implementations <bcp14>SHALL</bcp14> use a COSE_Encrypt message with a recipient containing an indirect (wrapped or derived) CEK.
When a COSE_Encrypt is used with an ECC public key, the recipient layer <bcp14>SHALL</bcp14> include a public key identifier (see <xref target="sec-asym-keys"/>).
When a COSE_Encrypt is used with an ECC public key, the security source <bcp14>SHALL</bcp14> either generate an ephemeral ECC keypair or choose a unique HKDF "salt" for each security operation.
          </t>
          <t>
When a COSE_Encrypt is used with an ECC public key and a single recipient, the direct HKDF algorithms (code -25 through -28) are <bcp14>RECOMMENDED</bcp14> over the key wrapped algorithms (code -29 through -34) to reduce message size and the need for symmetric key generation.
The use of HKDF also binds to the content layer algorithm code point and mitigates the possibility of a <xref target="sec-threat-downgrade">downgrade attack</xref>.
          </t>
          <t>
The choice of whether to use ECDH in static-static (SS) or ephemeral-static (EH) mode depends on what security properties are needed for the operation.
ECDH-SS can reduce message size and allows key generation to happen outside of the source entity, but also requires the ECC public key to either be known by the recipient(s) and identified by or be fully transmitted by a header parameter (as discussed in <xref section="6.3.1" target="RFC9053"/>).
ECDH-ES can provide forward secrecy by using the ephemeral key only for single messages, but also requires the source to generate a new key when needed.
          </t>
        </section>
        <section>
          <name>RSA Algorithms</name>
          <t>
Implementations conforming to this specification <bcp14>SHALL</bcp14> support the Rivest–Shamir–Adleman (RSA) algorithms in <xref target="tab-interop-algs-rsa"/> if they will operate with RSA key material.
          </t>
          <aside>
            <t>
The RSA-based algorithms are CNSA 1.0 conformant <xref target="CNSA1"/> only when used with a key modulus of 3072 bits or larger.
            </t>
          </aside>
          <table anchor="tab-interop-algs-rsa">
            <name>RSA Algorithms</name>
            <thead>
              <tr>
                <th>BPSec Block</th>
                <th>COSE Layer</th>
                <th>Name</th>
                <th>Code</th>
                <th>Conformance</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>Integrity</td>
                <td>0 or 1</td>
                <td>PS384</td>
                <td>-38</td>
                <td>CNSA 1.0</td>
              </tr>
              <tr>
                <td>Integrity</td>
                <td>0 or 1</td>
                <td>PS512</td>
                <td>-39</td>
                <td></td>
              </tr>
              <tr>
                <td>Confidentiality</td>
                <td>1</td>
                <td>RSAES-OAEP w/ SHA-512</td>
                <td>-42</td>
                <td>CNSA 1.0</td>
              </tr>
            </tbody>
          </table>
          <t>
When generating a BIB result from an RSA private key, implementations <bcp14>SHALL</bcp14> use a COSE_Sign or COSE_Sign1 using the private key directly.
When a COSE_Sign or COSE_Sign1 is used with an RSA private key, the top-layer headers <bcp14>SHALL</bcp14> include a public key identifier (see <xref target="sec-asym-keys"/>).
When a COSE signature is generated with an RSA private key, the signature uses a PSS salt in accordance with <xref section="2" target="RFC8230"/>.
          </t>
          <t>
When generating a BCB result from an RSA public key, implementations <bcp14>SHALL</bcp14> use a COSE_Encrypt message with a recipient containing a key-wrapped CEK.
When a COSE_Encrypt is used with an RSA public key, the recipient layer <bcp14>SHALL</bcp14> include a public key identifier (see <xref target="sec-asym-keys"/>).
          </t>
        </section>
        <section>
          <name>ML Algorithms</name>
          <t>
Implementations conforming to this specification <bcp14>SHALL</bcp14> support the module-lattice-based (ML) algorithms in <xref target="tab-interop-algs-ml"/> if they will operate with ML key material.
          </t>
          <table anchor="tab-interop-algs-ml">
            <name>ML Algorithms</name>
            <thead>
              <tr>
                <th>BPSec Block</th>
                <th>COSE Layer</th>
                <th>Name</th>
                <th>Code</th>
                <th>Conformance</th>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>Integrity</td>
                <td>0 or 1</td>
                <td>ML-DSA-87</td>
                <td>-50</td>
                <td>CNSA 2.0</td>
              </tr>
            </tbody>
          </table>
          <t>
When generating a BIB result from an ML private key, implementations <bcp14>SHALL</bcp14> use a COSE_Sign or COSE_Sign1 using the private key directly.
When a COSE_Sign or COSE_Sign1 is used with an ML private key, the top-layer headers <bcp14>SHALL</bcp14> include a public key identifier (see <xref target="sec-asym-keys"/>).
          </t>
          <t>
Uses of ML keys for creating or consuming a BCB result are not supported by this profile.
There are currently no COSE algorithm code points registered for either direct ML-KEM use or ML-KEM within Hybrid Public-Key Encryption (HPKE).
          </t>
        </section>
      </section>
      <section anchor="sec-interop-hdr">
        <name>Needed Header Parameters</name>
        <t>
The set of COSE header parameters needed for interoperability is listed in this section.
The full set of COSE header parameters available is managed by IANA <xref target="IANA-COSE"/>.
        </t>
        <t>
Implementations conforming to this specification <bcp14>SHALL</bcp14> support the header parameters in <xref target="tab-interop-hdrs"/>.
This support means required-to-implement not required-to-use for any particular COSE message.
        </t>
        <t>
Specific COSE algorithms have their own requirements about which header parameters are mandatory or optional to use in the associated COSE message layer.
The phrasing in <xref target="tab-interop-hdrs"/> uses the term "required" where the parameter needs to be understood by all message processors, "optional" where the need for a parameter is determined by the specific end use, and "conditional" for cases where one parameter of several options is needed by this profile.
For example, a choice of specific <xref target="sec-sym-keys">symmetric key identifier</xref> or <xref target="sec-asym-keys">asymmetric key identifier</xref> is conditional and chosen by the source.
        </t>
        <table anchor="tab-interop-hdrs">
          <name>Interoperability Header Parameters</name>
          <thead>
            <tr>
              <th>Name</th>
              <th>Label</th>
              <th>Need</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>alg</td>
              <td>1</td>
              <td>Required for COSE <xref target="RFC9052"/></td>
            </tr>
            <tr>
              <td>crit</td>
              <td>2</td>
              <td>Required for COSE <xref target="RFC9052"/></td>
            </tr>
            <tr>
              <td>content type</td>
              <td>3</td>
              <td>Optional for COSE <xref target="RFC9052"/></td>
            </tr>
            <tr>
              <td>kid</td>
              <td>4</td>
              <td>Conditional for this COSE profile</td>
            </tr>
            <tr>
              <td>IV</td>
              <td>5</td>
              <td>Conditional for symmetric encryption algorithms</td>
            </tr>
            <tr>
              <td>Partial IV</td>
              <td>6</td>
              <td>Conditional for symmetric encryption algorithms</td>
            </tr>
            <tr>
              <td>kid context</td>
              <td>10</td>
              <td>Optional for this COSE profile</td>
            </tr>
            <tr>
              <td>x5bag</td>
              <td>32</td>
              <td>Conditional for public key algorithms</td>
            </tr>
            <tr>
              <td>x5chain</td>
              <td>33</td>
              <td>Conditional for public key algorithms</td>
            </tr>
            <tr>
              <td>x5t</td>
              <td>34</td>
              <td>Conditional for public key algorithms</td>
            </tr>
            <tr>
              <td>ephemeral key</td>
              <td>-1</td>
              <td>Required for ECDH-ES algorithms</td>
            </tr>
            <tr>
              <td>static key</td>
              <td>-2</td>
              <td>Conditional for ECDH-SS algorithms</td>
            </tr>
            <tr>
              <td>static key id</td>
              <td>-3</td>
              <td>Conditional for ECDH-SS algorithms</td>
            </tr>
            <tr>
              <td>salt</td>
              <td>-20</td>
              <td>Required for direct+HKDF and ECDH-SS algorithms, optional for ECDH-ES</td>
            </tr>
            <tr>
              <td>x5t-sender</td>
              <td>-27</td>
              <td>Conditional for ECDH-SS algorithms</td>
            </tr>
            <tr>
              <td>x5chain-sender</td>
              <td>-29</td>
              <td>Conditional for ECDH-SS algorithms</td>
            </tr>
          </tbody>
        </table>
        <t>
This profile of COSE does not use in-message KDF context information as defined in <xref section="5.2" target="RFC9053"/>.
The context header parameters for PartyU (code -21 through -23) and PartyV (code -24 through -26) <bcp14>SHALL NOT</bcp14> be present in any COSE message within this security context.
A side effect of this is that, to satisfy COSE requirements, the "salt" parameter <bcp14>SHALL</bcp14> always be present in a layer when an HKDF is used by the algorithm for that layer.
        </t>
      </section>
      <section anchor="sec-sym-keys">
        <name>Symmetric Keys and Identifiers</name>
        <t>
This section applies when a BIB or BCB uses a shared symmetric key for MAC, encryption, or key-wrap.
When using symmetric keyed algorithms, the security source <bcp14>SHALL</bcp14> include a symmetric key identifier as a signature or recipient header.
The symmetric key identifier <bcp14>SHALL</bcp14> be either a "kid" of <xref target="RFC9052"/> (possibly with "kid context" of <xref target="RFC8613"/>), or an equivalent identifier.
This requirement makes the selection of keys by verifiers and acceptors unambiguous.
        </t>
        <t>
When present, a "kid" parameter is used to uniquely identify a single shared key known to the security source and all expected security verifiers and acceptors.
Specific strategies or mechanisms to generate or ensure uniqueness of "kid" values within some domain of use is outside the scope of this profile.
Specific users of this profile can define such mechanisms specific to their abilities and needs.
        </t>
        <t>
When present, a "kid context" parameter <bcp14>SHALL</bcp14> be used as a correlator with a larger scope than an individual "kid" value.
The use of a "kid context" allows security verifiers and acceptors to correlate using that larger scope even if they cannot match the sibling "kid" value.
For example, a "kid context" can be used to identify a long-lived security association between two entities while an individual "kid" identifies a single shared key agreed within that larger association.
        </t>
      </section>
      <section anchor="sec-asym-keys">
        <name>Asymmetric Key Types and Identifiers</name>
        <t>
This section applies when a BIB uses a public key for verification or key-wrap, or when a BCB uses a public key for encryption or key-wrap.
When using asymmetric keyed algorithms, the security source <bcp14>SHALL</bcp14> include a public key container or public key identifier as a signature or recipient header.
The public key identifier <bcp14>SHALL</bcp14> be either an "x5t" or "x5chain" of <xref target="RFC9360"/>, or "kid" (possibly with "kid context"), or an equivalent identifier.
        </t>
        <t>
When BIB result contains a "x5t" identifier, the security source <bcp14>MAY</bcp14> include an appropriate certificate container ("x5chain" or "x5bag") in a direct COSE header or an additional header security parameter (see <xref target="sec-ASB-param-additional"/>).
When a BIB result contains an "x5chain", the security source <bcp14>SHOULD NOT</bcp14> also include an "x5t" because the first certificate in the chain is implicitly the applicable end-entity certificate.
For a BIB, if all potential security verifiers and acceptors are known to possess related public key and/or certificate data then the public key or additional header parameters can be omitted.
Risks of not including related credential data are described in <xref target="sec-threat-unident-key"/> and <xref target="sec-threat-notrust-key"/>.
        </t>
        <t>
When present, public keys and certificates <bcp14>SHOULD</bcp14> be included as additional header parameters rather than within result COSE messages.
This provides size efficiency when multiple security results are present because they will all be from the same security source and likely share the same public key material.
Security verifiers and acceptors <bcp14>SHALL</bcp14> still process public keys or certificates present in a result message or recipient as applying to that individual COSE level.
        </t>
        <t>
Security verifiers and acceptors <bcp14>SHALL</bcp14> aggregate all COSE Key objects from all parameters within a single BIB or BCB, independent of encoded type or order of parameters.
Because each context contains a single set of security parameters which apply to all results in the same context, security verifiers and acceptors <bcp14>SHALL</bcp14> treat all public keys as being related to the security source itself and potentially applying to every result.
        </t>
      </section>
      <section anchor="sec-asym-keys-policy-rec">
        <name>Policy Recommendations</name>
        <t>
The <bcp14>RECOMMENDED</bcp14> priority policy for including public key identifiers for BIB results is as follows:
        </t>
        <ol>
          <li>When receivers are not known to possess certificate chains, a full chain is included (as an "x5chain").</li>
          <li>When receivers are known to possess root and intermediate CAs, just the end-entity certificate is included (again as an "x5chain").</li>
          <li>When receivers are known to possess associated chains including end-entity certificates, a certificate thumbnail (as an "x5t").</li>
          <li>Some arbitrary identifier is used to correlate to an end-entity certificate (as a "kid" with an optional "kid context").</li>
          <li>The BIB Security Source is used to imply an associated end-entity certificate which identifies that Node ID.</li>
        </ol>
        <t>
When certificates are used for public key data and the end-entity certificate is not explicitly trusted (<em>i.e.</em> pinned), a security verifier or acceptor <bcp14>SHALL</bcp14> perform the certification path validation of <xref target="sec-context-auth-valid-cert"/> up to one or more trusted CA certificates.
Leaving out part of the certification chain can cause a security verifier or acceptor to fail to validate a BIB if the left-out certificates are unknown to the acceptor (see <xref target="sec-threat-notrust-key"/>).
        </t>
        <t>
The <bcp14>RECOMMENDED</bcp14> priority policy for including public key identifiers for BCB results is as follows:
        </t>
        <ol>
          <li>When receivers are known to possess associated end-entity certificates, a certificate thumbnail (as an "x5t").</li>
          <li>Some arbitrary identifier is used to correlate to the private key (as a "kid" with an optional "kid context").</li>
        </ol>
        <t>
Any end-entity certificate associated with a BIB security source or BCB result recipient <bcp14>SHALL</bcp14> adhere to the profile of <xref target="sec-pkix-profile"/>.
        </t>
      </section>
    </section>
    <section anchor="sec-pkix-profile">
      <name>PKIX Certificate Profile</name>
      <t>
This section contains requirements on public key certificates (PKCs) used with the COSE context, while <xref target="sec-asym-keys"/> contains requirements for how such certificates are transported or identified.
The profile here mandates specific data to be present in certificate authority (CA) and end-entity (EE) certificates but does not mandate any specific key types or signing algorithms to be used (see <xref target="sec-ops-alg-choice"/> and <xref target="sec-ops-pkc"/>).
      </t>
      <t>
All end-entity X.509 certificates used for BPSec <bcp14>SHALL</bcp14> conform to <xref target="RFC5280"/>, or any updates or successors to that profile.
      </t>
      <t>
This profile requires Version 3 certificates due to the extensions used by this profile.
Security verifiers and acceptors <bcp14>SHALL</bcp14> reject as invalid Version 1 and Version 2 end-entity certificates.
      </t>
      <t>
Security verifiers and acceptors <bcp14>SHALL</bcp14> accept certificates that contain an empty Subject field or contain a Subject without a Common Name.
Security verifiers and acceptors <bcp14>SHALL</bcp14> use the Subject Alternative Name extension for identity information in end-entity certificates.
      </t>
      <t>
All BPSec end-entity certificates <bcp14>SHALL</bcp14> contain a Basic Constraints extension in accordance with <xref section="4.2.1.9" target="RFC5280"/> marked as critical.
      </t>
      <t>
All BPSec end-entity certificates <bcp14>SHALL</bcp14> contain a Subject Alternative Name extension in accordance with <xref section="4.2.1.1" target="RFC5280"/> marked as critical.
A BPSec end-entity certificate <bcp14>SHALL</bcp14> contain a NODE-ID in its Subject Alternative Name extension which authenticates the Node ID of the security source (for integrity) or a security verifier or acceptor (for confidentiality).
The identifier type NODE-ID is defined in <xref section="4.4.1" target="RFC9174"/>.
      </t>
      <t>
All BPSec CA certificates <bcp14>SHOULD</bcp14> contain both a Subject Key Identifier extension in accordance with <xref section="4.2.1.2" target="RFC5280"/> and an Authority Key Identifier extension in accordance with <xref section="4.2.1.1" target="RFC5280"/>.
All BPSec end-entity certificates <bcp14>SHOULD</bcp14> contain an Authority Key Identifier extension in accordance with <xref section="4.2.1.1" target="RFC5280"/>.
Security verifiers and acceptors <bcp14>SHOULD NOT</bcp14> rely on either a Subject Key Identifier and an Authority Key Identifier being present in any received certificate.
Including key identifiers simplifies the work of an entity needing to assemble a certification chain.
      </t>
      <t>
All BPSec CA certificates <bcp14>SHOULD</bcp14> contain an Extended Key Usage extension in accordance with <xref section="4.2.1.12" target="RFC5280"/>.
When allowed by CA policy, a BPSec end-entity certificate <bcp14>SHALL</bcp14> contain an Extended Key Usage extension in accordance with <xref section="4.2.1.12" target="RFC5280"/>.
When the PKIX Extended Key Usage extension is present, it <bcp14>SHALL</bcp14> contain a key purpose <tt>id-kp-bundleSecurity</tt> of <xref target="IANA-SMI"/>.
The <tt>id-kp-bundleSecurity</tt> purpose <bcp14>MAY</bcp14> be combined with other purposes in the same certificate.
      </t>
      <t>
When allowed by CA policy, a BPSec end-entity certificate <bcp14>SHALL</bcp14> contain a Key Usage extension in accordance with <xref section="4.2.1.3" target="RFC5280"/> marked as critical.
The PKIX Key Usage bits which are consistent with COSE security are: digitalSignature, nonRepudiation, keyEncipherment, and keyAgreement.
The specific algorithms used by COSE messages in security results determine which of those key uses are exercised.
See <xref target="sec-pkix-multiple-certs"/> for discussion of key use policies across multiple certificates.
      </t>
      <t>
A BPSec end-entity certificate <bcp14>MAY</bcp14> contain an Online Certificate Status Protocol (OCSP) URI within an Authority Information Access extension in accordance with <xref section="4.2.2.1" target="RFC5280"/>.
Security verifiers and acceptors are not expected to have continuous internet connectivity sufficient to perform OCSP verification.
      </t>
      <section anchor="sec-pkix-multiple-certs">
        <name>Multiple-Certificate Uses</name>
        <t>
A <bcp14>RECOMMENDED</bcp14> security policy is to limit asymmetric keys (and thus public key certificates) to single uses among the following:
        </t>
        <dl>
          <dt>Bundle transport:</dt>
          <dd>With key uses as defined in the convergence layer specification(s). Transports can require additional Extended Key Usage, such as <tt>id-kp-serverAuth</tt> or <tt>id-kp-clientAuth</tt>.</dd>
          <dt>Block signing:</dt>
          <dd>With key use <tt>digitalSignature</tt> and/or <tt>nonRepudiation</tt>.</dd>
          <dt>Block encryption:</dt>
          <dd>With key use <tt>keyEncipherment</tt> and/or <tt>keyAgreement</tt>.</dd>
        </dl>
        <t>
This policy is the same one recommended by <xref section="6" target="RFC8551"/> for email security and by Section 5.2 of <xref target="NIST-SP800-57"/> more generally.
Effectively this means that a BP node uses separate certificates for transport (e.g., as a TCPCL entity), BIB signing (as a security source), and BCB encryption (as a security acceptor).
        </t>
      </section>
    </section>
    <section anchor="sec-ops">
      <name>Operational Considerations</name>
      <t>
This section explains various operational topics of this BPSec context, based on guidance of the IETF Operations and Management Area Working Group <xref target="RFC5706"/>.
Many of these topics are related to capabilities that are not mandatory to use in the profiles of <xref target="sec-COSE-profile"/> and <xref target="sec-pkix-profile"/>.
Therefore, this section discusses when their uses is appropriate and when it is not.
      </t>
      <section anchor="sec-ops-participating">
        <name>Understanding Participating Nodes</name>
        <t>
For each desired security operation, all security sources, verifiers, and acceptors which process that operation (<em>i.e.</em>, the participating nodes) need to implement and configure aspects of those operations which are carried as part of a security block (<em>i.e.</em>, BPSec parameters and results, COSE message types, and COSE header parameters) as well as aspects which are not part of the security block and are manged on each node (<em>e.g.</em>, key families and key stores, algorithm families and COSE algorithm processing).
For most of the following subsections, understanding the participating nodes and what they each support is critical to managing the use of BPSec COSE operations.
        </t>
        <t>
For example, if any security verifier along the path of a single security operation either does not implement or allow one of the COSE algorithm code points its verification will fail.
Depending upon policy control in that node, it might delete the containing bundle entirely or at least remove the offending security operation.
In either case, the security operation will not reach its desired acceptor and expected behavior will not occur.
        </t>
        <t>
Beyond supporting algorithms, another critical aspect of all participating nodes is access to key material referenced by the security operation.
If any participating node either does not have any needed key, or if a referencing key identifier is modified by an on-path attacker (see <xref target="sec-threat-unident-key"/>), or if the material itself is available but has expired (see <xref target="sec-ops-participating-time"/>) then processing of the operation will fail.
Similar to the example above, if key material is misaligned expected behavior will not occur.
        </t>
        <t>
Operating in a PKIX environment adds additional challenges beyond simple knowledge of end-use key material.
When participating nodes are expected to possess PKCs the use of shorted thumbprints ("x5t" header) can be used to avoid sending large duplicate certificate data.
But if any participating node does not contain the full certificate chain needed for an operation, or if some portion of that chain fails <xref target="sec-context-auth-valid-cert">path validation</xref> then the situation of <xref target="sec-threat-notrust-key"/> occurs and the expected behavior will not occur.
        </t>
        <section anchor="sec-ops-participating-time">
          <name>Time Keeping</name>
          <t>
A special consideration about the participating nodes is the ability to synchronize their time keepers to a sufficient accuracy.
In a PKIX environment this is needed as part of PKC path validation to ensure that all certificates in a path are valid at the reference time (bundle creation time as defined in <xref target="sec-context-auth-valid-cert"/>).
Even in a non-PKIX environment, there is still an expectation that shared keys will have an associated validity time limit used to control time-variant security policy or an associated data volume limit to avoid <xref target="sec-threat-overuse">key overuse</xref>.
          </t>
        </section>
      </section>
      <section anchor="sec-ops-multi-sig">
        <name>Use of Multiple Signatures</name>
        <t>
The COSE profile in this document allows the use of COSE_Sign messages when multiple signatures are to be present in a single result, but it does not mandate when or why multiple signatures would be used by a security source.
The following subsections give some examples of their use.
        </t>
        <section anchor="sec-ops-multi-sig-creds">
          <name>Multiple Credentials</name>
          <t>
One possible need for multiple signatures is when the same security source is identified by multiple credentials (<em>i.e.</em>, EE PKCs) and thus associated with multiple private signing keys resulting in multiple distinct signatures (with associated public key identifiers).
This need could manifest when the participating nodes (and their credentials) span multiple security or administrative domains, and a single security operation needs to be verified by all of the nodes.
          </t>
          <t>
This could also manifest during overlapping credential/key validity time intervals, when an older credential is about to expire and a new credential has become valid.
When not all participating nodes can be guaranteed to have either the old or new credential but possibly not both, signing with multiple credentials ensures that each node will be able to verify using one of them.
          </t>
        </section>
        <section anchor="sec-ops-multi-sig-algs">
          <name>Multiple Algorithms</name>
          <t>
Another possible need for multiple signatures is to provide different signing algorithms for the same security operation.
This could be because not all of the participating nodes support the same algorithms but there is a set that is known to have at least one algorithm supported by each node.
          </t>
          <t>
This could also be used to provide parallel signatures (one traditional and one post-quantum) for a single target, which is not the same as a "hybrid" signature <xref target="RFC9794"/> <xref target="I-D.ietf-pquip-hybrid-signature-spectrums"/>.
This form of parallel signature in COSE is "separable" and can only be enforced by verifier policy requiring a specific valid signing set because an on-path attacker can simply remove one or more of the signatures and the others will still be valid.
          </t>
        </section>
      </section>
      <section anchor="sec-ops-multi-recip">
        <name>Use of Multiple Recipients</name>
        <t>
The COSE profile in this document allows the use of COSE_Mac and COSE_Encrypt messages when multiple recipients are to be present in a single result, but it does not mandate when or why multiple recipients would be used by a security source.
The following subsections give some examples of their use.
        </t>
        <t>
All of these multiple-recipient cases require the recipient layer to use key wrapping/encryption of the same content key, which means that the recipient algorithms cannot use a KDF as that would derive a different key for each recipient.
        </t>
        <section anchor="sec-ops-multi-recip-creds">
          <name>Multiple Credentials</name>
          <t>
One possible need for multiple recipients is when the same security acceptor is identified by multiple credentials (<em>i.e.</em>, EE PKCs) and thus associated with multiple private unwrapping/decryption keys resulting in multiple distinct wrapped keys (with associated public key identifiers).
This situation could occur for the same reasons as the multi-credential use case for signing in <xref target="sec-ops-multi-sig-creds"/>.
          </t>
        </section>
        <section anchor="sec-ops-multi-recip-nodes">
          <name>Intermediate Verifying Nodes</name>
          <t>
The simple case of point-to-point confidentiality involves a shared secret between exactly two participating nodes (the source and acceptor).
When there are intermediate nodes that need to be verifiers of the operation and group keying is not available, one option is to use a single CEK for the operation and then wrap/encrypt the CEK using multiple recipients each directed at a single verifying or accepting node.
          </t>
        </section>
      </section>
      <section anchor="sec-ops-alg-choice">
        <name>Choice of Key and Algorithm Families</name>
        <t>
The <xref target="sec-COSE-profile">COSE profile</xref> and <xref target="sec-pkix-profile">PKIX profile</xref> in this document narrow down the wide variety of algorithm families and key-material families available within both the COSE and PKIX environments.
The subsections under <xref target="sec-interop-alg"/> are organized by key family precisely because the choice of an acceptable key family narrows down the set of compatible COSE algorithms to a small number of options.
        </t>
        <t>
It is expected that the ultimate choice of which families are used in actual security operations will be determined by a small number of least-common acceptable choices among the various BP nodes acting as source, verifier, or acceptor roles for those operations.
Each of those nodes will be administered by some controlling entity which itself will need to adhere to both interoperability requirements as well as security conformance requirements (both general and mission-specific).
        </t>
        <t>
For example, if the constraints are ECC keys using NIST curves meeting CNSA 1.0 minimum strength then only one integrity algorithm is available: ESP384 (-51).
If there is a need for forward secrecy of confidentiality targets, then only one encryption recipient algorithm is available: ECDH-ES+HKDF-512 (-26).
In these cases the choice of algorithm is completely determined by operational constraints and no other metric of suitability is needed.
        </t>
        <aside>
          <t>
There is an expectation that the BPSec COSE interoperability minimums will be expanded in the future to handle yet emerging post-quantum algorithm needs.
          </t>
        </aside>
        <t>
Separate from the choice of desired COSE algorithm from the security source is a choice of allowed algorithm(s) to be enforced by security verifiers and acceptors.
A verifier or acceptor which does not constrain allowed algorithms is vulnerable to a <xref target="sec-threat-downgrade">downgrade attack</xref>.
        </t>
      </section>
      <section anchor="sec-ops-pkc">
        <name>Use of Public Key Certificates</name>
        <t>
Similar to how the choice of algorithm families is driven by administrative constraints, decisions regarding whether and how to use public key certificates with this BPSec context are expected to be heavily influenced by the needs and constraints of the administering entities.
        </t>
        <t>
Much of the complexity of PKIX is in how its various extensions can be combined by issuers and how they must be validated by security processors.
It is expected that each PKIX environment will have detailed and specific needs and constraints for extensions for administrative purposes beyond those needed by this specification.
There are also algorithm-specific profiles, such as the one for CNSA 1.0 conformance <xref target="RFC8603"/>.
        </t>
        <t>
For example, if a security source provides integrity with an "x5t" parameter identifying an associated end-entity certificate, then all possible security verifiers and acceptors of that operation need to be able to handle and validate that entire referenced certificate chain and each of its contained PKIX extensions.
        </t>
      </section>
      <section anchor="sec-ops-kid-choice">
        <name>Choice of Key Identifiers</name>
        <t>
Similar to the algorithm family choice in <xref target="sec-ops-alg-choice"/>, the choice of which key identifier to use for a specific security operation (among those described in <xref target="sec-sym-keys"/> and <xref target="sec-asym-keys"/>) is expected to be based on least-common acceptable choices among the set of participating nodes.
        </t>
        <t>
For example if overall ASB and total bundle size are driving concerns, the use of short-length narrow-scoped "kid" could be more favorable over universally-unique (but longer) identifiers such as hash-based thumbprints <xref target="RFC9679"/>.
Another example is if PKCs are available and pre-hashed for management reasons, then their thumbprints are readily available for "x5t" identifiers which can allow easy correlation between the ASB content, in-node logging, and network orchestration configuration.
        </t>
        <t>
Many of the "conditional" header parameters in <xref target="tab-interop-hdrs"/> depend on the choice of acceptable key identifier for a particular security operation.
Because of this, a node or mission with constraints on public key certificate use and identification will necessarily have a limited need for key-identifying parameters.
        </t>
        <t>
In any case, an inherited requirement from COSE <xref section="3.1" target="RFC9052"/> is that "kid" values cannot be assumed by any processor to be unique and full validity of a COSE message depends on successful verification of (or decryption for) the entire message.
        </t>
      </section>
      <section anchor="sec-ops-key-mgmt">
        <name>General Key Management</name>
        <t>
The scope of this document explicitly excludes specifying management strategies or mechanisms for symmetric keys, asymmetric keys, and public key certificates.
However, this document does provide recommendations and constraints regarding when to include <xref target="sec-asym-keys">certificates or thumbprints</xref>, <xref target="sec-pkix-multiple-certs">single-use keys</xref>, and considerations related to <xref target="sec-threat-overuse">key overuse</xref>.
        </t>
        <t>
There is a broader concern, likely spanning multiple administrative domains, regarding how to distribute and manage keys and/or PKCs needed to support normal BPSec operations.
This is also not unique to this COSE security context, and will apply equally to any security operations using equivalent key material or identity-binding credentials.
        </t>
        <t>
Management of keys and certificates includes the entire life-cycle of those items, including distributing them to participating nodes, upkeep of time-limited items such as certificate chains, and decommissioning them after their effective lifetime has ended.
        </t>
      </section>
      <section anchor="sec-ops-additional-hdrs">
        <name>Use of Additional Header Maps</name>
        <t>
The <xref target="sec-ASB-param-additional">additional header map parameters</xref> can be used to remove redundancies from multiple COSE messages in the same security block, but does not necessarily save encoded size (depending on if and which common header parameters are present in those COSE messages) and does add processing complexity to security verifiers and acceptors.
        </t>
        <t>
Because these parameters are optional-to-use, a simplification which can apply within an administrative domain or across multiple domains is a restriction to avoid the use of additional header map parameters when they are not expected to provide any operational benefit.
For BPSec entities, this does not imply that these parameters are optional-to-implement; they can still be present in security blocks received from unexpected sources.
It is a more general implementation and configuration matter for how to handle unexpected or unwanted (but otherwise valid) security parameters in any node.
        </t>
        <t>
Because the additional protected header parameter is included unconditionally in the <xref target="sec-secctx-aad">external AAD</xref>, it is handled equivalently to the in-COSE-layer protected header map.
This means that the same considerations for including header parameters in either protected or unprotected in-COSE-layer header map apply to the additional header maps.
Individual header parameters define their own requirements for protection when needed.
        </t>
      </section>
      <section anchor="sec-ops-aad-scope">
        <name>Choice of AAD Scope</name>
        <t>
The security source of every BPSec security operation using the COSE context can choose a specific <xref target="sec-ASB-param-AAD-scope">AAD Scope parameter</xref> appropriate for that operation.
        </t>
        <t>
The default AAD Scope, used when no parameter is present, binds the security operation to the primary block of the bundle, the security block metadata and Security Source EID for the operation, and the target block metadata.
Together these tightly constrain the ability of an attacker to replay either the target or security block (see <xref target="sec-threat-block-replay"/>).
        </t>
        <t>
The minimum AAD Scope still includes the Security Source EID to ensure that the operation is always bound to its source (by identity, not by any proof-of-possession).
        </t>
        <t>
For specific cases, possibly depending on how tightly coupled the cryptographic processing is with the BP and BPSec processing or what kind of block rearranging is expected to happen by middleboxes, the AAD Scope can be reduced to allow changes to either the security block or target block metadata.
It is <bcp14>RECOMMENDED</bcp14> to always include the primary block (number zero) in the AAD Scope to protect against replay attacks.
        </t>
        <t>
For other cases, where several blocks are expected to have similar lifetimes and there is a desire to cover them all by a single security operation, the AAD Scope can be expanded to include not just the target block but other blocks in the same bundle.
These cases need more careful consideration (see <xref target="sec-threat-aad-mod"/>) due to the more complex inter-relationships between all of the blocks involved in such a security operation.
        </t>
        <section>
          <name>Covered Block Life Cycle Examples</name>
          <t>
This section contains examples which illustrate the effect and side-effects of AAD covering blocks beyond than the default scope.
The situations illustrated in these examples can arise when security operations are sourced and accepted throughout a bundle's lifetime as it traverses across different administrative and security domains.
          </t>
          <t>
In these examples, the edge-ward nodes (N10, N11, N12, and N13) are operated by one administrative domain and the interior nodes (N20, N21, N22) are operated by a different domain as part of a transit network.
For the sake of simplicity, because this example is not about routing or time variance, these nodes are connected in a linear topology aligned with a single bundle flow from N10 to N13.
          </t>
          <figure anchor="fig-aad-scope-example-topo">
            <name>Simplified linear path topology</name>
            <artwork align="center" type="ascii-art"><![CDATA[
   User net         Transit net        User net
  .---------.    .--------------.    .---------.
 /           \  /                \  /           \
|  N10...N11......N20...N21...N22.....N12...N13  |
 \           /  \                /  \           /
  '---------'    '--------------'    '---------'
]]></artwork>
          </figure>
          <t>
The two examples in this section refer to the following set of security operations in two security blocks.
          </t>
          <ul>
            <li>Block number 2: a BIB containing two security operations targeting the primary block and the payload block. These operations are added at the bundle source (N10) and are intended to have a lifetime identical to the bundle itself (accepted at destination N13). They also have verifiers in routers N11 and N12.</li>
            <li>Block number 3: a BIB containing one operation covering (either as target or as AAD) block number 2 and the payload block. This operation has a different set of participating nodes: it is added by some gateway middlebox (N20) as it enters the transit network, is verified by N21, and is accepted by N22 (which results in block removal) as it leaves the transit network.</li>
          </ul>
          <t>
This is depicted in <xref target="fig-aad-scope-example-success"/> with an abstract timeline indicating both wall-clock time and forwarding-path progress.
In this situation, all security operation verification (indicated by "*") and acceptance (causing removal indicated by "R") succeed and the security behaves as expected.
          </t>
          <figure anchor="fig-aad-scope-example-success">
            <name>Successful security timeline</name>
            <artwork align="center" type="ascii-art"><![CDATA[
+-----------+
|Primary #0 +-------------------------------------------->
+-----------+
      |       +-----------+
      |       | BIB    #3 +---------*-------R
      |       +-----------+         |       |
+-----------+       |               |       |
| BIB    #2 +--*----------------------------------*----R
+-----------+  |    |               |       |     |    |
+-----------+  |    |               |       |     |    |
|Payload #1 +-------------------------------------------->
+-----------+  |    |               |       |     |    |
      |        |    |               |       |     |    |
------S--------V----S---------------V-------A-----V----A->
     N10      N11  N20             N21     N22   N12  N13
                       Timeline
]]></artwork>
          </figure>
          <t>
In an alternative example of <xref target="fig-aad-scope-example-failure"/> there is a middlebox (N30) which accepts (or simply removes) one of the security operations within block number 2 during the lifetime of covering block number 3.
Because the middlebox removes the operation it alters the BTSD of block number 2 to remove the associated target and results from its ASB.
Later verification of covering security block number 3 will fail (indicated by "X").
Depending upon security policy, the entire bundle might be deleted by N21 or N22 and never progress further along the path.
This second example results in security failure, but it is also caused by a middlebox affecting the lifetime of a security operation outside of its intended use.
          </t>
          <figure anchor="fig-aad-scope-example-failure">
            <name>Failing security timeline</name>
            <artwork align="center" type="ascii-art"><![CDATA[
+-----------+
|Primary #0 +-------------------------------------------->
+-----------+
      |       +-----------+
      |       | BIB    #3 +---------X-------X
      |       +-----------+         |       |
+-----------+       |               |       |
| BIB    #2 +--*-------------M--------------------*----R
+-----------+  |    |        |      |       |     |    |
+-----------+  |    |        |      |       |     |    |
|Payload #1 +-------------------------------------------->
+-----------+  |    |        |      |       |     |    |
      |        |    |        |      |       |     |    |
------S--------V----S--------A------V-------A-----V----A->
     N10      N11  N20      N30    N21     N22   N12  N13
                       Timeline
]]></artwork>
          </figure>
          <t>
Although these examples depict a linear topology with a predictable path, the logic of multiple interacting security domains is not confined to a linear situation.
The same logic can apply when using either group symmetric keys (distributed to all participating nodes) with MAC integrity or using PKIX certificates (distributed to participating nodes) with signature integrity.
In those cases the path can be arbitrary and any intermediate node in each security domain can act as an integrity verifier (for those security operations meant for its security domain).
          </t>
        </section>
      </section>
      <section anchor="sec-ops-rng">
        <name>Random and Unique Numbers for COSE</name>
        <t>
There are several points during processing when a security source must generate either random or unique numbers to satisfy cryptographic algorithm requirements.
In all cases, the proper functioning of COSE assumes the source entity has a (pseudo-)random number generator (RNG) sufficient to meet the security needs of each algorithm.
        </t>
        <t>
For the interoperability profile in <xref target="sec-interop-alg"/> these include:
        </t>
        <dl newline="true">
          <dt>KID generation:</dt>
          <dd>
This is needed for cases where the KID is not generated in some deterministic way from the key itself (see <xref target="sec-ops-kid-choice"/>).
Each KID value does not need to be universally unique, but is expected to be unique within the scope of each Security Source EID for the sake of logging and auditing.
Reuse of KID values for a single Security Source is permitted but is <bcp14>NOT RECOMMENDED</bcp14> in order to avoid confusion of comparing traffic and node logs across time.
          </dd>
          <dt>IV generation:</dt>
          <dd>
This is needed for symmetric-key AEAD algorithms (A256GCM in this case).
The value is either a direct "IV" parameter or as a "Base IV" from a COSE key paired with a "Partial IV" parameter.
In either case, the algorithm requirement is for uniqueness of the key-and-IV pair not for randomness of the IV itself.
The length of each full IV is determined by the AEAD algorithm.
An IV or Partial IV <bcp14>MAY</bcp14> be generated by a deterministic mechanism associated with a specific content key only when the generating entity is the sole security source associated with that content key.
          </dd>
          <dt>KDF salt generation:</dt>
          <dd>
This is needed for KDF recipients (either direct+HKDF or the ECDH algorithms).
In either case, similar to IV generation, the requirement for a salt is to be unique within its derivation context.
Because of the KDF context defined in <xref target="sec-secctx-kdfctx"/>, this means the salt is unique for each parent key and Security Source EID.
The length of each salt is recommended by COSE to be at least as large as the hash output for HKDF.
A salt <bcp14>MAY</bcp14> be generated by a deterministic mechanism associated with a specific parent key (symmetric or ECDH-SS) only when the generating entity is the sole security source associated with that parent key.
          </dd>
          <dt>Unique content key generation:</dt>
          <dd>
This is needed for key-wrap recipients (either direct+A256KW or ECDH+A256KW or RSAES-OAEP algorithms).
Although the requirement here is for uniqueness, the expected mechanism of generating ephemeral content keys is to use an RNG or a KDF internal to the security source.
          </dd>
          <dt>Ephemeral ECDH key generation:</dt>
          <dd>
This is needed for the ECDH-ES algorithms to ensure that the sender key is truly ephemeral and enable forward secrecy.
Although the requirement here is for uniqueness, the expected mechanism of generating ephemeral ECDH keys is to use an RNG.
          </dd>
        </dl>
      </section>
    </section>
    <section anchor="sec-security">
      <name>Security Considerations</name>
      <t>
This section separates security considerations into threat categories based on guidance of BCP 72 <xref target="RFC3552"/>.
      </t>
      <section anchor="sec-threat-block-replay">
        <name>Threat: BPSec Block Replay</name>
        <t>
The bundle's primary block contains fields which uniquely identify a bundle: the Source Node ID, Creation Timestamp, and fragment parameters (see <xref section="4.3.1" target="RFC9171"/>).
These same fields are used to correlate Administrative Records with the bundles for which the records were generated.
Including the primary block in the AAD Scope for integrity and confidentiality (see <xref target="sec-ASB-param-AAD-scope"/>) binds the verification of the secured block to its parent bundle and disallows replay of any block with its BIB or BCB.
        </t>
        <t>
This profile of COSE limits the encryption algorithms to only AEAD in order to include the context of the encrypted data as AAD.
If an agent mistakenly allows the use of non-AEAD encryption when decrypting and verifying a BCB, the possibility of block replay attack is present.
        </t>
      </section>
      <section anchor="sec-threat-untrust-cert">
        <name>Threat: Untrusted End-Entity Certificate</name>
        <t>
The profile in <xref target="sec-context-auth"/> uses end-entity certificates chained up to a trusted root CA, where each certificate has a specific validity time interval.
        </t>
        <t>
A security verifier or acceptor needs to assemble an entire certificate chain in order to validate the use of an end-entity certificate.
A security source can include a certificate set which does not contain the full chain, possibly excluding intermediate or root CAs.
In an environment where security verifiers and acceptors are known to already contain needed root and intermediate CAs there is no need to include those CAs, but this has a risk of a relying node not actually having one of the needed CAs.
        </t>
        <t>
A security verifier or acceptor needs to use the bundle creation time when assembling a certificate chain and and validating it.
Because of this, a security source needs to use the bundle creation time as the specific instant for choosing appropriate certificate(s) based on their validity time interval.
The selection of a certificate outside of its validity time period will cause the entire security operation to be unusable.
        </t>
      </section>
      <section>
        <name>Threat: Certificate Validation Vulnerabilities</name>
        <t>
Even when a security acceptor is operating properly an attacker can attempt to exploit vulnerabilities within certificate check algorithms or configuration to authenticate using an invalid certificate.
An invalid certificate exploit could lead to higher-level security issues and/or denial of service to the Node ID being impersonated.
        </t>
        <t>
There are many reasons, described in PKIX specifications <xref target="RFC5280"/> and <xref target="RFC6125"/>, why a certificate can fail to validate, including using the certificate outside of its validity time interval, using purposes for which it was not authorized, or using it after it has been revoked by its CA.
Validating a certificate is a complex task and can require network connectivity outside of the primary BP convergence layer network path(s) if a mechanism such as OCSP <xref target="RFC6960"/> is used by the CA.
The configuration and use of particular certificate validation methods are outside of the scope of this document.
        </t>
      </section>
      <section anchor="sec-threat-node-impersonation">
        <name>Threat: Security Source Impersonation</name>
        <t>
When certificates are referenced by BIB results it is possible that the certificate does not contain a NODE-ID or does contain one but has a mismatch with the actual security source (see <xref target="sec-pkix-env"/>).
Having a CA-validated certificate does not alone guarantee the identity of the security source from which the certificate is provided; additional validation procedures in <xref target="sec-context-auth"/> bind the Node ID based on the contents of the certificate.
        </t>
      </section>
      <section anchor="sec-threat-unident-key">
        <name>Threat: Unidentifiable Key</name>
        <t>
The profile in <xref target="sec-interop-alg"/> recommends key identifiers when possible and the parameters in section <xref target="sec-ASB-parameters"/> allow encoding public keys where available.
If the application using a COSE Integrity or COSE Confidentiality context leaves out key identification data (in a COSE recipient structure), a security verifier or acceptor for those BPSec blocks only has the primary block available to use when verifying or decrypting the target block.
This leads to a situation, identified in BPSec Security Considerations, where a signature is verified to be valid but not from the expected Security Source.
        </t>
        <t>
Because the key identifier headers are unprotected (see <xref target="sec-asym-keys"/>), there is still the possibility that an active attacker removes or alters key identifier(s) in the result.
This can cause a security verifier or acceptor to not be able to properly verify a valid signature or not use the correct private key to decrypt valid ciphertext.
        </t>
      </section>
      <section anchor="sec-threat-notrust-key">
        <name>Threat: Non-Trusted Public Key</name>
        <t>
The profile in <xref target="sec-interop-alg"/> allows the use of PKIX which typically involves end-entity certificates chained up to a trusted root CA.
A BIB can reference or contain end-entity certificates not previously known to a security acceptor but the acceptor can still trust the certificate by verifying it up to a trusted CA.
In an environment where security verifiers and acceptors are known to already contain needed root and intermediate CAs there is no need to include those CAs in a proper chain within the security parameters, but this has a risk of an acceptor not actually having one of the needed CAs.
        </t>
        <t>
Because the security parameters are not included as AAD, there is still the possibility that an active attacker removes or alters certification chain data in the parameters.
This can cause a security verifier or acceptor to be able to verify a valid signature but not trust the public key used to perform the verification.
        </t>
      </section>
      <section>
        <name>Threat: Passive Leak of Key Material</name>
        <t>
It is important that the key requirements of <xref target="sec-ASB-parameters"/> apply only to public keys and PKIX certificates.
Including non-public key material in ASB parameters will expose that material in the bundle data and over the bundle convergence layer during transport.
        </t>
      </section>
      <section anchor="sec-threat-overuse">
        <name>Threat: Key Overuse</name>
        <t>
For many symmetric keyed algorithms (but none of the asymmetric algorithms included in this specification) there are limits to the number of operations or total size of plaintext data processed with a single key.
These limits are discussed in the specifications that register COSE algorithm code points and will not be repeated here.
For example, AES-GCM imposes strict limits on the total plaintext processed for each key based on the security strength needed by the application.
        </t>
        <t>
Algorithms can also impose limits on the number of forgery attempts (observed as failed operations) or size of failed ciphertext associated with a single key.
These limits are to avoid the ability of an on-path attacker to forge messages based on that key.
For example, AES-GCM imposes a (large) limit on the number of forgery attempts  for a single key.
        </t>
        <t>
Some algorithms are more or less vulnerable to reuse of pairs of key-and-IV.
These limits are also discussed in specifications that register COSE algorithm code points.
For example, AES-GCM imposes a strict limit that a single pair never be used for more than one encryption operation.
        </t>
        <t>
Specific details covering modern AEAD algorithms are documented and explained in a Crypto Forum Research Group draft <xref target="I-D.irtf-cfrg-aead-limits"/>.
        </t>
      </section>
      <section anchor="sec-threat-downgrade">
        <name>Threat: Algorithm Downgrade</name>
        <t>
The message and processing structure of COSE includes in-band algorithm identifiers as a protected header parameter.
One possible attack on COSE generally is an on-path attacker manipulating an algorithm identifier to achieve a downgrade to an algorithm which is vulnerable to further attacks or collisions.
        </t>
        <t>
For COSE algorithms which make use of a KDF, the <tt>COSE_KDF_Context</tt> includes as its first item the explicit algorithm identifier of the lower COSE layer to bind each KDF-using recipient to that lower layer algorithm.
Other algorithms, such as those which use key wrapping (A256KW and ECDH+A256KW) or key encryption (RSAES-OAEP) do not bind the content key to the content encryption algorithm and are possibly vulnerable to a downgrade.
        </t>
        <t>
Because this profile of COSE mandates the use of AEAD encryption algorithms for the COSE payload (layer 0) it is ensured that the content encryption algorithm is protected, but there is still a possibility that two different AEAD algorithms have a collision when the entire COSE message and its detached payload can be modified by an attacker.
It is <bcp14>RECOMMENDED</bcp14> that verifiers and acceptors enforce narrow constraints on allowed COSE algorithms in all COSE layers.
It is an implementation matter to choose and configure allowed algorithms on participating nodes.
        </t>
      </section>
      <section anchor="sec-threat-algo-vuln">
        <name>Threat: Algorithm Vulnerabilities</name>
        <t>
Because this use of COSE leaves the specific algorithms chosen for BIB and BCB use up to the applications securing bundle data, it is important to use only COSE algorithms which are marked as "recommended" in the IANA registry <xref target="IANA-COSE"/>.
        </t>
        <t>
Specifically for the case of vulnerability to a cryptographically relevant quantum computer, algorithms for signing and key encapsulation have been published by NIST, and identified in <xref target="CNSA2"/>, but are not all available as COSE code points allocated by published standards.
        </t>
      </section>
      <section>
        <name>Inherited Security Considerations</name>
        <t>
All of the security considerations of the underlying BPSec <xref target="RFC9172"/> apply to this security context.
Because this security context uses whole COSE messages and inherits all COSE processing, all of the security considerations of <xref target="RFC9052"/> apply to this security context.
When public key certificates are used, all of the security considerations of <xref target="RFC5280"/> and any other narrowing PKIX profile apply to this security context.
        </t>
      </section>
      <section anchor="sec-threat-aad-mod">
        <name>AAD-Covered Block Modification</name>
        <t>
The <xref target="sec-ASB-param-AAD-scope">AAD Scope parameter</xref> can be used to refer to any other block within the same bundle (by its unique block number) at the time the associated security operation is added to a bundle.
Because of this, if any block within the AAD coverage is modified (by any node along the bundle's forwarding path) in a way which affects the generated <xref target="sec-secctx-aad">AAD value</xref>, including its removal, that will cause verification or acceptance of the security operation to fail.
        </t>
        <t>
One reason why such a modification would be made is that the other block has an expected lifetime shorter than the security operation.
For example, a Previous Node block (<xref section="4.4.1" target="RFC9171"/>) is expected to be removed or replaced at each hop.
The AAD Scope parameter <bcp14>SHALL NOT</bcp14> reference any other block with an expected lifetime shorter than the containing security operation.
        </t>
        <t>
A reason for a block to be removed is if it has its block processing control flags (<xref section="4.2.4" target="RFC9171"/>) have the flag set indicating "Discard block if it can't be processed" and the block type or type-specific data cannot be handled by any node along the forwarding path.
The AAD Scope parameter <bcp14>SHALL NOT</bcp14> reference any other block having block processing control flags with the flag set indicating "Discard block if it can't be processed" unless it is expected that all possible receiving nodes can process the associated block type during the lifetime of the containing security operation.
        </t>
        <t>
A reason for modification of an AAD-covered block metadata is when a middlebox chooses to modify its block processing control flags because of local policy.
For example, a firewall which does not allow specific block flags to be set and forces them to not be set.
The AAD Scope parameter <bcp14>SHALL NOT</bcp14> reference any other block using the flag <tt>AAD-metadata</tt> (<xref target="tab-AAD-scope-flags"/>) if that other block is expected to have its block processing control flags modified by a middlebox during the lifetime of the containing security operation.
        </t>
        <t>
A reason for modification of an AAD-covered BTSD is when the other block is designed to be updated along the forwarding path.
For example, a Hop Count block (<xref section="4.4.3" target="RFC9171"/>) is expected to be modified as the bundle is forwarded by each node.
Another example is an other BIB or BCB containing a security operation which is expected to be accepted (<em>i.e.</em>, removed from the other security block) by some middlebox independently of the AAD-covering security operation.
The AAD Scope parameter <bcp14>SHALL NOT</bcp14> reference any other block using the flag <tt>AAD-btsd</tt> (<xref target="tab-AAD-scope-flags"/>) if that other block is expected to have its BTSD modified by a middlebox during the lifetime of the containing security operation.
        </t>
        <t>
The requirement conditions above apply only to closed networks with well-controlled forwarding topology and uniform block-type support.
In open or evolving BP deployments, security sources cannot rely on expectations for the presence or capabilities of middleboxes.
        </t>
        <t>
Compliance with the requirement conditions in this section is the responsibility of each security source.
Because block processing control flags are included in AAD metadata, a middlebox cannot alter a bundle by adjusting flags on an AAD-covered block.
A security verifier or acceptor that detects an AAD Scope reference to a block with the "Discard block if it
can't be processed" flag set <bcp14>SHOULD</bcp14> log the violation, and <bcp14>MAY</bcp14> reject reception the bundle in accordance with local policy.
        </t>
      </section>
    </section>
    <section anchor="sec-iana">
      <name>IANA Considerations</name>
      <t>
Registration procedures referred to in this section are defined in <xref target="RFC8126"/>.
      </t>
      <section anchor="sec-iana-bundle">
        <name>Bundle Protocol</name>
        <t>
Within the "Bundle Protocol" registry group <xref target="IANA-BUNDLE"/>, the following entry has been added to the "BPSec Security Context Identifiers" registry.
        </t>
        <table>
          <name>BPSec Security Context Identifiers</name>
          <thead>
            <tr>
              <th>Value</th>
              <th>Description</th>
              <th>Reference</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>3</td>
              <td>COSE</td>
              <td>[This specification]</td>
            </tr>
          </tbody>
        </table>
        <t>
Within the "Bundle Protocol" registry group <xref target="IANA-BUNDLE"/>, the IANA has created and now maintains a new registry named "BPSec COSE AAD Scope Special Keys".
<xref target="tab-iana-aad-scope-keys"/> shows the initial values for this registry.
        </t>
        <t>
The registration policy for this registry is Specification Required.
Specifications of new entries need to define how they relate to AAD generation procedure of <xref target="sec-secctx-aad"/>.
        </t>
        <t>
The value range is negative 16-bit integer.
This value range is combined with the non-negative 64-bit integer block numbers for the AAD Scope key domain (<xref target="sec-ASB-param-AAD-scope"/>).
        </t>
        <table anchor="tab-iana-aad-scope-keys">
          <name>BPSec COSE AAD Scope Special Keys</name>
          <thead>
            <tr>
              <th>Value</th>
              <th>Name</th>
              <th>Reference</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>-1</td>
              <td>Target block</td>
              <td>[This specification]</td>
            </tr>
            <tr>
              <td>-2</td>
              <td>Security block</td>
              <td>[This specification]</td>
            </tr>
            <tr>
              <td>-3 to -238</td>
              <td>Unassigned</td>
              <td></td>
            </tr>
            <tr>
              <td>-239 to -240</td>
              <td>Reserved for Experimental Use</td>
              <td>[This specification]</td>
            </tr>
            <tr>
              <td>-241 to -256</td>
              <td>Reserved for Private Use</td>
              <td>[This specification]</td>
            </tr>
            <tr>
              <td>-257 to -65536</td>
              <td>Reserved</td>
              <td></td>
            </tr>
          </tbody>
        </table>
        <t>
Within the "Bundle Protocol" registry group <xref target="IANA-BUNDLE"/>, the IANA has created and now maintains a new registry named "BPSec COSE AAD Scope Flags".
<xref target="tab-iana-aad-scope-flags"/> shows the initial values for this registry.
        </t>
        <t>
The registration policy for this registry is Specification Required.
Specifications of new entries need to define how they relate to AAD generation procedure of <xref target="sec-secctx-aad"/>.
        </t>
        <t>
The value range is a bit position within an unsigned 64-bit integer.
        </t>
        <table anchor="tab-iana-aad-scope-flags">
          <name>BPSec COSE AAD Scope Flags</name>
          <thead>
            <tr>
              <th><t>Bit Position</t><t>(from LSbit)</t></th>
              <th>Name</th>
              <th>Reference</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>0</td>
              <td><tt>AAD-metadata</tt></td>
              <td>[This specification]</td>
            </tr>
            <tr>
              <td>1</td>
              <td><tt>AAD-btsd</tt></td>
              <td>[This specification]</td>
            </tr>
            <tr>
              <td>2-64</td>
              <td>Unassigned</td>
              <td></td>
            </tr>
          </tbody>
        </table>
      </section>
    </section>
  </middle>
  <back>
    <displayreference target="CCSDS-SDLS" to="SDLS"/>
    <displayreference target="NIST-FIPS-140" to="FIPS-140"/>
    <displayreference target="NIST-SP800-57" to="SP800-57"/>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <reference anchor="IANA-BUNDLE" target="https://www.iana.org/assignments/bundle/">
          <front>
            <title>Bundle Protocol</title>
            <author>
              <organization>IANA</organization>
            </author>
            <date/>
          </front>
        </reference>
        <reference anchor="IANA-COSE" target="https://www.iana.org/assignments/cose/">
          <front>
            <title>CBOR Object Signing and Encryption (COSE)</title>
            <author>
              <organization>IANA</organization>
            </author>
            <date/>
          </front>
        </reference>
        <reference anchor="IANA-SMI" target="https://www.iana.org/assignments/smi-numbers/">
          <front>
            <title>Structure of Management Information (SMI) Numbers</title>
            <author>
              <organization>IANA</organization>
            </author>
            <date/>
          </front>
        </reference>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5280.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.6125.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.6960.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8126.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8230.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8551.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8610.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8613.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8949.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9052.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9053.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9172.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9174.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9360.xml"/>
      </references>
      <references>
        <name>Informative References</name>
        <reference anchor="NIST-SP800-57" target="https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r5.pdf">
          <front>
            <title>Recommendation for Key Management - Part 1: General</title>
            <seriesInfo name="NIST SP" value="800-57"/>
            <author>
              <organization>US National Institute of Standards and Technology</organization>
            </author>
            <date month="May" year="2020"/>
          </front>
        </reference>
        <reference anchor="NIST-FIPS-140" target="https://doi.org/10.6028/NIST.FIPS.140-3">
          <front>
            <title>Security Requirements for Cryptographic Modules</title>
            <seriesInfo name="FIPS" value="140-3"/>
            <author>
              <organization>US National Institute of Standards and Technology</organization>
            </author>
            <date month="March" year="2019"/>
          </front>
        </reference>
        <reference anchor="CCSDS-SDLS" target="https://public.ccsds.org/Pubs/350x5g2.pdf">
          <front>
            <title>Space Data Link Security Protocol - Summary of Concept and Rationale</title>
            <seriesInfo name="CCSDS" value="350.5-G-2"/>
            <author>
              <organization>Consultative Committee for Space Data Systems</organization>
            </author>
            <date month="January" year="2024"/>
          </front>
        </reference>
        <reference anchor="CNSA1" target="">
          <front>
            <title>Use of Public Standards for Secure Information Sharing</title>
            <seriesInfo name="CNSS Policy" value="15"/>
            <author>
              <organization>US Committee on National Security Systems</organization>
            </author>
            <date day="20" month="October" year="2016"/>
          </front>
        </reference>
        <reference anchor="CNSA2" target="">
          <front>
            <title>Use of Public Standards for Secure Information Sharing</title>
            <seriesInfo name="CNSS Policy" value="15"/>
            <author>
              <organization>US Committee on National Security Systems</organization>
            </author>
            <date month="December" year="2024"/>
          </front>
        </reference>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.3552.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.5706.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.7942.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.8603.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9171.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9173.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9679.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9794.xml"/>
        <xi:include href="https://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.9964.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-pquip-hybrid-signature-spectrums.xml"/>
        <xi:include href="https://bib.ietf.org/public/rfc/bibxml3/reference.I-D.irtf-cfrg-aead-limits.xml"/>
        <reference anchor="github-dtn-bpsec-cose" target="https://github.com/BrianSipos/dtn-bpsec-cose/">
          <front>
            <title>Bundle Protocol Security (BPSec) COSE Context</title>
            <author fullname="Brian Sipos" initials="B." surname="Sipos">
              <organization abbrev="JHU/APL">The Johns Hopkins University Applied Physics Laboratory</organization>
            </author>
            <date/>
          </front>
        </reference>
        <reference anchor="github-dtn-demo-agent" target="https://github.com/BrianSipos/dtn-demo-agent/">
          <front>
            <title>Demo Convergence Layer Agent</title>
            <author fullname="Brian Sipos" initials="B." surname="Sipos">
              <organization abbrev="JHU/APL">The Johns Hopkins University Applied Physics Laboratory</organization>
            </author>
            <date/>
          </front>
        </reference>
        <reference anchor="gitlab-wireshark" target="https://gitlab.com/wireshark/wireshark">
          <front>
            <title>Wireshark repository</title>
            <author>
              <organization>Wireshark Foundation</organization>
            </author>
            <date/>
          </front>
        </reference>
      </references>
    </references>
    <section anchor="sec-example-ops">
      <name>Example Security Operations</name>
      <t>
These examples are intended to have the correct structure of COSE security blocks but in some cases use simplified algorithm parameters or smaller key sizes than are required by the actual COSE profile defined in this documents.
Each example indicates how it differs from the actual profile if there is a meaningful difference.
      </t>
      <t>
All of these examples operate within the context of the bundle primary block of <xref target="fig-ex-primary-block"/> with a security target block of <xref target="fig-ex-target-block"/>.
All example figures use the extended diagnostic notation <xref target="RFC8610"/>.
      </t>
      <figure anchor="fig-ex-primary-block">
        <name>Primary block CBOR diagnostic</name>
        <sourcecode type="cbor"><![CDATA[
[
  7, / BP version /
  0, / flags /
  2, / CRC type /
  [1, "//dst/svc"], / destination /
  [1, "//src/svc"], / source /
  [1, "//src/"], / report-to /
  [ / timestamp: /
    813110400000, / creation time: 2025-10-07T00:00:00Z /
    0 / seq. no. /
  ],
  1000000, / lifetime /
  h'82a081c9' / CRC value /
]
]]></sourcecode>
      </figure>
      <figure anchor="fig-ex-target-block">
        <name>Target block CBOR diagnostic</name>
        <sourcecode type="cbor"><![CDATA[
[
  1, / type code: payload /
  1, / block num /
  0, / flags /
  2, / CRC type /
  <<"hello">>, / block-type-specific-data /
  h'4ec359d2' / CRC value /
]
]]></sourcecode>
      </figure>
      <t>
Together these form an original bundle without any security operations present.
This bundle is encoded as the following 77 octets in base-16:
      </t>
      <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9860101000246656865
6c6c6f444ec359d2ff
      </sourcecode>
      <t>
All of the block integrity block examples operate within the context of the "frame" block of <xref target="fig-ex-bib-frame"/>, and block confidentiality block examples within the frame block of <xref target="fig-ex-bcb-frame"/>.
      </t>
      <figure anchor="fig-ex-bib-frame">
        <name>Block integrity frame block CBOR diagnostic</name>
        <sourcecode type="cbor"><![CDATA[
[
  11, / type code: BIB /
  3, / block num /
  0, / flags /
  0, / CRC type /
  '' / BTSD to be replaced with ASB /
]
]]></sourcecode>
      </figure>
      <figure anchor="fig-ex-bcb-frame">
        <name>Block confidentiality frame block CBOR diagnostic</name>
        <sourcecode type="cbor"><![CDATA[
[
  12, / type code: BCB /
  3, / block num /
  0, / flags /
  0, / CRC type /
  '' / BTSD to be replaced with ASB /
]
]]></sourcecode>
      </figure>
      <t>
All of the examples also operate within a security block containing the AAD Scope parameter with value <tt>{0:0b1,-1:0b1}</tt> indicating the primary block and target block metadata are included.
This results in a consistent <tt>AAD-list</tt> as shown in <xref target="fig-ex-AAD-list"/>, which is encoded as the byte string for COSE <tt>external_aad</tt> in all of the examples.
      </t>
      <figure anchor="fig-ex-AAD-list">
        <name>Example scope AAD-list CBOR-sequence diagnostic</name>
        <sourcecode type="cborseq">
[1, "//src/"], / security source /
{0:0b1, -1:0b1}, / AAD-scope /
[7, 0, 0, [1, "//dst/svc"], [1, "//src/svc"], [1, "//src/"],
  [813110400000, 0 ], 1000000, h'82a081c9'], / primary-block /
1, 1, 0, / target block-metadata /
'' / additional-protected /
        </sourcecode>
      </figure>
      <t>
The only differences between these examples which use ECC or RSA keypairs and a use of a public key certificate are: the highest-layer parameters would contain an "x5t" (or equivalent, see <xref target="sec-asym-keys"/>) value instead of a "kid" value.
This would not be a change to a protected header so, given the same private key, there would be no change to the signature or wrapped-key data.
      </t>
      <t>
Because each of the COSE_Encrypt examples using key wrap or encapsulation (<xref target="sec-example-ops-encrypt-sym-kw"/>, <xref target="sec-example-ops-encrypt-ecc-kw"/>, <xref target="sec-example-ops-rsa-recip"/>) use the same CEK within the same AAD, the target ciphertext is also identical.
The target block after application of the encryption is shown in <xref target="fig-ex-encrypt-target-final"/>.
      </t>
      <figure anchor="fig-ex-encrypt-target-final">
        <name>Encrypted Target block CBOR diagnostic</name>
        <sourcecode type="cbor"><![CDATA[
[
  1, / type code: payload /
  1, / block num /
  0, / flags /
  2, / CRC type /
  h'1fd25f64a2ee33e774abe16700bcfd9cf12ea5f7d841', / ciphertext /
  h'47abdef0'
]
]]></sourcecode>
      </figure>
      <section>
        <name>Symmetric Key COSE_Mac0</name>
        <t>
This is an example of a MAC with recipient having a 384-bit symmetric key (same size of the hash output) identified by a "kid".
        </t>
        <figure>
          <name>Symmetric Key</name>
          <sourcecode type="cbor"><![CDATA[
[
  {
    / kty / 1: 4, / symmetric /
    / kid / 2: 'ExampleA.1',
    / alg / 3: 6, / HMAC 384 384 /
    / ops / 4: [9, 10], / MAC create, MAC verify /
    / k / -1: h'3a5c74e32ab4558a99581ec3a816576812aabe895db04494cda2
5b711d7b5ed4077466e677860648412f1bf8c91d0624'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-mac-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
The <tt>payload</tt> is the encoded target BTSD from <xref target="fig-ex-target-block"/>.
        </t>
        <figure anchor="fig-ex-mac-struct">
          <name><tt>MAC_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "MAC0", / context /
  h'a10105', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040', / external_aad /
  h'6568656c6c6f' / payload /
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-mac-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      17, / COSE_Mac0 tag /
      <<[
        <<{ / protected /
           / alg / 1: 6 / HMAC 384 384 /
        }>>,
        { / unprotected /
          / kid / 4: 'ExampleA.1'
        },
        null, / payload detached /
        h'ec8260a38a1a00fef2cd4aae063f50f01c5645e84c6c4893ca895eed44
ef60a5f50f9adf5cc5654499b881e589637805' / tag /
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 180 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850b03000058608101
03018201662f2f7372632f818205a2000120018181821158458443a10106a1044a45
78616d706c65412e31f65830ec8260a38a1a00fef2cd4aae063f50f01c5645e84c6c
4893ca895eed44ef60a5f50f9adf5cc5654499b881e5896378058601010002466568
656c6c6f444ec359d2ff
        </sourcecode>
      </section>
      <section anchor="sec-example-ops-ecc-sign">
        <name>ECC Keypair COSE_Sign1</name>
        <t>
This is an example of a signature with the signer having a P-384 curve ECC keypair identified by a "kid".
        </t>
        <figure>
          <name>Example Keys</name>
          <sourcecode type="cbor"><![CDATA[
[
  { / signing private key /
    / kty / 1: 2, / EC2 /
    / kid / 2: 'ExampleA.2',
    / alg / 3: -51, / ESP384 /
    / ops / 4: [1, 2], / sign, verify /
    / crv / -1: 2, / P-384 /
    / x / -2: h'02dfc49747f5d3d219fe6185744729fa1672ef7d11cb57ca0320
c632be06ca3fdcc118e63140ba3ec57ea7b85d419568',
    / y / -3: h'4526e81bf0d9ea0924f05a3453ad75b92806671511544c993f6b
d908a7a4239d476cfdfd74d6c68836488ad1e60b0e7d',
    / d / -4: h'3494803544d85a84d802400b50f51eea23b72d7d850b53cbf300
6e5be2940d4a2c18d510a412efc7dc7875fbba22cca9'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-sign-ecc-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
The <tt>payload</tt> is the encoded target BTSD from <xref target="fig-ex-target-block"/>.
        </t>
        <figure anchor="fig-ex-sign-ecc-struct">
          <name><tt>Sig_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Signature1", / context /
  h'a10126', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040', / external_aad /
  h'6568656c6c6f' / payload /
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-sign-ecc-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      18, / COSE_Sign1 tag /
      <<[
        <<{ / protected /
           / alg / 1: -51 / ESP384 /
        }>>,
        { / unprotected /
          / kid / 4: 'ExampleA.2'
        },
        null, / payload detached /
        h'9c64328dfe9570262f5be687c35cc51ced48b8682d2a61d8baadfd3410
233634251c2c1862b0a194b8503985931051a77731a74a1514b83092d7c662e6dbcd
a2629af72b24bf1cc3c5e2552f54ddfcc1762e6bc46fd5e6c2137e4a695e563e
ae' / signature /
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 229 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850b03000058918101
03018201662f2f7372632f818205a2000120018181821258768444a1013832a1044a
4578616d706c65412e32f658609c64328dfe9570262f5be687c35cc51ced48b8682d
2a61d8baadfd3410233634251c2c1862b0a194b8503985931051a77731a74a1514b8
3092d7c662e6dbcda2629af72b24bf1cc3c5e2552f54ddfcc1762e6bc46fd5e6c213
7e4a695e563eae8601010002466568656c6c6f444ec359d2ff
        </sourcecode>
      </section>
      <section>
        <name>RSA Keypair COSE_Sign1</name>
        <t>
This is an example of a signature with the signer having a 3072-bit RSA keypair identified by a "kid".
        </t>
        <t>
This key strength is not supposed to be a secure configuration, only intended to explain the procedure.
This signature uses a random salt, so the full signature output is not deterministic.
        </t>
        <figure>
          <name>Example Keys</name>
          <sourcecode type="cbor"><![CDATA[
[
  { / signing private key /
    / kty / 1: 3, / RSA /
    / kid / 2: 'ExampleA.3',
    / alg / 3: -38, / PS384 /
    / ops / 4: [1, 2], / sign, verify /
    / n / -1: h'c14d4f1f3ed0913404c7ceffda1bb273e7cd8b575840d03a1048
5f3fead54bc2be84f21a771e56cb3a547db2fb1dd583932e5baa1d755dcaac0aaa78
dffee68f1e187121b22bf965a777a4dc7a7e8633fbc83867caf503d22f3d7f579bad
f3dd706cce0f0855f48eab3d6bd5e0fdef354b1469dd361e9f157e52add65ad9aa38
c281b8d4ef6818670816afcfd1d851e94fc6e70a5fc277c6307e6d68716d137b5d79
4b613b45cd911e59b94454fa70e75c72d9b4cffb9ff496e602a21f09de8f9062eec4
fddc480e5a1f854b18bd412ea0f8ed6f08f63516a4de42afffc94940ef7959363126
40116f7789702bee01a6118a7b6ee5d5496397fa58f408c968157e82a9b3f9579526
c301a9cd012f5c29c829425e581ba474a9a116b5ade9f60fb01fc45b03862d6e6eaa
3f586e456914370953ae725eb1deac8965da2d7a0568fddf4be2325fc2ee3ea4d338
e367e8e5a1da782a6bd5bf0291edb1cbd661c6aa2328a88df575b14b1bed84643a0f
57c1075cabbfcfbc42ef7637300612d5f9ef',
    / e / -2: h'010001',
    / d / -3: h'1ea457800a503bf6fa865aa677d7d479dccb84f9f8c2a174d582
f0c7c19299456037d3e70fc343eff2feff6eb6b19bd89525654b7a0afd035fdd504e
594d0a15b2d2c8baeb885eab0219370d94ef674268a31714964edbbc5f025e798548
ab1e8b0551c429469d935b75764426667ff1109b464d80ed94109a00978fa216dcb8
785636f603936fec2e933b6b1eb12e09903cbaaae17e2d72c1da30bebc884017da11
470fe7e4f5f964a31acec85d16365ebdd2b6aa679160cf90db91abde3fcf7701cbc3
28ad0bc0e7a633700d220dfac58c63e16f6e45e4f936ade468e1b398e52dda883fa6
59b7442af44c9152b487e1217c541125cfc48d75652b087beb8e9198e546a207e125
369f051780de3f8831a5427581050ddaeb3a91d9d1438d6e81288cecc246b533911f
678bfe1accd6bac04093031736b2d7e889d455cef1d7a3fd957c42de8dbf59ad33f3
0ed6b60b83ac9c3f8f2b4c94b2782770ebeed3c5503219729891cb5c26115ba8dc00
56cefe8b2cdb08dc5e1f01c3748476b6d99d',
    / p / -4: h'f5ace2298a583123dbc945ecdb640fb26bfddf00aa23ad065b92
18505bcaf50f736d41025db450ef387d901df5e655c80e08437d4f0caec4f2408bc4
38c76e909f033f10e0cdcc92189c3e22e5172ca443f10510854ebfe753df33712549
166af083ad45027ae03e9b56c2e505611e2dce649f046aa82cc40a0b071bfb8551b9
5070badf994afa4053163454923689ceb41270897c1235019eefb44c3cab49d596a9
ae0f8cfd15f9f795104714f77235fe152adbe846df3462fff61a38c40de5',
    / q / -5: h'c96cf68ed93426255732edf523f3cf54248a6439dbf2d3285ce3
5c74b9211b750997920451f970560f58d12bbad498b5d1a1fec4ec1162c075678816
b4fb1a4aff747871ac55e8792361c2968864ae33dc82299475b5d3b5c6380b1ed64a
56c5ec21cfaa90967aac499daa8ddbe8980e98ef0260c73731488d5ba2ba92d0e8f6
c2cfb6a1367f72858374d2588779efb2e2c1533482a95496a7c5c171c463f71ca8ee
45146f77cebde57be857075a9d71f78116ffc3be1bac428ba1456c5f8b43',
    / dP / -6: h'0649573c32e310d6d70fee6f222a0c50c77ca69130c95aeb17b
ac44e821ace6c87ca9ae84197949e9a767412a03135aeb9d5324ce991ec82f3a3fd2
f97385b36ee2aba1967773caddc5d5b25af71095e66b2ab2b820dc2d15b8f1194ea9
c552b855e093803d93b15bf09d850ddf35f3f52d1b653f99ab6128a23401a5234562
404cfeda83d16f312644de426e9dae569d9a7c323717e51c6e9d73e68d9009512171
9de6f5d6f3879be011d7a8429d4cd56e419c5a8caef793ab34c0bddb9fe95',
    / dQ / -7: h'62bb626fcacfe112d4974644af06c74dbb4b8aad41bed8fa23e
dde57e896edda84852331b2eccdbfa16e2bb97faecddbf191b24bdc5af948d543965
56b08da6e80a11a98bd9cae831270ccecf496453d6e8ceeccb29619dc33f92c9a44f
7d368d8c20a04d532ad96ddcec6d71a3ffca8cb15fcd86b4e067e45abf12bfae3240
e3097983195810b259eb61895047324a74eb6ec8e04adf3a495403dfe0201ee12c24
b68d9077a7680668841eec6d007f4e11909a8fccda6cadd238c3d774dadf9',
    / qInv / -8: h'cbd0a9d2d3e1922948906ffa45f27dc75383a81b3fd7fe57e
ce7f3e9d4bb1b3139696208fccedbeb1f3fc58493af5806fedd4bf496d087012a874
1bcdeabc590f3810ec77dfb8c38fc3ae68b74c22f6a998c295cd191dfcfe17b029ba
f7687d6a5a2672231dcb67cb93a854dee715319b195716bad1636382c2e124fcfed2
eb25be7f3a969cd5ce0f60c88213a5fb9e8de7d99fb54867c3f604925da9f522ca67
9633b134468882364be6595a55648a41fb56ae658f27ab704055d4c23bb95fa'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-sign-rsa-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
The <tt>payload</tt> is the encoded target BTSD from <xref target="fig-ex-target-block"/>.
        </t>
        <figure anchor="fig-ex-sign-rsa-struct">
          <name><tt>Sig_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Signature1", / context /
  h'a1013824', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040', / external_aad /
  h'6568656c6c6f' / payload /
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-sign-rsa-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      18, / COSE_Sign1 tag /
      <<[
        <<{ / protected /
           / alg / 1: -38 / PS384 /
        }>>,
        { / unprotected /
          / kid / 4: 'ExampleA.3'
        },
        null, / payload detached /
        h'687790c647271611102c8baf056046dac4184ee6e4e068d3b01a101723
9840714dfa5a9ed593680c9415a4dfb1e1473bb7807d9c0d614041b5dfbf963a0ba7
965cb446ac44602d8e17ebaf888d4a86edec6f47f71ba36f26b0ec657ac73f0edf08
381e1d2496f782c8c114728bab1e4ab0801531998e13e1ecb39a9e011142cb3b321d
ecfc08845dbc0685d96ac089df5c09937a8f47c46078d9dbc07725b9a85b85b7c570
8c6dfbacded9aea48ab492c1188e6b597a0bd81847519683ce5fd315f94edd44bf09
f842a9be66f281dcf62ccfd6257652d0fc6a86e0bda5132effa84a71c271aa975ac5
4511a70ddb5a8dd2ab8b9b5fd2680d27a09277d3d7777d0da83dafc1cd97753e35c0
d7a4b6ea0d2a74d278f39ff365f3ed61d4c50b35e1bb5c23e8c5778d43558f6e1d7f
9cd8ac38c12d33eb11cd698618f4d5536b1fe3482b42e69baf266bc82a2cfc0577be
126b6b6aac0134273759b64d3d7512da810092fa6345e26ede9d1a3e20336b2a7448
58928dd1158b4dc6e8037f4bfba61e' / signature /
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 520 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850b0300005901b381
0103018201662f2f7372632f818205a200012001818182125901978444a1013825a1
044a4578616d706c65412e33f6590180687790c647271611102c8baf056046dac418
4ee6e4e068d3b01a1017239840714dfa5a9ed593680c9415a4dfb1e1473bb7807d9c
0d614041b5dfbf963a0ba7965cb446ac44602d8e17ebaf888d4a86edec6f47f71ba3
6f26b0ec657ac73f0edf08381e1d2496f782c8c114728bab1e4ab0801531998e13e1
ecb39a9e011142cb3b321decfc08845dbc0685d96ac089df5c09937a8f47c46078d9
dbc07725b9a85b85b7c5708c6dfbacded9aea48ab492c1188e6b597a0bd818475196
83ce5fd315f94edd44bf09f842a9be66f281dcf62ccfd6257652d0fc6a86e0bda513
2effa84a71c271aa975ac54511a70ddb5a8dd2ab8b9b5fd2680d27a09277d3d7777d
0da83dafc1cd97753e35c0d7a4b6ea0d2a74d278f39ff365f3ed61d4c50b35e1bb5c
23e8c5778d43558f6e1d7f9cd8ac38c12d33eb11cd698618f4d5536b1fe3482b42e6
9baf266bc82a2cfc0577be126b6b6aac0134273759b64d3d7512da810092fa6345e2
6ede9d1a3e20336b2a744858928dd1158b4dc6e8037f4bfba61e8601010002466568
656c6c6f444ec359d2ff
        </sourcecode>
      </section>
      <section>
        <name>Symmetric CEK COSE_Encrypt0</name>
        <t>
This is an example of an encryption with an explicit CEK identified by a "kid".
The key used is shown in <xref target="fig-ex-encrypt0-symm-keys"/>, which includes a Base&nbsp;IV parameter in order to reduce the total size of the COSE message using a Partial&nbsp;IV.
        </t>
        <figure anchor="fig-ex-encrypt0-symm-keys">
          <name>Example Key</name>
          <sourcecode type="cbor"><![CDATA[
[
  {
    / kty / 1: 4, / symmetric /
    / kid / 2: 'ExampleA.4',
    / alg / 3: 3, / A256GCM /
    / ops / 4: [3, 4], / encrypt, decrypt /
    / base IV / 5: h'6f3093eba5d85143c3dc0000',
    / k / -1: h'13bf9cead057c0aca2c9e52471ca4b19ddfaf4c0784e3f3e8e39
99dbae4ce45c'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-encrypt0-symm-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
        </t>
        <figure anchor="fig-ex-encrypt0-symm-struct">
          <name><tt>Enc_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Encrypt0", / context /
  h'a10103', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040' / external_aad /
]
]]></sourcecode>
        </figure>
        <t>
The ASB item for this encryption operation is shown in <xref target="fig-ex-encrypt0-symm-asb"/> and corresponds with the updated target block (containing the ciphertext) of <xref target="fig-ex-encrypt0-target-final"/>.
This ciphertext is different than the common one in <xref target="fig-ex-encrypt-target-final"/> because of the different context string in <xref target="fig-ex-encrypt0-symm-struct"/>.
        </t>
        <figure anchor="fig-ex-encrypt0-symm-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      16, / COSE_Encrypt0 tag /
      <<[
        <<{ / protected /
           / alg / 1: 3 / A256GCM /
        }>>,
        { / unprotected /
          / kid / 4: 'ExampleA.4',
          / partial iv / 6: h'484a'
        },
        null / payload detached /
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-encrypt0-target-final">
          <name>Encrypted Target block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  1, / type code: payload /
  1, / block num /
  0, / flags /
  2, / CRC type /
  h'1fd25f64a2eee2ff1a1ab29812ba221874380974c13b', / ciphertext /
  h'2086c017'
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 149 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850c03000058318101
03018201662f2f7372632f818205a20001200181818210578343a10103a2044a4578
616d706c65412e340642484af68601010002561fd25f64a2eee2ff1a1ab29812ba22
1874380974c13b442086c017ff
        </sourcecode>
      </section>
      <section anchor="sec-example-ops-encrypt-sym-kw">
        <name>Symmetric Key COSE_Encrypt with Key Wrap</name>
        <t>
This is an example of an encryption with a random CEK and an explicit key-encryption key (KEK) identified by a "kid".
The keys used are shown in <xref target="fig-ex-encrypt-sym-kw-keys"/>.
        </t>
        <figure anchor="fig-ex-encrypt-sym-kw-keys">
          <name>Example Keys</name>
          <sourcecode type="cbor"><![CDATA[
[
  {
    / kty / 1: 4, / symmetric /
    / kid / 2: 'ExampleA.5',
    / alg / 3: -5, / A256KW /
    / ops / 4: [5, 6], / wrap, unwrap /
    / k / -1: h'0e8a982b921d1086241798032fedc1f883eab72e4e43bb2d11cf
ae38ad7a972e'
  },
  { / wrapped CEK /
    / kty / 1: 4, / symmetric /
    / alg / 3: 3, / A256GCM /
    / k / -1: h'13bf9cead057c0aca2c9e52471ca4b19ddfaf4c0784e3f3e8e39
99dbae4ce45c'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-encrypt-sym-kw-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
        </t>
        <figure anchor="fig-ex-encrypt-sym-kw-struct">
          <name><tt>Enc_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Encrypt", / context /
  h'a10103', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040' / external_aad /
]
]]></sourcecode>
        </figure>
        <t>
The ASB item for this encryption operation is shown in <xref target="fig-ex-encrypt-sym-kw-asb"/> and corresponds with the updated target block (containing the ciphertext) of <xref target="fig-ex-encrypt-target-final"/>.
The recipient does not have any protected header parameters because AES Key Wrap does not allow any AAD.
        </t>
        <figure anchor="fig-ex-encrypt-sym-kw-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      96, / COSE_Encrypt tag /
      <<[
        <<{ / protected /
           / alg / 1: 3 / A256GCM /
        }>>,
        { / unprotected /
          / iv / 5: h'6f3093eba5d85143c3dc484a'
        },
        null, / payload detached /
        [
          [ / recipient /
            <<>>, / protected /
            { / unprotected /
              / alg / 1: -5, / A256KW /
              / kid / 4: 'ExampleA.5'
            },
            h'917f2045e1169502756252bf119a94cdac6a9d8944245b5a9a26d4
03a6331159e3d691a708e9984d' / key-wrapped /
          ]
        ]
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 209 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850c030000586d8101
03018201662f2f7372632f818205a200012001818182186058518443a10103a1054c
6f3093eba5d85143c3dc484af6818340a20124044a4578616d706c65412e35582891
7f2045e1169502756252bf119a94cdac6a9d8944245b5a9a26d403a6331159e3d691
a708e9984d8601010002561fd25f64a2ee33e774abe16700bcfd9cf12ea5f7d84144
47abdef0ff
        </sourcecode>
      </section>
      <section anchor="sec-example-ops-encrypt-sym-hkdf">
        <name>Symmetric Key COSE_Encrypt with HKDF</name>
        <t>
This is an example of an encryption with a derived CEK and an explicit KDK identified by a "kid".
The keys used are shown in <xref target="fig-ex-encrypt-sym-hkdf-keys"/>, where the second key is the CEK derived from the KDK via a salt value in the recipient header.
        </t>
        <figure anchor="fig-ex-encrypt-sym-hkdf-keys">
          <name>Example Keys</name>
          <sourcecode type="cbor"><![CDATA[
[
  {
    / kty / 1: 4, / symmetric /
    / kid / 2: 'ExampleA.6',
    / alg / 3: -11, / direct+HKDF-SHA-512 /
    / ops / 4: [7], / derive key /
    / k / -1: h'6c4e5271e211e0c8329ab8f363097f16516a459f12a4060cf016
4968fdccbd63'
  },
  { / derived CEK /
    / kty / 1: 4, / symmetric /
    / alg / 3: 3, / A256GCM /
    / k / -1: h'9219317dd73fe13a4d40494aa3edade0d844f70475aeb558b9d6
18f0388d82ad'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-encrypt-sym-hkdf-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
The recipient internal KDF context is shown in <xref target="fig-ex-encrypt-sym-hkdf-kdfctx"/>.
        </t>
        <figure anchor="fig-ex-encrypt-sym-hkdf-struct">
          <name><tt>Enc_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Encrypt", / context /
  h'a10103', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040' / external_aad /
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-encrypt-sym-hkdf-kdfctx">
          <name><tt>COSE_KDF_Context</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  3, / AlgorithmID /
  [null, null, null], / PartyUInfo /
  [null, null, null], / PartyVInfo /
  [ / SuppPubInfo /
    256, / keyDataLength /
    <<{1: -11}>>, / protected /
    <<"BPSec", [1, "//src/"], ''>> / other /
  ]
]
]]></sourcecode>
        </figure>
        <t>
The ASB item for this encryption operation is shown in <xref target="fig-ex-encrypt-sym-hkdf-asb"/> and corresponds with the updated target block (containing the ciphertext) of <xref target="fig-ex-encrypt-sym-hkdf-target-final"/>.
This ciphertext is different than the common one in <xref target="fig-ex-encrypt-target-final"/> because of the different derived CEK in <xref target="fig-ex-encrypt-sym-hkdf-keys"/>.
        </t>
        <figure anchor="fig-ex-encrypt-sym-hkdf-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      96, / COSE_Encrypt tag /
      <<[
        <<{ / protected /
           / alg / 1: 3 / A256GCM /
        }>>,
        { / unprotected /
          / iv / 5: h'6f3093eba5d85143c3dc484a'
        },
        null, / payload detached /
        [
          [ / recipient /
            <<{ / protected /
              / alg / 1: -11 / direct+HKDF-SHA-512 /
            }>>,
            { / unprotected /
              / kid / 4: 'ExampleA.6',
              / salt / -20: h'2fa8c8352aea17faf7407271a5e90eb8'
            },
            h'' / empty /
          ]
        ]
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-encrypt-sym-hkdf-target-final">
          <name>Encrypted Target block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  1, / type code: payload /
  1, / block num /
  0, / flags /
  2, / CRC type /
  h'6d0664951176f40600518b5c32a2a2137871f1f045ad', / ciphertext /
  h'd7042de5'
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 187 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850c03000058578101
03018201662f2f7372632f818205a2000120018181821860583b8443a10103a1054c
6f3093eba5d85143c3dc484af6818343a1012aa2044a4578616d706c65412e363350
2fa8c8352aea17faf7407271a5e90eb8408601010002566d0664951176f40600518b
5c32a2a2137871f1f045ad44d7042de5ff
        </sourcecode>
      </section>
      <section anchor="sec-example-ops-encrypt-ecc-kw">
        <name>ECC Keypair COSE_Encrypt with Key Wrap</name>
        <t>
This is an example of an encryption with an P-384 curve ephemeral sender keypair and a static recipient keypair identified by a "kid".
The keys used are shown in <xref target="fig-ex-encrypt-ecc-kw-keys"/>.
        </t>
        <figure anchor="fig-ex-encrypt-ecc-kw-keys">
          <name>Example Keys</name>
          <sourcecode type="cbor"><![CDATA[
[
  { / sender ephemeral private key /
    / kty / 1: 2, / EC2 /
    / crv / -1: 2, / P-384 /
    / x / -2: h'2f88f095c45c96e377e18d717a5e6007ce8f6076ae82009d1637
5e1b9abaa9497a4bde513be6c9b0e7dae96033968c45',
    / y / -3: h'fd27656fbb97f789d667f40d73b65ab362b22dd23bf492bee72b
f3409f68dddf208040a5fcbcbee74545741e2866cb2d',
    / d / -4: h'c4fff15193b8bceff5e221cc37b919fa8d33581a37c08d3e8520
a658b4040a443f8fb3b54fb4ce882510e76017b66261'
  },
  { / recipient private key /
    / kty / 1: 2, / EC2 /
    / kid / 2: 'ExampleA.7',
    / alg / 3: -31, / ECDH-ES + A256KW /
    / ops / 4: [7], / derive key /
    / crv / -1: 2, / P-384 /
    / x / -2: h'0057ea0e6fdc50ddc1111bd810eae7c0ba24645d44d4712db0c8
354c234b2970b4ac27e78f38250069d128f98e51ceb1',
    / y / -3: h'4b72c50b27267637c40adcd78bd025e4b654a645d2ba7ba9894c
c73b2431d4cdc040d66e8eb2dad731f7dca57108545c',
    / d / -4: h'7931af7cc3010ae457bcb8be100acdafab8492de633b20384c3e
4de5e5e94899d9d9de25c04d6205ae6bb9385ce16ff7'
  },
  { / derived KEK /
    / kty / 1: 4, / symmetric /
    / alg / 3: -5, / A256KW /
    / k / -1: h'6f8e81f2cef6fb914ca4013a244a56a9ccd8f57d9eb481e94bec
1d3e6b33af9d'
  },
  { / wrapped CEK /
    / kty / 1: 4, / symmetric /
    / alg / 3: 3, / A256GCM /
    / k / -1: h'13bf9cead057c0aca2c9e52471ca4b19ddfaf4c0784e3f3e8e39
99dbae4ce45c'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-encrypt-ecc-kw-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
The recipient internal KDF context is shown in <xref target="fig-ex-encrypt-ecc-kw-kdfctx"/>.
        </t>
        <figure anchor="fig-ex-encrypt-ecc-kw-struct">
          <name><tt>Enc_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Encrypt", / context /
  h'a10103', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040' / external_aad /
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-encrypt-ecc-kw-kdfctx">
          <name><tt>COSE_KDF_Context</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  -5, / AlgorithmID /
  [null, null, null], / PartyUInfo /
  [null, null, null], / PartyVInfo /
  [ / SuppPubInfo /
    256, / keyDataLength /
    <<{1: -31}>>, / protected /
    <<"BPSec", [1, "//src/"], ''>> / other /
  ]
]
]]></sourcecode>
        </figure>
        <t>
The ASB item for this encryption operation is shown in <xref target="fig-ex-encrypt-ecc-kw-asb"/> and corresponds with the updated target block (containing the ciphertext) of <xref target="fig-ex-encrypt-target-final"/>.
        </t>
        <figure anchor="fig-ex-encrypt-ecc-kw-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      96, / COSE_Encrypt tag /
      <<[
        <<{ / protected /
           / alg / 1: 3 / A256GCM /
        }>>,
        { / unprotected /
          / iv / 5: h'6f3093eba5d85143c3dc484a'
        },
        null, / payload detached /
        [
          [ / recipient /
            <<{ / protected /
              / alg / 1: -31 / ECDH-ES + A256KW /
            }>>,
            { / unprotected /
              / kid / 4: 'ExampleA.7',
              / ephemeral key / -1: {
                1: 2,
                -1: 2,
                -2: h'2f88f095c45c96e377e18d717a5e6007ce8f6076ae8200
9d16375e1b9abaa9497a4bde513be6c9b0e7dae96033968c45',
                -3: h'fd27656fbb97f789d667f40d73b65ab362b22dd23bf492
bee72bf3409f68dddf208040a5fcbcbee74545741e2866cb2d'
              }
            },
            h'40cbaff3538184a12ed3f3aee47f899342b642cc9d78d2db84c26b
08b2d16eb8f162740a25b21f37' / key-wrapped /
          ]
        ]
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 319 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850c03000058db8101
03018201662f2f7372632f818205a200012001818182186058bf8443a10103a1054c
6f3093eba5d85143c3dc484af6818344a101381ea2044a4578616d706c65412e3720
a4010220022158302f88f095c45c96e377e18d717a5e6007ce8f6076ae82009d1637
5e1b9abaa9497a4bde513be6c9b0e7dae96033968c45225830fd27656fbb97f789d6
67f40d73b65ab362b22dd23bf492bee72bf3409f68dddf208040a5fcbcbee7454574
1e2866cb2d582840cbaff3538184a12ed3f3aee47f899342b642cc9d78d2db84c26b
08b2d16eb8f162740a25b21f378601010002561fd25f64a2ee33e774abe16700bcfd
9cf12ea5f7d8414447abdef0ff
        </sourcecode>
      </section>
      <section anchor="sec-example-ops-encrypt-ecc-hkdf">
        <name>ECC Keypair COSE_Encrypt with HKDF</name>
        <t>
This is an example of an encryption with an P-384 curve static sender keypair and a static recipient keypair each identified by a "kid".
The keys used are shown in <xref target="fig-ex-encrypt-ecc-hkdf-keys"/>, where the third key is the CEK derived from the ECDH secret via a salt value in the recipient header.
        </t>
        <figure anchor="fig-ex-encrypt-ecc-hkdf-keys">
          <name>Example Keys</name>
          <sourcecode type="cbor"><![CDATA[
[
  {
    / kty / 1: 2, / EC2 /
    / kid / 2: 'SenderA.8',
    / alg / 3: -28, / ECDH-SS + HKDF-512 /
    / ops / 4: [7], / derive key /
    / crv / -1: 2, / P-384 /
    / x / -2: h'2f88f095c45c96e377e18d717a5e6007ce8f6076ae82009d1637
5e1b9abaa9497a4bde513be6c9b0e7dae96033968c45',
    / y / -3: h'fd27656fbb97f789d667f40d73b65ab362b22dd23bf492bee72b
f3409f68dddf208040a5fcbcbee74545741e2866cb2d',
    / d / -4: h'c4fff15193b8bceff5e221cc37b919fa8d33581a37c08d3e8520
a658b4040a443f8fb3b54fb4ce882510e76017b66261'
  },
  { / recipient private key /
    / kty / 1: 2, / EC2 /
    / kid / 2: 'ExampleA.8',
    / alg / 3: -28, / ECDH-SS + HKDF-512 /
    / ops / 4: [7], / derive key /
    / crv / -1: 2, / P-384 /
    / x / -2: h'0057ea0e6fdc50ddc1111bd810eae7c0ba24645d44d4712db0c8
354c234b2970b4ac27e78f38250069d128f98e51ceb1',
    / y / -3: h'4b72c50b27267637c40adcd78bd025e4b654a645d2ba7ba9894c
c73b2431d4cdc040d66e8eb2dad731f7dca57108545c',
    / d / -4: h'7931af7cc3010ae457bcb8be100acdafab8492de633b20384c3e
4de5e5e94899d9d9de25c04d6205ae6bb9385ce16ff7'
  },
  { / derived CEK /
    / kty / 1: 4, / symmetric /
    / alg / 3: 3, / A256GCM /
    / k / -1: h'044696106512bd01e479c9d836ae8ec0183096a689010d103f7d
5e0109ab61d2'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-encrypt-ecc-hkdf-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
The recipient internal KDF context is shown in <xref target="fig-ex-encrypt-ecc-hkdf-kdfctx"/>.
        </t>
        <figure anchor="fig-ex-encrypt-ecc-hkdf-struct">
          <name><tt>Enc_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Encrypt", / context /
  h'a10103', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040' / external_aad /
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-encrypt-ecc-hkdf-kdfctx">
          <name><tt>COSE_KDF_Context</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  3, / AlgorithmID /
  [null, null, null], / PartyUInfo /
  [null, null, null], / PartyVInfo /
  [ / SuppPubInfo /
    256, / keyDataLength /
    <<{1: -28}>>, / protected /
    <<"BPSec", [1, "//src/"], ''>> / other /
  ]
]
]]></sourcecode>
        </figure>
        <t>
The ASB item for this encryption operation is shown in <xref target="fig-ex-encrypt-ecc-hkdf-asb"/> and corresponds with the updated target block (containing the ciphertext) of <xref target="fig-ex-encrypt-ecc-hkdf-target-final"/>.
This ciphertext is different than the common one in <xref target="fig-ex-encrypt-target-final"/> because of the different derived CEK in <xref target="fig-ex-encrypt-ecc-hkdf-keys"/>.
        </t>
        <figure anchor="fig-ex-encrypt-ecc-hkdf-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      96, / COSE_Encrypt tag /
      <<[
        <<{ / protected /
           / alg / 1: 3 / A256GCM /
        }>>,
        { / unprotected /
          / iv / 5: h'6f3093eba5d85143c3dc484a'
        },
        null, / payload detached /
        [
          [ / recipient /
            <<{ / protected /
              / alg / 1: -28 / ECDH-SS + HKDF-512 /
            }>>,
            { / unprotected /
              / kid / 4: 'ExampleA.8',
              / sender kid / -3: 'SenderA.8',
              / salt / -20: h'2fa8c8352aea17faf7407271a5e90eb8'
            },
            h'' / empty /
          ]
        ]
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-encrypt-ecc-hkdf-target-final">
          <name>Encrypted Target block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  1, / type code: payload /
  1, / block num /
  0, / flags /
  2, / CRC type /
  h'2ca0e0a335caf954c79f9e4c2c24016df09f662069c0', / ciphertext /
  h'1631e85a'
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 199 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850c03000058638101
03018201662f2f7372632f818205a200012001818182186058478443a10103a1054c
6f3093eba5d85143c3dc484af6818344a101381ba3044a4578616d706c65412e3822
4953656e646572412e3833502fa8c8352aea17faf7407271a5e90eb8408601010002
562ca0e0a335caf954c79f9e4c2c24016df09f662069c0441631e85aff
        </sourcecode>
      </section>
      <section anchor="sec-example-ops-rsa-recip">
        <name>RSA Keypair COSE_Encrypt</name>
        <t>
This is an example of an encryption with a recipient having a 3072-bit RSA keypair identified by a "kid".
The associated public key is included as a security parameter.
        </t>
        <t>
This key strength is not supposed to be a secure configuration, only intended to explain the procedure.
This padding scheme uses a random salt, so the full Layer 1 ciphertext output is not deterministic.
        </t>
        <figure anchor="fig-ex-encrypt-rsa-keys">
          <name>Example Keys</name>
          <sourcecode type="cbor"><![CDATA[
[
  { / recipient private key /
    / kty / 1: 3, / RSA /
    / kid / 2: 'ExampleA.9',
    / alg / 3: -42, / RSAES-OAEP w SHA-512 /
    / ops / 4: [5, 6], / wrap, unwrap /
    / n / -1: h'bb4917794481770c92a1ba6a35fbe0677a5c3669cd39c530985a
234765d0c0acc874925b1578e08f5d71dec62c1d28bb237fc3f1ddf8f01cab5ac207
5ade1747958d818fd332781891dbda85e00d0006a538f88d28900f69d93c340bd7da
8d47d0e63b448671b885d35a275a7204ed15bea0276ace4bbca291d2843b4454fce8
5faf78056753b6331b01f54c52eca23c0c255ea53919a972b548777049dc64bc4261
7ae74fc1af5bd10d72102f32347e12161d9fb1d43c9cbf26a49bd65a6b282276a634
15c52b36ce2a186f0ecc6b15a4c596c67a9eafca72e665c3a91062b22d1f00d05fb3
fb120f34263406c64848d93baa65985a7974aafc39f83a39c896c907da9b7e6df1a6
f9c3588ebd5ae5d6dfce569e15d17a4594098c1606b3b94cfdeff8dc41e56e9592fc
59de96b6aae1729444ee28e6fedd59e432f0670465a65212774ece52c205748ec207
db332feef700d2b4a2c2a7d40efddac627d816b872c6e12b074704b12f2dbb92b44f
7bd799a2848ef0c17e1783baa33e89c1bb4b',
    / e / -2: h'010001',
    / d / -3: h'8d0b34532ce688fadcb4dea67fd303ad0c84632f87d2cf57e59a
80319defb97dfafa13c247d3828c6bcac2567507108e84ad8937cd25676ac70f45d6
07360efa5efd3daf42a19758dfd557775b56da4b68bc4f70c728ef09df397b57e01e
17f2c96afba541d096365e9c549df5ed82d9d9c0d43ca3f454af1c6701afd1749636
03f20f52f647225a24e81403c72dd0336ff99027d44f12b073d87faa8c263f1fe505
03757be3210c455df6e92f9aaf89a63ec49b884af7648c168a7116848087b94db5a8
2435e98249723543fdbe8bf420faa6f578c382738a2a2753e7886e8152ba5ec8291d
002b87a068a73fc5f3a3379424582d1ed5b4c338475c8de509f37c3092d3fd8337b0
9b0d9725add3380d921d4f9f90700116b5543cb8a40c3ec0e4661cf09f0ebf62c57c
dbf63c59390d6f1d2dbd2ea09be5c21d2732109e7787cb9a4582d8c2be712a2d9355
c1b8ba1e597dc2012bb920e551a6fddc0c7db08ab32b0add6ddedab6b70b4c3105dc
ed09a49c6cf6e325b8b80c65fc1859fcd5',
    / p / -4: h'fa214874981ce573589c4eb4682c12aed490c66714a4e339ea2d
b376b6dac4bd997fdeacccd4b514daeda487b86a273dec8746a5debb3f776c46367c
f163f968c76900de21a20b75201b9a376327158e90a52e3e24e3c60b79102a572ad9
f859364fdce1c14da0379480ee87c20fd54454847a41c644fff9e9e72b6d42dbcd5b
7d343abbf785e72d494fd60e309322e5bcb20763f56c6000ae975eb6d4c23e1f3e0b
6f6d52b74cefaa6045fbd0697740895b45af918faf75febec37f6e88eb55',
    / q / -5: h'bfae414a486903f3f203382d3995dcae8e1e716b8835d1126819
4879d9dad3d57396e3fd52a16272221d25a2f8e82eccc29c16751061e903566825cd
66e562bad038b002684356411bc323d8212c8b7aac4dd481b511e9de45ab3b6cab78
50d30f2861e0e7c6778d26b19458fff4f74d2b65af87234a090ab241ea8a51b8cb15
294b1b283bead83f9064cb32cbe0f25807ee946484c6a777c19a7bd2a214cbc9ed17
8552e0afd7748511333375753852fb0b4e9c8d4fcab2d2372be59c104c1f',
    / dP / -6: h'92f19ca44a7ca75b751216b6ab8040d58eb122ad8a16381b5cf
4ce3a8ebfc4d6f1e78a04902ce1d8c7a8d68099195bc6683f2c84e36db3a24fec8bb
42907a78d23a10f4e7009c79b5e6a78d5d31d31efd8100233a5ee5df97d7cbeb308c
c96b6aa4e8e9fddb4e1cbe5253d7c69c86d6cc00e37d88e4718ee53b867edbf5a6bb
134c3cb4183ef995924798f72349d2be235518d3feefd6504e18cb1aacd20f3e7dcc
65106b39255d3728f2e6dfa090b72d17eda5883361b4941880647c5c31025',
    / dQ / -7: h'933ea1191716d4da8886c098bd2bca22ad39e596dd43ba1f91a
81a6cc055c174af1eb274df0cea3b12c9a127d85d43d6378900175d4659611ef7525
2bf4066df6b24a0d0b89741a332586d2892134df2267a834c40744a5b5cd97504bd9
3e742bada22964a75c350c2f0972ce7329ee6c0f79427138cc3f55b8a1749ba0d62b
416cc83481cff02af91945c23e14a23e04bf79236c568752d21a4328a53c7f5e4602
5395db90c5b4e3f0a3f72c04013cc6adcfcbe762f5d5e90eda0e2f947ebb1',
    / qInv / -8: h'2f61ebed182ff0375be59300f2f0f4302f915274756b13dfa
3847b56259c87a204e7188656460afec04bf8889ad2ab6cd54d56cbff63eeac06620
ec6cadca22ba4cc4ee29b6195aaab25ef33455ef204eb75f93e9fc2b0c7bfe11f112
7c2b9102e729a504eb1bd350c70568acbab5b5feffa8272f0458ba66491fd93387e8
6b8c8c2ed69845b6dffc0b3800dc175d3bdf40e154053141e54db17f9515dfa719de
b426775bac26854b539e18176f89e785bacd4672534f683f80b2cc7927bf8f7'
  },
  { / encapsulated CEK /
    / kty / 1: 4, / symmetric /
    / alg / 3: 3, / A256GCM /
    / k / -1: h'13bf9cead057c0aca2c9e52471ca4b19ddfaf4c0784e3f3e8e39
99dbae4ce45c'
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-encrypt-rsa-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
        </t>
        <figure anchor="fig-ex-encrypt-rsa-struct">
          <name><tt>Enc_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Encrypt", / context /
  h'a10103', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040' / external_aad /
]
]]></sourcecode>
        </figure>
        <t>
The ASB item for this encryption operation is shown in <xref target="fig-ex-encrypt-rsa-asb"/> and corresponds with the updated target block (containing the ciphertext) of <xref target="fig-ex-encrypt-target-final"/>.
The recipient does not have any protected header parameters because RSA OAEP does not allow any AAD.
        </t>
        <figure anchor="fig-ex-encrypt-rsa-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      96, / COSE_Encrypt tag /
      <<[
        <<{ / protected /
           / alg / 1: 3 / A256GCM /
        }>>,
        { / unprotected /
          / iv / 5: h'6f3093eba5d85143c3dc484a'
        },
        null, / payload detached /
        [
          [ / recipient /
            <<>>, / protected /
            { / unprotected /
              / alg / 1: -42, / RSAES-OAEP w SHA-512 /
              / kid / 4: 'ExampleA.9'
            },
            h'50901651a7f2d911da19ced267bf2390bd9af7d0e0617a3212c59c
f1ae237041aa81ff8e169c49a570be2c5eeced21c4666d4b385b36462e486f011791
ec7f86e9b0afe0affafc12f26d605ef13396675d6d4642448a5fd9a1cfdd999f1423
31d894501f8b82d08e7d1703ab14eaf510bcc4e18e373ab2ed502ebb99dc0035f393
c4cbdea8b40535e528017087ee700442539e7cf079950de91c0aa9f058c66e15a640
eba39b4e619c4daf6c08beaf654932f8f88ad8685e87402f75be68bf3dd2e5539a7d
0ea880ec89788c36dc3a6603eda6999f519eed0f62302ea92adc13d52bf7898eb1ab
1aa587bf8f278059ede7c75204d3d69f67b00b50cd70a8724eb2a204c275981af92a
4ae21b77d9ca8be275fb4a1edbba3edcae4a0f964ca913326a9507c4c6647adc9487
82136036f73cbfba33e1b5977591931b99ce536015bfb89c062c3208189bdc43e530
6cdaefa81a769df267d00233e375e5b0b027974fda218f318c7cd7c1fdbfe8548fb2
71f3b14de9a50d7bb23e26feb3cc1ea882' / key-encapsulation /
          ]
        ]
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 557 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850c0300005901c881
0103018201662f2f7372632f818205a20001200181818218605901ab8443a10103a1
054c6f3093eba5d85143c3dc484af6818340a2013829044a4578616d706c65412e39
59018050901651a7f2d911da19ced267bf2390bd9af7d0e0617a3212c59cf1ae2370
41aa81ff8e169c49a570be2c5eeced21c4666d4b385b36462e486f011791ec7f86e9
b0afe0affafc12f26d605ef13396675d6d4642448a5fd9a1cfdd999f142331d89450
1f8b82d08e7d1703ab14eaf510bcc4e18e373ab2ed502ebb99dc0035f393c4cbdea8
b40535e528017087ee700442539e7cf079950de91c0aa9f058c66e15a640eba39b4e
619c4daf6c08beaf654932f8f88ad8685e87402f75be68bf3dd2e5539a7d0ea880ec
89788c36dc3a6603eda6999f519eed0f62302ea92adc13d52bf7898eb1ab1aa587bf
8f278059ede7c75204d3d69f67b00b50cd70a8724eb2a204c275981af92a4ae21b77
d9ca8be275fb4a1edbba3edcae4a0f964ca913326a9507c4c6647adc948782136036
f73cbfba33e1b5977591931b99ce536015bfb89c062c3208189bdc43e5306cdaefa8
1a769df267d00233e375e5b0b027974fda218f318c7cd7c1fdbfe8548fb271f3b14d
e9a50d7bb23e26feb3cc1ea8828601010002561fd25f64a2ee33e774abe16700bcfd
9cf12ea5f7d8414447abdef0ff
        </sourcecode>
      </section>
      <section anchor="sec-example-ops-ml-sign">
        <name>ML Keypair COSE_Sign1</name>
        <t>
This is an example of a signature with the signer having an ML-DSA-87 keypair identified by a "kid".
The signing private key in <xref target="fig-ex-sign-ml-keys"/> elides the public parameter because they can be fully derived from the private parameter (which is a "seed" form in accordance with <xref section="4" target="RFC9964"/>).
        </t>
        <figure anchor="fig-ex-sign-ml-keys">
          <name>Example Keys</name>
          <sourcecode type="cbor-elide"><![CDATA[
[
  { / signing private key /
    / kty / 1: 7, / AKP /
    / kid / 2: 'ExampleA.10',
    / alg / 3: -50, / ML-DSA-87 /
    / ops / 4: [1, 2], / sign, verify /
    / pub  / -1: h'fbcf...94e9', / elided 2592 octets /
    / priv / -2: h'6aad3263218dc8d7314db377756bb82727c825fa10bcbf8c
76e45c628f4328ec',
  }
]
]]></sourcecode>
        </figure>
        <t>
The internal COSE structure is shown in <xref target="fig-ex-sign-ml-struct"/>.
The <tt>external_aad</tt> is the encoded data from <xref target="fig-ex-AAD-list"/>.
The <tt>payload</tt> is the encoded target BTSD from <xref target="fig-ex-target-block"/>.
        </t>
        <figure anchor="fig-ex-sign-ml-struct">
          <name><tt>Sig_structure</tt> CBOR diagnostic</name>
          <sourcecode type="cbor"><![CDATA[
[
  "Signature1", / context /
  h'a1013831', / protected /
  h'8201662f2f7372632fa200012001890700028201692f2f6473742f7376638201
692f2f7372632f7376638201662f2f7372632f821b000000bd51281400001a000f42
404482a081c901010040', / external_aad /
  h'6568656c6c6f' / payload /
]
]]></sourcecode>
        </figure>
        <figure anchor="fig-ex-sign-ml-asb">
          <name>Abstract Security Block CBOR diagnostic</name>
          <sourcecode type="cbor-elide"><![CDATA[
[1], / targets /
3, / security context /
1, / flags: params-present /
[1, "//src/"], / security source /
[ / parameters /
  [
    5, / AAD-scope /
    {0:0b1,-1:0b1} / primary metadata, target metadata /
  ]
],
[
  [ / target block #1 /
    [ / result /
      18, / COSE_Sign1 tag /
      <<[
        <<{ / protected /
           / alg / 1: -50 / ML-DSA-87 /
        }>>,
        { / unprotected /
          / kid / 4: 'ExampleA.10'
        },
        null, / payload detached /
        h'fe60...2a30' / signature elided, total 4627 octets /
      ]>>
    ]
  ]
]
]]></sourcecode>
        </figure>
        <t>
The final bundle is encoded as the following 4764 octets in base-16:
        </t>
        <sourcecode type="cborhex">
9f890700028201692f2f6473742f7376638201692f2f7372632f7376638201662f2f
7372632f821b000000bd51281400001a000f42404482a081c9850b03000059124781
0103018201662f2f7372632f818205a2000120018181821259122b8444a1013831a1
044b4578616d706c65412e3130f6591213fe604a2c9c5263c6fd8e9b61ca6fe9e627
88a4eae74e5791d47ea90a0212048d965f4909fe0bd2f88aca3fc2108e72fbb5a2bb
e9416aa61b69b3e58fc2664442f7554780acafd68708ee30db69c96928f0cc0384f9
792ccab02fe15a839a48b0066885cd70ae4c0b073aae1b18c4dd1132862d32d4c4c7
4b811b476b56b0c6856b64384e4447b97845c25cc1f3f5fac75c376c5c8765c063b4
77a4cd50950af80bf6ff30a2fd0d6a16d303fd1077fc9ff06573ebb0613cdb1865a1
56d130c075f4a49b72987a924545d7548474dc7b06af2cdb863b73426fba59cafb12
50a32a227cbec43f4db14f5e62a7c2c245f3cb800e26ec3e015d5e50a79ae2f6ed9d
cd3bc938f15bbd01938479c4cf5dcbda12083c3837ce97f11028c6a10767f2b7135a
b1adc877a35e4f20d19b339673b495badf8534b12e79f871c3f39ee72f3c6b994e40
227b32a416829f2b31f3cf3503fa91e4d9183aa51bcc2ae6632b61216c33adf30ec6
1994f59fd365a4ae52641f361c15fa0e8e888af884ba681004ec3aa90548cbfc4091
527ad2972369c3e75e95a4ebb6953346a707528f4168a84ee58a45d85e177ca877b6
9ed45b830c4ee029fd0338ce6b0c2a5de6102eede174f27bf5391da3a7a8ad4b2331
52273e45bd8f80f227a62de9132b2f4c6ba4ed5559116bf86e730fae895b787fd6f8
62da0518f6d06f74ae4c520a169f1d9d2d9f19e40be8032bedc9be881a93f0f5e931
639a2176b8ad60db98ee7b5e8f978010504dee7e1bb447066164edfe0c03eb2bb761
e5423f2662636a988da1d8b56c69c11ddea5cf3545aeb52ea12f5e1f90225b07ddbd
e33017aede645ce05c13953c74f760480be6d8ab04c86a2ee64f649d669e482cc69c
c69f208e94cf6876df51303cab48d1b864a334335377bde48f7e12188989033020f9
27131c7f251ddcc1fa3a7942c35fd77b9abdd6a6b599c5e9d1b236f1b056da515763
942cb9ab86667344e652175858f765de17e7cf352eca7d65b83cc2d5d989bde06187
9a228e2068d0b7ee9dddc23310dd5efccab4bf4e2bd8cad948b0fb2e018833b2dd22
49811cab277bc58d987c9b771726c4cd66422071b9751d12a9fbabad230447463387
40593d5bc383aed19dcab738833176f0674df1e6a2f8dc4ddffc81cd215532cf6240
647ed372498bee684200d6aba01e874ebdfd42bec240fecafadeb4a28381de7d51bf
04131ca1e564ad584ec0c030f90d7ce6196fe1497724ee7e1bb0f65bd2f65c25d7f0
035704a89c259c9c8a2e3c63371daaaf912b0d164651e80b2fee7fb5a0e7e716ad74
d22f4abb56da2c521c310230c3efbb256fb4246ba2a74053ad94183879ae94030707
45d6fda8e2e26a0ed949d972d2774b48b849deb1cf7fbe990efe19c6c1710c299f8a
1e4d9b71987c998c2e637b6723e79fe2fb36f9aeb550c21c02bcc2aeee144d75ceef
857f48a077c2296036b1885c9fa2e3dda4b01451967490cb311d52b59df80da84c83
2c30f17b0fc5f23aa8850beb2ed6f30320815fd919e53c958c44ed260011a6370a51
678da88bdb9d487cd9143bacfe8422d201c6e5de737731b5688ee197a024fbfe4cc4
4c889c2420351dc5860cd289c023c617b52ded66bfe4c17fc042cb3cb943c58d3f94
6c11853ef7cf9a4710b545b83f1ba2183e75a065704f887fc16cd82827f06ad4794b
0d4fcf709aaab11159500e55f0c458262fad487c258c636f29b76285f875cb23e475
101984f7c78671160bb173c29fa1ed128c3ecffaba42e1f79354846ab997089ca6dc
402afb77556481dfeae633e7affb1546a63bd4808897a75b4974c2515ddceee96055
5505fc3680c40263affc405d668a1e842be0bc9be35fb48c805eade0e75c7a904b7c
17c54a28074c20b57aca8036b85653d5437d2cd32f75f1e62250ec88337deececfc9
400b202fea7a438feae1288575c74313f1807668ba23e95da15e5f596e28d31a8190
9f8b73e37b5a7af66e1c7f2c7f6348342ad2b6b61c41c45f9e8b15d7542d6484cdbc
510c5d7d55c1ee2341a55e6120a7b93712f5138b95787fdae47f99801a7fe31c0a36
b4e85155530a21ac64698e35501071ab067801a69296fc953b9c98d225ac2297f686
bc035d365e2fbd8f1a08cce6c6df59968ab9da29505d2587f6593a5abd61f4f3ccd5
0f5249bf946427f648987afb90e51c7a8507f4469f7e28e35f5bb86f069b9b01a768
1374919c9d234c69f196daeeaa56f9bb1a2d41dae5b078ebc8c01010697846372e3f
db3d9137f35555bffda9560be7c4d81dc6b98d1f85cfb1ed36fe21e67b27cb1ff1a2
6ee9687ec7063a1350e113f2f4872c6732d071a53f4fc5d9408fbbad6de1e497e02a
de984ce875b821bf00777271845edb48d1dcfeede5808df67428597e6cbd547e8600
83e3753fee2ad8a92fd50d0ffa61a62aed569c3073d3e0146cbee7fe1606ced8d706
0e5b998f04714ddd71fc32b1689b442dd95216b548ff62179ab48b1697f692083f76
e04032b8a3443ddc977cb656d0232ff2bf8d9b25307e6c795e20d61ee27f8d9726bf
67a00b41a25b668db48a628b84818f6345aa53ae45e83f527ba6051f7f92c5860ef9
527dc8fb52e65b4b98cd30a89efabd89cd8471a70bf083a71d5eed8b07074ccbb685
d402b27883c120b374e05832440b3d2fa72c03ea4ca56468874121f64e0abd08f95b
cf15da84f78609aa32929d6d2370025374c26782277685e6075e32dd4e532974b98a
017df5e4262fb1fc649b1f932fd31109d7850f2422725d78ccc5148154b910d19be4
70e72badea5117ed0c4c51429317da7e976402f5fb8bfb890dfc7e8820ff759d720c
8f426d546eb755f9d759387da63224fe93a34743e75c3550f5934ff3f9feefdc5e3a
511284ad60cb179ab956ab0adf892993da7e1c6076105f7307253be683b8c6326149
b327bea0bf3fab333a5dd1d4911e435974d018a354f1062196aaa1a51d5377f7c1e7
0e2552add9a7d0cc6e2358e8d55c0c8bc763ad7ddee59d6810469224bd36b03ccec5
60801e04865a9fe635a5809dec351a199d3b6a3a62f6843b33b04fbde7dcbf368139
6768244664f7704146a94a9f3292cc32b0a0fab18a3e0f44138115448d392703b88c
46ed7ca4358c46fea338a41ad1e8f1893f318e7926bf64159191d142e3e2756144c4
b1950c6f017b007212b7aec0695faafdae3e55f721f8b1155ac0d12292cd6616c67c
2cfa3bf39171c09686599fce0028435cfa7605183b66bab161a05d8f44448ab7d047
317216ae86825fe6d0ea1c43ec3d55743f9f9050e6577fecf61eb47ef528b79f7fa3
0c11007728bdb4ca72441f6978088c7f13442b76df2cf9055b692fed9e0ff09ca7d8
88eb932d88f6936e13fea6911f0ddee4e2a5ee75e0ff3510ec9e8d630032897d321e
97486c550b089d699a8eba2c7ee732ca74b6c8f557e22457d05be79f3d44467d1b0d
b8e30d47fe2dd1432379a915b419df1931c0d7a1622a71cdf9ce2f29b3583f8a52e1
c081d9c6700a27aa1cce21f9bdfa9e1ce7b2a8d3635a374c82bcf949792977b72b6f
1a471fc4a500d1e6b2e2ab71d5da142e11a50b9eba33e6eb0f16e38acadec3a9e5b3
727315ab5c1175d27ce8300e77cc1e4d4210c6b9706af0c98d51da641eb328a6983b
3e3f09ad5107f01ce04712409459ad7130d0789185ed1c9623c7a4256da0d8d54049
bb47fc1b355528662721b34706b256ce48bc49f47d4741aff5cc7d9138a172393d25
3d4b02fd6d6796b6810f3398f99a18e59c8dabd6fb9ccb39db55905e2790986536f8
e7d7106bc85427f7bd519151f3598f57dd50c515a9393113506d8b84e885eff0536c
45707da97d4171bf4e6d1a62ccefc27219acaa7d09ba29f5fc335abdbf2050bf843c
e8405bd0daeff2e38b65669298c9d5e0bfe59a99cbd77064a1fc741292c9066d7ca6
448bb0fedfae12924753e0026bdcae8eb917ffda4050476b07dbc51037a85ce7c87c
22da246316a9d7acd717a0e6c901d180db968e9a20e0e1b63e21371275d8c323c0ca
cf673a84d176b7dbe3341cb2f9636f58657a5f823ba6a6c3962bb93e2fd675e88439
d5a4a0741ca6e57feb57ea6dfe935ce8091af5160fb2d8bb3b4d49516f92784c0994
e7050f2e4bd86b5988f594e6f4754d50d7f31a6bde1de8a76a66e25d60b1d709c2c5
4da1d1469a48105fe2531d51ac56402b5573c548fea65c5da74a4fc907607abe1414
b863143faa88b5c717a0187fa4f1859eac069d464a47060066df19dfb014392c416a
608c0fc8c22a4e4d18e96c8112056d80af32e9d2bd3b4c8b572fb4fd6454a515eb2a
7abf52041a5475da0ffc6b9c54f20f1fb00d7d7c7686d795a895c832e0f2066a3bba
c09e79d0498fdac3d853a3fe09101fb3fa694e2d7f23ffede312da4b8a4a767e385a
18d03de0fc4fd6d82db3fc556f98eb164c20b206036c6a9e5056d53cb2376daf3947
312b6402583e5944d63060619cd98e0a0e4e2fd1ed9b3e4532b68548b93e542d5d15
70342ab95e130db28e43c6bb5feaaea0ece99fced47f1f59dd58c3ef5661a0a1662f
61600df6d3e78e300d381ef79428ff7087a94725af9a3d9fb94cf87ecb121fc58631
9630d63b538ef05cee9a0d6d696e0e727bac95103f213edd50b5d9b124e2c35b61ec
539fd5c1cf7b87309467e626becda9d684d72a333907d34437644e204251cda5ef35
633e39cc62c9f16f85ef04b39017b3f969150e44fd72b3fca4f6636097527211bc55
3e8333ae2fffd0d2a9d125ec476a005729e31650b876b5fb240b0b233a262265e4e5
aa125056c708d58ff2585894b0889ec40b32ccd9e78051afa98320a1f9c9e7cbc1bb
f113bbc85ddd24b00f89d30ef0042fdfdd0c5c37de5842cd09f2a28b3b742c9c6ef9
9d323e4baad0efb6e876a78501a70431720b300f3845aebe2097241e1a1d6962aad7
4a121f804ff5a98d6691983e9262d6b703a16c16bb4c3515b8c99a57cd2fdd76efba
17289ba191fd7698459f1d7c5fd290a66004e41c30dc97994be61ec96fa2838c02bd
1ce9c8859acdbbbf09805b06bdcfdf107e89c1a0291b1124ba2ca5ffe18f68cb0ab4
e3bcecdf4d050a062f229890404609b10c938b4e7eaaeaa06d84fedb3feed1ac717d
95fbce7d3c18b99abcd00f9c04e24bd5c45379ec50578664e87ddf1c5007a7dca208
3c5b3ab4762eac1621f058397f79d13b8ac89099d1590077fc3d39bc4c65d2a19db7
69580874485ff7ef9997a3e9e13a454215ba2a3bfe2f6f0eda2c095fd81404b60d47
ac0e92daf03ef6bd8fc85805af664d6c0039b0f22bf0006eb9abdc8aee91a7570042
5210d7e6b1548384ec4e15822aa003100f09ff247b5617f4d02b92818da9d4ed5e45
0fac24ffcec9f94b79788470cf32f805b85d201899c22247a2178c694b99fc297906
e370d955b1f79babd4e4fa611a56bbca62239f3553b8dd49c8e90cae7bff2cf90f94
36d217a81750f7aa947757268f888d978c4eaabee5215f12c9c6e96fddb2dbd0a793
7c0ff49423f7dd418e8ffcf4bd0812b2e1a9de574816caf231c5088383be311f8cca
b5c7881bf42fbabfd5641a665b82ee5ec8aa591bad064ffb28492adee608e554767d
4e85edaaf9f7e68a955c228cb0a9f93b64e100efc03c68f725e73ee8d563bc8e9912
0eb36511018a98f7108b7b190ab9e28ed35cb7bccb6fb3189d61425ba0f9c08c20c4
684795a3988c124c210be61a4549b043954dceb3766dac9ce780a745bd0ebfdbf2d0
03f96b4923c7be77a100cfce4d67ce81ca290debf2eed43e453c61a1f0cbb27eeb1a
1f054b901d08c38a64c6835cd988287a461a5d795a8669519a2684aad6e19d91817a
ac771cd7565cc14cd78a8b6f5c66e640e3948ab6e6bafd58b7020d2806688aad4c50
2b1427abe8c42edf859689fa51b042f1d6c1d0817a380060e90e046c87083b6fc6c0
570e2bb5c2ddd7eecba3ec4ff9ef16dcd314697df84fd2a42159a884b28de9dfa8c6
8e181f2ae7d1f6ebde04f127df78a4a2d677091340c58e4d855e62cac1d3463307ba
812bff2234978d42b4b9135b66563e6f852a2b25d47828530ddaff4cd660067d09cb
bc8c7adfd23fc356d515a8f822b2e4f96bdf927c6a186f5ab66f39b6909d5d9d3adc
cf9c2f36c88f0d2cd9faaede7d9a343c0123e7e0405640bd19619c530138f2eaf91a
eafd5140b8d3af98ae233a25366433bffaa5a9a5ed0879fcb1f640f4f418f21b88f7
7d986751cb12405e4918baaacbe7fcd93decab057ed05fe3d6d0bf61c12bf92d2dd2
ab67779a847c57af57bcc0558a33c247e3bd30e39cf1e88f54beab53fec3c5b95285
8ba59e8b23bc03ab4270c32649d8ef98bf2bca30f429217b77f23ceb054664c85908
ea86625a1f060e89c8d8407c9ccaed93a7b7bbd9294593d9dff3030f346f94bf1036
3d91a2a4e4e8e921265460c4f6084649728799000000000000000000000000000000
000000000000000000000000050a0f151b242a308601010002466568656c6c6f444e
c359d2ff
        </sourcecode>
      </section>
    </section>
    <section anchor="sec-example-pkc">
      <name>Example Public Key Certificates</name>
      <t>
This section contains example public key certificates corresponding to end-entity private keys and identities used in examples of <xref target="sec-example-ops"/> with structure and extensions conforming to the profile of <xref target="sec-pkix-profile"/>.
All of the example certificates contain a validity time interval extending a short amount around the original bundle creation time of the <xref target="fig-ex-primary-block">original bundle</xref>.
      </t>
      <section>
        <name>Root CA Certificate</name>
        <t>
This root CA certificate and private key are included for completeness in testing <xref target="sec-context-auth-valid-cert">path validation</xref> with a full chain.
This root CA does not allow any intermediates purely as an example, while a typical deployed PKI would separate a root CA from intermediate signing CA(s).
It also does not include any Certificate Policies, Name Constraints, or Policy Constraints extensions as an operational CA might do to express or control how its subordinates are validated and used.
It does, however, include an Extended Key Usage (EKU) value <tt>id-kp-bundleSecurity</tt> which indicates that this certificate tree is authorized for securing BP data.
        </t>
        <figure>
          <name>CA Certificate Content</name>
          <sourcecode type="x509dump">
Version: 3 (0x2)
Serial Number:
    15:15:ff:a7:40:a4:bd:73:f5:ba
Signature Algorithm: ecdsa-with-SHA384
Issuer: CN = Certificate Authority
Validity
    Not Before: Oct  6 00:00:00 2025 GMT
    Not After : Oct 16 00:00:00 2025 GMT
Subject: CN = Certificate Authority
Subject Public Key Info:
    Public Key Algorithm: id-ecPublicKey
        Public-Key: (384 bit)
        pub:
            04:cc:7b:ba:7b:04:77:e0:f7:97:30:40:a1:83:fd:
            0c:8b:44:9f:6f:e2:bd:ab:ec:df:9c:7a:72:e2:2c:
            b3:55:6a:49:64:89:ca:75:f8:09:f1:1f:73:7e:08:
            00:71:c0:e6:1c:06:36:15:68:c2:24:be:ab:29:17:
            54:fd:40:c8:75:b8:be:3f:f7:46:0b:50:d4:28:1b:
            ec:95:d5:34:b4:4a:f4:97:71:5a:09:52:11:e3:59:
            28:b2:fb:f4:55:c7:6a
        ASN1 OID: secp384r1
        NIST CURVE: P-384
X509v3 extensions:
    X509v3 Basic Constraints: critical
        CA:TRUE, pathlen:0
    X509v3 Key Usage: critical
        Certificate Sign, CRL Sign
    X509v3 Extended Key Usage:
        1.3.6.1.5.5.7.3.35
    X509v3 Subject Key Identifier:
        1B:77:33:BE:83:75:66:6A:75:86:22:F2:AB:0A:17:60:3F:42:56:03
    X509v3 Authority Key Identifier:
        1B:77:33:BE:83:75:66:6A:75:86:22:F2:AB:0A:17:60:3F:42:56:03
          </sourcecode>
        </figure>
        <figure>
          <name>CA Certificate PEM</name>
          <sourcecode type="pem">
-----BEGIN CERTIFICATE-----
MIIB8DCCAXagAwIBAgIKFRX/p0CkvXP1ujAKBggqhkjOPQQDAzAgMR4wHAYDVQQD
DBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjUxMDA2MDAwMDAwWhcNMjUxMDE2
MDAwMDAwWjAgMR4wHAYDVQQDDBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwdjAQBgcq
hkjOPQIBBgUrgQQAIgNiAATMe7p7BHfg95cwQKGD/QyLRJ9v4r2r7N+cenLiLLNV
aklkicp1+AnxH3N+CABxwOYcBjYVaMIkvqspF1T9QMh1uL4/90YLUNQoG+yV1TS0
SvSXcVoJUhHjWSiy+/RVx2qjezB5MBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0P
AQH/BAQDAgEGMBMGA1UdJQQMMAoGCCsGAQUFBwMjMB0GA1UdDgQWBBQbdzO+g3Vm
anWGIvKrChdgP0JWAzAfBgNVHSMEGDAWgBQbdzO+g3VmanWGIvKrChdgP0JWAzAK
BggqhkjOPQQDAwNoADBlAjBQLyBu8JDNdPcOkHpJZuH9BIbshDBEn3H+SNBubiS9
sRgqWp+gphgvVUBlo+na0TACMQCv0zQ7tVQHG7n8i3fw6hLNrk4UrwfXX91tcp3M
a9Z6MI8EU1mRAmqkM63oRHeNGS0=
-----END CERTIFICATE-----
          </sourcecode>
        </figure>
        <figure>
          <name>CA Private Key PEM</name>
          <sourcecode type="pem">
-----BEGIN EC PRIVATE KEY-----
MIGkAgEBBDBj90cnyONTJ3DqsSBdr4Df0zZ951wOLbQgqDPC8zw0wcrrQ5CT6+Ov
sA2i87696dWgBwYFK4EEACKhZANiAATMe7p7BHfg95cwQKGD/QyLRJ9v4r2r7N+c
enLiLLNVaklkicp1+AnxH3N+CABxwOYcBjYVaMIkvqspF1T9QMh1uL4/90YLUNQo
G+yV1TS0SvSXcVoJUhHjWSiy+/RVx2o=
-----END EC PRIVATE KEY-----
          </sourcecode>
        </figure>
      </section>
      <section>
        <name>Signing Source End-Entity Certificate</name>
        <t>
This end-entity certificate corresponds with the private key used for signing in <xref target="sec-example-ops-ecc-sign"/>.
It contains a SAN authenticating the single security source from that example, an EKU authorizing the identity, and a Key Usage authorizing the signing.
        </t>
        <figure>
          <name>Signing Certificate Content</name>
          <sourcecode type="x509dump">
Version: 3 (0x2)
Serial Number:
    6f:fe:89:dc:b7:6e:d3:72:ea:7a
Signature Algorithm: ecdsa-with-SHA384
Issuer: CN = Certificate Authority
Validity
    Not Before: Oct  6 00:00:00 2025 GMT
    Not After : Oct 16 00:00:00 2025 GMT
Subject: CN = src
Subject Public Key Info:
    Public Key Algorithm: id-ecPublicKey
        Public-Key: (384 bit)
        pub:
            04:02:df:c4:97:47:f5:d3:d2:19:fe:61:85:74:47:
            29:fa:16:72:ef:7d:11:cb:57:ca:03:20:c6:32:be:
            06:ca:3f:dc:c1:18:e6:31:40:ba:3e:c5:7e:a7:b8:
            5d:41:95:68:45:26:e8:1b:f0:d9:ea:09:24:f0:5a:
            34:53:ad:75:b9:28:06:67:15:11:54:4c:99:3f:6b:
            d9:08:a7:a4:23:9d:47:6c:fd:fd:74:d6:c6:88:36:
            48:8a:d1:e6:0b:0e:7d
        ASN1 OID: secp384r1
        NIST CURVE: P-384
X509v3 extensions:
    X509v3 Basic Constraints: critical
        CA:FALSE
    X509v3 Subject Alternative Name: critical
        othername: 1.3.6.1.5.5.7.8.11::dtn://src/
    X509v3 Key Usage: critical
        Digital Signature
    X509v3 Extended Key Usage:
        1.3.6.1.5.5.7.3.35
    X509v3 Authority Key Identifier:
        1B:77:33:BE:83:75:66:6A:75:86:22:F2:AB:0A:17:60:3F:42:56:03
          </sourcecode>
        </figure>
        <figure>
          <name>Signing Certificate PEM</name>
          <sourcecode type="pem">
-----BEGIN CERTIFICATE-----
MIIB4TCCAWegAwIBAgIKb/6J3Ldu03LqejAKBggqhkjOPQQDAzAgMR4wHAYDVQQD
DBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjUxMDA2MDAwMDAwWhcNMjUxMDE2
MDAwMDAwWjAOMQwwCgYDVQQDDANzcmMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQC
38SXR/XT0hn+YYV0Ryn6FnLvfRHLV8oDIMYyvgbKP9zBGOYxQLo+xX6nuF1BlWhF
Jugb8NnqCSTwWjRTrXW5KAZnFRFUTJk/a9kIp6QjnUds/f101saINkiK0eYLDn2j
fjB8MAwGA1UdEwEB/wQCMAAwJgYDVR0RAQH/BBwwGqAYBggrBgEFBQcIC6AMFgpk
dG46Ly9zcmMvMA4GA1UdDwEB/wQEAwIHgDATBgNVHSUEDDAKBggrBgEFBQcDIzAf
BgNVHSMEGDAWgBQbdzO+g3VmanWGIvKrChdgP0JWAzAKBggqhkjOPQQDAwNoADBl
AjBHljyxGGWxBmV5pz6Mgkn2k8MH9Am0+4ZGzRcEvMORA9R6371sJ0OYpuy1pPrd
rwcCMQDrxYHocIePcAKYQnAAaNbn4pm/GaiTFgoQJWQn1tTMy3CyeocQMB0if57Y
w6Xw0+Y=
-----END CERTIFICATE-----
          </sourcecode>
        </figure>
      </section>
      <section>
        <name>Encryption Recipient End-Entity Certificate</name>
        <t>
This end-entity certificate corresponds with the private key used for decrypting <xref target="sec-example-ops-encrypt-ecc-kw"/> and <xref target="sec-example-ops-encrypt-ecc-hkdf"/>.
It contains a SAN identifying the single security acceptor from that example, an EKU authorizing the identity, and a Key Usage authorizing the key agreement.
        </t>
        <figure>
          <name>Key-Agreement Certificate Content</name>
          <sourcecode type="x509dump">
Version: 3 (0x2)
Serial Number:
    3f:24:0b:cd:a6:f7:fc:3c:29:de
Signature Algorithm: ecdsa-with-SHA384
Issuer: CN = Certificate Authority
Validity
    Not Before: Oct  6 00:00:00 2025 GMT
    Not After : Oct 16 00:00:00 2025 GMT
Subject: CN = dst
Subject Public Key Info:
    Public Key Algorithm: id-ecPublicKey
        Public-Key: (384 bit)
        pub:
            04:00:57:ea:0e:6f:dc:50:dd:c1:11:1b:d8:10:ea:
            e7:c0:ba:24:64:5d:44:d4:71:2d:b0:c8:35:4c:23:
            4b:29:70:b4:ac:27:e7:8f:38:25:00:69:d1:28:f9:
            8e:51:ce:b1:4b:72:c5:0b:27:26:76:37:c4:0a:dc:
            d7:8b:d0:25:e4:b6:54:a6:45:d2:ba:7b:a9:89:4c:
            c7:3b:24:31:d4:cd:c0:40:d6:6e:8e:b2:da:d7:31:
            f7:dc:a5:71:08:54:5c
        ASN1 OID: secp384r1
        NIST CURVE: P-384
X509v3 extensions:
    X509v3 Basic Constraints: critical
        CA:FALSE
    X509v3 Subject Alternative Name: critical
        othername: 1.3.6.1.5.5.7.8.11::dtn://dst/
    X509v3 Key Usage: critical
        Key Agreement
    X509v3 Extended Key Usage:
        1.3.6.1.5.5.7.3.35
    X509v3 Authority Key Identifier:
        1B:77:33:BE:83:75:66:6A:75:86:22:F2:AB:0A:17:60:3F:42:56:03
          </sourcecode>
        </figure>
        <figure>
          <name>Key-Agreement Certificate PEM</name>
          <sourcecode type="pem">
-----BEGIN CERTIFICATE-----
MIIB4DCCAWegAwIBAgIKPyQLzab3/Dwp3jAKBggqhkjOPQQDAzAgMR4wHAYDVQQD
DBVDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMjUxMDA2MDAwMDAwWhcNMjUxMDE2
MDAwMDAwWjAOMQwwCgYDVQQDDANkc3QwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQA
V+oOb9xQ3cERG9gQ6ufAuiRkXUTUcS2wyDVMI0spcLSsJ+ePOCUAadEo+Y5RzrFL
csULJyZ2N8QK3NeL0CXktlSmRdK6e6mJTMc7JDHUzcBA1m6OstrXMffcpXEIVFyj
fjB8MAwGA1UdEwEB/wQCMAAwJgYDVR0RAQH/BBwwGqAYBggrBgEFBQcIC6AMFgpk
dG46Ly9kc3QvMA4GA1UdDwEB/wQEAwIDCDATBgNVHSUEDDAKBggrBgEFBQcDIzAf
BgNVHSMEGDAWgBQbdzO+g3VmanWGIvKrChdgP0JWAzAKBggqhkjOPQQDAwNnADBk
AjArcmaF95pLvgjxXBYa7mtDhEEgnYVsZytcWFu74yLx/7u/mUEsK0AgOrV+uTTo
pqoCMAINw25QZUv9t8r+7lEmAo1em5730riu0Axq1yv0jF0LebLSYP6/fWe0cCwt
/zk1CA==
-----END CERTIFICATE-----
          </sourcecode>
        </figure>
      </section>
    </section>
    <section anchor="sec-cddl-bpsec">
      <name>CDDL Definitions for BPSec</name>
      <t>
The normative definitions of BPSec <xref target="RFC9172"/> do not include corresponding CDDL extending the rules defined for BP.
The following CDDL provides those definitions as an update to that specification.
These definitions include a new socket <tt>$ext-data-asb</tt> for all possible ASB contents and a generic rule <tt>bpsec-context-use</tt> which allows a security context to define a single rule for the ASB socket to include all of their parameter and result types together.
      </t>
      <sourcecode type="cddl"><![CDATA[
; Generic structure of block-type-specific data for BIB and BCB
ext-data-asb = $ext-data-asb .within ext-data-asb-structure
ext-data-asb-structure = [
  targets: [+ target-block-num],
  context-id: int,
  asb-flags,
  security-source: eid,
  ; params present if sec-params-present is set in #asb-flags
  ? parameters: asb-id-value-list,
  ; One result list per item in #targets
  target-results: [+ asb-id-value-list]
]
target-block-num = uint
asb-flags = uint .bits asb-flag-bits
asb-flag-bits = &(
  sec-params-present: 0
)

; Alternatives can be added to the sockets for each context ID
asb-id-value-list = [* asb-id-value-pair]
; Interpretation of the pair depends on the context-id and whether
; it is a parameter or a result.
asb-id-value-pair = [
  id: uint,
  value: any
]

; Provide BPv7 extension block types, they both really embed
; "ext-data-asb" as a cbor sequence.
; Block Integrity Block (BIB)
$extension-block /= extension-block-use<
  11,
  bstr .cborseq ext-data-asb
>
; Block Confidentiality Block (BCB)
$extension-block /= extension-block-use<
  12,
  bstr .cborseq ext-data-asb
>

; Specialization of $ext-data-asb for a security context.
; The ParamPair and ResultPair should be sockets for specializing
; those structures for the individual security context.
bpsec-context-use<ContextId, ParamPair, ResultPair> = [
  targets: [
    + target-block-num
  ],
  context-id: ContextId,
  asb-flags,
  ? security-source: eid,
  ? parameters: [
    + ParamPair .within asb-id-value-pair
  ],
  target-results: [
    + [
      + ResultPair .within asb-id-value-pair
    ]
  ]
]
]]></sourcecode>
    </section>
    <section anchor="sec-doc-ack" numbered="false">
      <name>Acknowledgments</name>
      <t>
Thanks to Lars Baumgaertner and Lukas Holst of the European Space Agency (ESA) for prototyping feedback.
Thanks to David Koisser of SANCTUARY Systems GmbH, Rick Taylor of Aalyria Technologies, and Leonardo Babun of JHU/APL for specification review and feedback.
      </t>
    </section>
    <section removeInRFC="true" numbered="false">
      <name>Implementation Status</name>
      <t>
[NOTE to the RFC Editor: please remove this section before publication, as well as the reference to <xref target="RFC7942"/>, <xref target="github-dtn-bpsec-cose"/>, <xref target="github-dtn-demo-agent"/>, and <xref target="gitlab-wireshark"/>.]
      </t>
      <t>
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
<xref target="RFC7942"/>.
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 can exist.
      </t>
      <t>
A limited implementation of this COSE Context has been added to the <xref target="github-dtn-demo-agent"/> to help with interoperability testing.
      </t>
      <t>
As of the time of writing a COSE Context dissector has been accepted to the default development branch of the Wireshark project <xref target="gitlab-wireshark"/>.
That dissector integrates the full-featured COSE dissector on top of BPSec, so will scale with any future additions to COSE itself.
      </t>
      <t>
An example implementation of this COSE Context has been created as a GitHub project <xref target="github-dtn-bpsec-cose"/> and is intended to use as a proof-of-concept and as a source of data for the examples in <xref target="sec-example-ops"/>.
This example implementation only handles CBOR encoding/decoding and cryptographic functions, it does not construct actual BIB or BCB and does not integrate with a BP Agent.
      </t>
    </section>
  </back>
</rfc>
