<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.6.13 (Ruby 2.7.0) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-core-oscore-key-limits-00" category="std" consensus="true" submissionType="IETF" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.16.0 -->
  <front>
    <title abbrev="Key Usage Limits for OSCORE">Key Usage Limits for OSCORE</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-core-oscore-key-limits-00"/>
    <author initials="R." surname="Höglund" fullname="Rikard Höglund">
      <organization>RISE AB</organization>
      <address>
        <postal>
          <street>Isafjordsgatan 22</street>
          <city>Kista</city>
          <code>16440 Stockholm</code>
          <country>Sweden</country>
        </postal>
        <email>rikard.hoglund@ri.se</email>
      </address>
    </author>
    <author initials="M." surname="Tiloca" fullname="Marco Tiloca">
      <organization>RISE AB</organization>
      <address>
        <postal>
          <street>Isafjordsgatan 22</street>
          <city>Kista</city>
          <code>16440 Stockholm</code>
          <country>Sweden</country>
        </postal>
        <email>marco.tiloca@ri.se</email>
      </address>
    </author>
    <date year="2023" month="March" day="13"/>
    <area>Internet</area>
    <workgroup>CoRE Working Group</workgroup>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <t>Object Security for Constrained RESTful Environments (OSCORE) uses AEAD algorithms to ensure confidentiality and integrity of exchanged messages. Due to known issues allowing forgery attacks against AEAD algorithms, limits should be followed on the number of times a specific key is used for encryption or decryption. Among other reasons, approaching key usage limits requires updating the OSCORE keying material before communications can securely continue. This document defines how two OSCORE peers can follow these key usage limits and what steps they should take to preserve the security of their communications.</t>
    </abstract>
    <note removeInRFC="true">
      <name>Discussion Venues</name>
      <t>Discussion of this document takes place on the
  Constrained RESTful Environments Working Group mailing list (core@ietf.org),
  which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/core/"/>.</t>
      <t>Source for this draft and an issue tracker can be found at
  <eref target="https://gitlab.com/crimson84/draft-tiloca-core-oscore-to-proxies"/>.</t>
    </note>
  </front>
  <middle>
    <section anchor="intro">
      <name>Introduction</name>
      <t>Object Security for Constrained RESTful Environments (OSCORE) <xref target="RFC8613"/> provides end-to-end protection of CoAP <xref target="RFC7252"/> messages at the application-layer, ensuring message confidentiality and integrity, replay protection, as well as binding of response to request between a sender and a recipient.</t>
      <t>In particular, OSCORE uses AEAD algorithms to provide confidentiality and integrity of messages exchanged between two peers. Due to known issues allowing forgery attacks against AEAD algorithms, limits should be followed on the number of times a specific key is used to perform encryption or decryption <xref target="I-D.irtf-cfrg-aead-limits"/>.</t>
      <t>The original OSCORE specification <xref target="RFC8613"/> does not consider such key usage limits. However, should they be exceeded, an adversary may break the security properties of the AEAD algorithm, such as message confidentiality and integrity, e.g., by performing a message forgery attack. Among other reasons, approaching the key usage limits requires updating the OSCORE keying material before communications can securely continue. This document defines what steps an OSCORE peer should take to preserve the security of its communications, by stopping to use the OSCORE Security Context shared with another peer when approaching the key usage limits.</t>
      <section anchor="terminology">
        <name>Terminology</name>
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they appear in all capitals, as shown here.</t>
        <t>Readers are expected to be familiar with the terms and concepts related to CoAP <xref target="RFC7252"/> and OSCORE <xref target="RFC8613"/>.</t>
      </section>
    </section>
    <section anchor="aead-key-usage-limits-in-oscore">
      <name>AEAD Key Usage Limits in OSCORE</name>
      <t>This section details how key usage limits for AEAD algorithms can be considered when using OSCORE. In particular, it discusses specific limits for common AEAD algorithms used with OSCORE; parameters to track associated to an OSCORE Security Context; and additions to the OSCORE message processing.</t>
      <section anchor="problem-overview">
        <name>Problem Overview</name>
        <t>The OSCORE security protocol <xref target="RFC8613"/> uses AEAD algorithms to provide integrity and confidentiality of messages, as exchanged between two peers sharing an OSCORE Security Context.</t>
        <t>When processing messages with OSCORE, each peer should follow specific limits as to the number of times it uses a specific key. This applies separately to the Sender Key used to encrypt outgoing messages, and to the Recipient Key used to decrypt and verify incoming protected messages.</t>
        <t>Exceeding these limits may allow an adversary to break the security properties of the AEAD algorithm, such as message confidentiality and integrity, e.g., by performing a message forgery attack.</t>
        <t>The following refers to the two parameters 'q' and 'v' introduced in <xref target="I-D.irtf-cfrg-aead-limits"/>, to use when deploying an AEAD algorithm.</t>
        <ul spacing="normal">
          <li>'q': this parameter has as value the number of messages protected with a specific key, i.e., the number of times the AEAD algorithm has been invoked to encrypt data with that key.</li>
          <li>'v': this parameter has as value the number of alleged forgery attempts that have been made against a specific key, i.e., the amount of failed decryptions that have occurred with the AEAD algorithm for that key.</li>
        </ul>
        <t>When a peer uses OSCORE:</t>
        <ul spacing="normal">
          <li>The key used to protect outgoing messages is its Sender Key from its Sender Context.</li>
          <li>The key used to decrypt and verify incoming messages is its Recipient Key from its Recipient Context.</li>
        </ul>
        <t>Both keys are derived as part of the establishment of the OSCORE Security Context, as defined in <xref section="3.2" sectionFormat="of" target="RFC8613"/>.</t>
        <t>As mentioned above, exceeding specific limits for the 'q' or 'v' value can weaken the security properties of the AEAD algorithm used, thus compromising secure communication requirements.</t>
        <t>Therefore, in order to preserve the security of the used AEAD algorithm, OSCORE has to observe limits for the 'q' and 'v' values, throughout the lifetime of the used AEAD keys.</t>
        <section anchor="limits">
          <name>Limits for 'q' and 'v'</name>
          <t>Formulas for calculating the security levels, as Integrity Advantage (IA) and Confidentiality Advantage (CA) probabilities, are presented in <xref target="I-D.irtf-cfrg-aead-limits"/>. These formulas take as input specific values for 'q' and 'v' (see section <xref target="problem-overview"/>) and for 'l', i.e., the maximum length of each message (in cipher blocks).</t>
          <t>For the algorithms shown in <xref target="algorithm-limits"/> that can be used as AEAD Algorithm for OSCORE, the key property to achieve is having IA and CA values which are no larger than p = 2^-64, which will ensure a safe security level for the AEAD Algorithm. This can be entailed by using the values q = 2^20, v = 2^20, and l = 2^10, that this document recommends to use for these algorithms.</t>
          <t><xref target="algorithm-limits"/> also shows the resulting IA and CA probabilities enjoyed by the considered algorithms, when taking the value of 'q', 'v' and 'l' above as input to the formulas defined in <xref target="I-D.irtf-cfrg-aead-limits"/>.</t>
          <figure anchor="algorithm-limits">
            <name>Probabilities for algorithms based on chosen q, v and l values.</name>
            <artwork align="center"><![CDATA[
+------------------------+----------------+----------------+
| Algorithm name         | IA probability | CA probability |
|------------------------+----------------+----------------|
| AEAD_AES_128_CCM       | 2^-64          | 2^-66          |
| AEAD_AES_128_GCM       | 2^-97          | 2^-89          |
| AEAD_AES_256_GCM       | 2^-97          | 2^-89          |
| AEAD_CHACHA20_POLY1305 | 2^-73          | -              |
+------------------------+----------------+----------------+
]]></artwork>
          </figure>
          <t>When AEAD_AES_128_CCM_8 is used as AEAD Algorithm for OSCORE, the triplet (q, v, l) considered above yields larger values of IA and CA. Hence, specifically for AEAD_AES_128_CCM_8, this document recommends using the triplet (q, v, l) = (2^20, 2^14, 2^8). This is appropriate, since the resulting CA and IA values are not greater than the threshold value of 2^-50 defined in <xref target="I-D.irtf-cfrg-aead-limits"/>, and thus yields an acceptable security level. Achieving smaller values of CA and IA would require to inconveniently reduce 'q', 'v' or 'l', with no corresponding increase in terms of security, as further elaborated in <xref target="aead-aes-128-ccm-8-details"/>.</t>
          <figure anchor="l-values-as-bytes">
            <name>Maximum length of each message (in bytes)</name>
            <artwork align="center"><![CDATA[
+------------------------+----------+----------+-----------+
| Algorithm name         | l=2^6 in | l=2^8 in | l=2^10 in |
|                        | bytes    | bytes    | bytes     |
|------------------------+----------+----------|-----------|
| AEAD_AES_128_CCM       | 1024     | 4096     | 16384     |
| AEAD_AES_128_GCM       | 1024     | 4096     | 16384     |
| AEAD_AES_256_GCM       | 1024     | 4096     | 16384     |
| AEAD_AES_128_CCM_8     | 1024     | 4096     | 16384     |
| AEAD_CHACHA20_POLY1305 | 4096     | 16384    | 65536     |
+------------------------+----------+----------+-----------+
]]></artwork>
          </figure>
        </section>
      </section>
      <section anchor="context">
        <name>Additional Information in the Security Context</name>
        <t>In addition to what defined in <xref section="3.1" sectionFormat="of" target="RFC8613"/>, the following parameters, associated to an OSCORE Security Context, can be used for keeping track of expiration of an OSCORE Security Context and maintaining key usage below safe limits.</t>
        <section anchor="common-context">
          <name>Common Context</name>
          <t>The Common Context has the following associated parameter.</t>
          <ul spacing="normal">
            <li>
              <t>'exp': with value the expiration time of the OSCORE Security Context, as a non-negative integer. The parameter contains a numeric value representing the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time, ignoring leap seconds, analogous to what specified for NumericDate in <xref section="2" sectionFormat="of" target="RFC7519"/>.  </t>
              <t>
