]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Clarify some code in epoch with better comments
authorArne Schwabe <arne@rfc2549.org>
Wed, 3 Dec 2025 12:57:34 +0000 (13:57 +0100)
committerGert Doering <gert@greenie.muc.de>
Thu, 4 Dec 2025 13:17:45 +0000 (14:17 +0100)
Change-Id: I34e6b680618a52003d8408852d415c8aeac01feb
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1190
Message-Id: <20251203125741.29239-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg34829.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/crypto.c
src/openvpn/crypto.h

index 8049b3a56772c50ae26fa658bfb90aced9c815f7..e43bc6cf17733a4026d4cd0b437db88806376cb1 100644 (file)
@@ -97,6 +97,13 @@ openvpn_encrypt_aead(struct buffer *buf, struct buffer work, struct crypto_optio
         /* IV starts with packet id to make the IV unique for packet */
         if (use_epoch_data_format)
         {
+            /* Note this does not check aead_usage_limit but can overstep it by
+             * a few extra blocks in one extra write. This is not affecting the
+             * security margin as these extra blocks are on a completely
+             * different order of magnitude than the security margin.
+             * The next iteration/call to epoch_check_send_iterate will
+             * iterate the epoch
+             */
             if (!packet_id_write_epoch(&opt->packet_id.send, ctx->epoch, &iv_buffer))
             {
                 msg(D_CRYPT_ERRORS, "ENCRYPT ERROR: packet ID roll over");
index 72c6821a16f895a444ef73fb46fb48ba3c089393..9424fd74b6c5f62c6f009ae2b3ba19a2a4b6a954 100644 (file)
@@ -298,7 +298,8 @@ struct crypto_options
 
     /** last epoch_key used for generation of the current send data keys.
      * As invariant, the epoch of epoch_key_send is always kept >= the epoch of
-     * epoch_key_recv */
+     * key_ctx_bi.decrypt.epoch
+     */
     struct epoch_key epoch_key_send;
 
     /** epoch_key used for the highest receive epoch keys */
@@ -309,7 +310,8 @@ struct crypto_options
 
     /** The limit for AEAD cipher, this is the sum of packets + blocks
      * that are allowed to be used. Will switch to a new epoch if this
-     * limit is reached*/
+     * limit is reached.
+     */
     uint64_t aead_usage_limit;
 
     /** Keeps the future epoch data keys for decryption. The current one