At the time indicated in this field, a peer must stop using this Security Context to process any incoming or outgoing message, and is required to establish a new Security Context to continue OSCORE-protected communications with the other peer.</t>
            </li>
          </ul>
        </section>
        <section anchor="sender-context">
          <name>Sender Context</name>
          <t>The Sender Context has the following associated parameters.</t>
          <ul spacing="normal">
            <li>'count_q': a non-negative integer counter, keeping track of the current 'q' value for the Sender Key. At any time, 'count_q' has as value the number of messages that have been encrypted using the Sender Key. The value of 'count_q' is set to 0 when establishing the Sender Context.</li>
            <li>
              <t>'limit_q': a non-negative integer, which specifies the highest value that 'count_q' is allowed to reach, before stopping using the Sender Key to process outgoing messages.  </t>
              <t>
The value of 'limit_q' depends on the AEAD algorithm specified in the Common Context, considering the properties of that algorithm. The value of 'limit_q' is determined according to <xref target="limits"/>.</t>
            </li>
          </ul>
          <t>Note for implementation: it is possible to avoid storing and maintaining the counter 'count_q'. Rather, an estimated value to be compared against 'limit_q' can be computed, by leveraging the Sender Sequence Number of the peer and (an estimate of) the other peer's. A possible method to achieve this is described in <xref target="estimation-count-q"/>. While this relieves peers from storing and maintaining the precise 'count_q' value, it results in overestimating the number of encryptions performed with a Sender Key. This in turn results in approaching 'limit_q' sooner and thus in performing a key update procedure more frequently.</t>
        </section>
        <section anchor="recipient-context">
          <name>Recipient Context</name>
          <t>The Recipient Context has the following associated parameters.</t>
          <ul spacing="normal">
            <li>'count_v': a non-negative integer counter, keeping track of the current 'v' value for the Recipient Key. At any time, 'count_v' has as value the number of failed decryptions occurred on incoming messages using the Recipient Key. The value of 'count_v' is set to 0 when establishing the Recipient Context.</li>
            <li>
              <t>'limit_v': a non-negative integer, which specifies the highest value that 'count_v' is allowed to reach, before stopping using the Recipient Key to process incoming messages.  </t>
              <t>
The value of 'limit_v' depends on the AEAD algorithm specified in the Common Context, considering the properties of that algorithm. The value of 'limit_v' is determined according to <xref target="limits"/>.</t>
            </li>
          </ul>
        </section>
      </section>
      <section anchor="oscore-messages-processing">
        <name>OSCORE Messages Processing</name>
        <t>In order to keep track of the 'q' and 'v' values and ensure that AEAD keys are not used beyond reaching their limits, the processing of OSCORE messages is extended as defined in this section. A limitation that is introduced is that, in order to not exceed the selected value for 'l', the total size of the COSE plaintext, authentication Tag, and possible cipher padding for a message may not exceed the block size for the selected algorithm multiplied with 'l‘.</t>
        <t>In particular, the processing of OSCORE messages follows the steps outlined in <xref section="8" sectionFormat="of" target="RFC8613"/>, with the additions defined below.</t>
        <section anchor="protecting-req-resp">
          <name>Protecting a Request or a Response</name>
          <t>Before encrypting the COSE object using the Sender Key, the 'count_q' counter is incremented.</t>
          <t>If 'count_q' exceeds the 'limit_q' limit, the message processing is aborted. From then on, the Sender Key must not be used to encrypt further messages.</t>
        </section>
        <section anchor="verifying-req-resp">
          <name>Verifying a Request or a Response</name>
          <t>If an incoming message is detected to be a replay (see <xref section="7.4" sectionFormat="of" target="RFC8613"/>), the 'count_v' counter is not incremented.</t>
          <t>If the decryption and verification of the COSE object using the Recipient Key fails, the 'count_v' counter is incremented.</t>
          <t>After 'count_v' has exceeded the 'limit_v' limit, incoming messages must not be decrypted and verified using the Recipient Key, and their processing must be aborted.</t>
        </section>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>This document mainly covers security considerations about using AEAD keys in OSCORE and their usage limits, in addition to the security considerations of <xref target="RFC8613"/>.</t>
      <t>[TODO: Add more considerations.]</t>
    </section>
    <section anchor="iana">
      <name>IANA Considerations</name>
      <t>This document has no IANA actions.</t>
    </section>
  </middle>
  <back>
    <references>
      <name>References</name>
      <references>
        <name>Normative References</name>
        <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author fullname="S. Bradner" initials="S." surname="Bradner">
              <organization/>
            </author>
            <date month="March" year="1997"/>
            <abstract>
              <t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
          <seriesInfo name="DOI" value="10.17487/RFC2119"/>
        </reference>
        <reference anchor="RFC7252" target="https://www.rfc-editor.org/info/rfc7252">
          <front>
            <title>The Constrained Application Protocol (CoAP)</title>
            <author fullname="Z. Shelby" initials="Z." surname="Shelby">
              <organization/>
            </author>
            <author fullname="K. Hartke" initials="K." surname="Hartke">
              <organization/>
            </author>
            <author fullname="C. Bormann" initials="C." surname="Bormann">
              <organization/>
            </author>
            <date month="June" year="2014"/>
            <abstract>
              <t>The Constrained Application Protocol (CoAP) is a specialized web transfer protocol for use with constrained nodes and constrained (e.g., low-power, lossy) networks.  The nodes often have 8-bit microcontrollers with small amounts of ROM and RAM, while constrained networks such as IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs) often have high packet error rates and a typical throughput of 10s of kbit/s.  The protocol is designed for machine- to-machine (M2M) applications such as smart energy and building automation.</t>
              <t>CoAP provides a request/response interaction model between application endpoints, supports built-in discovery of services and resources, and includes key concepts of the Web such as URIs and Internet media types.  CoAP is designed to easily interface with HTTP for integration with the Web while meeting specialized requirements such as multicast support, very low overhead, and simplicity for constrained environments.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="7252"/>
          <seriesInfo name="DOI" value="10.17487/RFC7252"/>
        </reference>
        <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author fullname="B. Leiba" initials="B." surname="Leiba">
              <organization/>
            </author>
            <date month="May" year="2017"/>
            <abstract>
              <t>RFC 2119 specifies common key words that may be used in protocol  specifications.  This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the  defined special meanings.</t>
            </abstract>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
          <seriesInfo name="DOI" value="10.17487/RFC8174"/>
        </reference>
        <reference anchor="RFC8613" target="https://www.rfc-editor.org/info/rfc8613">
          <front>
            <title>Object Security for Constrained RESTful Environments (OSCORE)</title>
            <author fullname="G. Selander" initials="G." surname="Selander">
              <organization/>
            </author>
            <author fullname="J. Mattsson" initials="J." surname="Mattsson">
              <organization/>
            </author>
            <author fullname="F. Palombini" initials="F." surname="Palombini">
              <organization/>
            </author>
            <author fullname="L. Seitz" initials="L." surname="Seitz">
              <organization/>
            </author>
            <date month="July" year="2019"/>
            <abstract>
              <t>This document defines Object Security for Constrained RESTful Environments (OSCORE), a method for application-layer protection of the Constrained Application Protocol (CoAP), using CBOR Object Signing and Encryption (COSE).  OSCORE provides end-to-end protection between endpoints communicating using CoAP or CoAP-mappable HTTP. OSCORE is designed for constrained nodes and networks supporting a range of proxy operations, including translation between different transport protocols.</t>
              <t>Although an optional functionality of CoAP, OSCORE alters CoAP options processing and IANA registration.  Therefore, this document updates RFC 7252.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="8613"/>
          <seriesInfo name="DOI" value="10.17487/RFC8613"/>
        </reference>
      </references>
      <references>
        <name>Informative References</name>
        <reference anchor="RFC7519" target="https://www.rfc-editor.org/info/rfc7519">
          <front>
            <title>JSON Web Token (JWT)</title>
            <author fullname="M. Jones" initials="M." surname="Jones">
              <organization/>
            </author>
            <author fullname="J. Bradley" initials="J." surname="Bradley">
              <organization/>
            </author>
            <author fullname="N. Sakimura" initials="N." surname="Sakimura">
              <organization/>
            </author>
            <date month="May" year="2015"/>
            <abstract>
              <t>JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties.  The claims in a JWT are encoded as a JSON object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or integrity protected with a Message Authentication Code (MAC) and/or encrypted.</t>
            </abstract>
          </front>
          <seriesInfo name="RFC" value="7519"/>
          <seriesInfo name="DOI" value="10.17487/RFC7519"/>
        </reference>
        <reference anchor="I-D.irtf-cfrg-aead-limits" target="https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-aead-limits-06">
          <front>
            <title>Usage Limits on AEAD Algorithms</title>
            <author fullname="Felix Günther" initials="F." surname="Günther">
              <organization>ETH Zurich</organization>
            </author>
            <author fullname="Martin Thomson" initials="M." surname="Thomson">
              <organization>Mozilla</organization>
            </author>
            <author fullname="Christopher A. Wood" initials="C. A." surname="Wood">
              <organization>Cloudflare</organization>
            </author>
            <date day="30" month="January" year="2023"/>
            <abstract>
              <t>   An Authenticated Encryption with Associated Data (AEAD) algorithm
   provides confidentiality and integrity.  Excessive use of the same
   key can give an attacker advantages in breaking these properties.
   This document provides simple guidance for users of common AEAD
   functions about how to limit the use of keys in order to bound the
   advantage given to an attacker.  It considers limits in both single-
   and multi-key settings.

              </t>
            </abstract>
          </front>
          <seriesInfo name="Internet-Draft" value="draft-irtf-cfrg-aead-limits-06"/>
        </reference>
      </references>
    </references>
    <section anchor="aead-aes-128-ccm-8-details">
      <name>Detailed considerations for AEAD_AES_128_CCM_8</name>
      <t>For the AEAD_AES_128_CCM_8 algorithm when used as AEAD Algorithm for OSCORE, larger IA and CA values are achieved, depending on the value of 'q', 'v' and 'l'. <xref target="algorithm-limits-ccm8"/> shows the resulting IA and CA probabilities enjoyed by AEAD_AES_128_CCM_8, when taking different values of 'q', 'v' and 'l' as input to the formulas defined in <xref target="I-D.irtf-cfrg-aead-limits"/>.</t>
      <t>As shown in <xref target="algorithm-limits-ccm8"/>, it is especially possible to achieve the lowest IA = 2^-50 and a good CA = 2^-70 by considering the largest possible value of the (q, v, l) triplet equal to (2^20, 2^10, 2^8), while still keeping a good security level. Note that the value of 'l' does not impact on IA, while CA displays good values for every considered value of 'l'.</t>
      <figure anchor="algorithm-limits-ccm8">
        <name>Probabilities for AEAD_AES_128_CCM_8 based on chosen q, v and l values.</name>
        <artwork align="center"><![CDATA[
+-----------------------+----------------+----------------+
| 'q', 'v' and 'l'      | IA probability | CA probability |
|-----------------------+----------------+----------------|
| q=2^20, v=2^20, l=2^8 | 2^-44          | 2^-70          |
| q=2^15, v=2^20, l=2^8 | 2^-44          | 2^-80          |
| q=2^10, v=2^20, l=2^8 | 2^-44          | 2^-90          |
| q=2^20, v=2^15, l=2^8 | 2^-49          | 2^-70          |
| q=2^15, v=2^15, l=2^8 | 2^-49          | 2^-80          |
| q=2^10, v=2^15, l=2^8 | 2^-49          | 2^-90          |
| q=2^20, v=2^14, l=2^8 | 2^-50          | 2^-70          |
| q=2^15, v=2^14, l=2^8 | 2^-50          | 2^-80          |
| q=2^10, v=2^14, l=2^8 | 2^-50          | 2^-90          |
| q=2^20, v=2^10, l=2^8 | 2^-54          | 2^-70          |
| q=2^15, v=2^10, l=2^8 | 2^-54          | 2^-80          |
| q=2^10, v=2^10, l=2^8 | 2^-54          | 2^-90          |
|-----------------------+----------------+----------------|
| q=2^20, v=2^20, l=2^6 | 2^-44          | 2^-74          |
| q=2^15, v=2^20, l=2^6 | 2^-44          | 2^-84          |
| q=2^10, v=2^20, l=2^6 | 2^-44          | 2^-94          |
| q=2^20, v=2^15, l=2^6 | 2^-49          | 2^-74          |
| q=2^15, v=2^15, l=2^6 | 2^-49          | 2^-84          |
| q=2^10, v=2^15, l=2^6 | 2^-49          | 2^-94          |
| q=2^20, v=2^14, l=2^6 | 2^-50          | 2^-74          |
| q=2^15, v=2^14, l=2^6 | 2^-50          | 2^-84          |
| q=2^10, v=2^14, l=2^6 | 2^-50          | 2^-94          |
| q=2^20, v=2^10, l=2^6 | 2^-54          | 2^-74          |
| q=2^15, v=2^10, l=2^6 | 2^-54          | 2^-84          |
| q=2^10, v=2^10, l=2^6 | 2^-54          | 2^-94          |
+-----------------------+----------------+----------------+
]]></artwork>
      </figure>
    </section>
    <section anchor="estimation-count-q">
      <name>Estimation of 'count_q'</name>
      <t>This section defines a method to compute an estimate of the counter 'count_q' (see <xref target="sender-context"/>), hence not requiring a peer to store it in its own Sender Context.</t>
      <t>This method relies on the fact that, at any point in time, a peer has performed <em>at most</em> ENC = (SSN + SSN*) encryptions using its own Sender Key, where:</t>
      <ul spacing="normal">
        <li>SSN is the current value of this peer's Sender Sequence Number.</li>
        <li>SSN* is the current value of other peer's Sender Sequence Number. That is, SSN* is an overestimation of the responses without Partial IV that this peer has sent.</li>
      </ul>
      <t>Thus, when protecting an outgoing message (see <xref target="protecting-req-resp"/>), the peer aborts the message processing if the estimated est_q &gt; limit_q, where est_q = (SSN + X) and X is determined as follows.</t>
      <ul spacing="normal">
        <li>If the outgoing message is a response, X is the Partial IV specified in the corresponding request that this peer is responding to. Note that X &lt; SSN* always holds.</li>
        <li>If the outgoing message is a request, X is the highest Partial IV value marked as received in this peer's Replay Window plus 1, or 0 if it has not accepted any protected message from the other peer yet. That is, X is the highest Partial IV specified in message received from the other peer, i.e., the highest seen Sender Sequence Number of the other peer. Note that, also in this case, X &lt; SSN* always holds.</li>
      </ul>
    </section>
    <section anchor="sec-document-updates">
      <name>Document Updates</name>
      <t>RFC EDITOR: PLEASE REMOVE THIS SECTION.</t>
      <section anchor="sec-00">
        <name>Version -00</name>
        <ul spacing="normal">
          <li>Editorial improvements.</li>
          <li>Extended terminology.</li>
          <li>Recommendation on limits for CCM_8. Details in Appendix.</li>
          <li>Example of method to estimate and not store 'count_q'.</li>
          <li>Split out material from Key Update for OSCORE draft into this new document.</li>
        </ul>
      </section>
    </section>
    <section numbered="false" anchor="acknowledgments">
      <name>Acknowledgments</name>
      <t>The authors sincerely thank <contact fullname="Christian Amsüss"/>, <contact fullname="Carsten Bormann"/>, <contact fullname="John Preuß Mattsson"/>, <contact fullname="Göran Selander"/> and <contact fullname="Rafa Marin-Lopez"/> for their feedback and comments.</t>
      <t>The work on this document has been partly supported by VINNOVA and the Celtic-Next project CRITISEC; and by the H2020 project SIFIS-Home (Grant agreement 952652).</t>
    </section>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA81cW3PbOJZ+169A2Q+Oe0St7NiOo9lsrVpWOp6JLys56Z6d
zKQgEpLQJgmFFykax1v7M/Zt/8U87Vv/k/0le84BQILUzUlP1bYrFTMkARyc
y3duYDzPa8w77HmjkcksFB32R7Fk71I+EeytjGSWsrFK2M2wdzPoN/holIj5
9ncC5cc8gomChI8zT4ps7PkqEZ5K6de9WHohjfJCnok0azT2WZrxOPjIQxXD
wCzJRaMhZwldptlxu/2yfdzgieAddhlnIolF1lhMOqynBn32o0ruZTxhPyQq
nzXuF+U73gWS0PB51oEVgkaajyKZplLF2XIGC1327143Gr4KYHiH5UDoeWMm
Owx+9pnPY5angvEk4Uv2TI4ZD0O2FOkhg81OeTplU5EAoYxlyu/gE7hMVZIl
Ypx2aI5AjHkeAn8yZZ8vI/0Y/9ngeTZVSafB6MczvxmTMbwxaLE3v/x9EuZx
UDzQnB3Ie54Eq09VAtsYXA77rPt9cTMFegQw4DLl459VEqQTDsxmx8fFG77M
liBTCUIo76kAFhr2vaOzk5M2G8IW76cqjJwX8jhLYNxwIQIRF/dFxGXYYQmR
2JoqovBfE9lKxfptXrXYnQyVz2ubvO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