OCB split AAD aborts when a buffered block becomes block 65,536
Closed, ResolvedPublic

Assigned To
None
Authored By
werner
Tue, Aug 4, 5:03 PM
Subscribers

Description

OCB split AAD aborts when a buffered block becomes block 65,536

The split-input AAD path increments aad_nblocks after completing a buffered block. At the 65,536-block table boundary it correctly detects overflow, but asks ocb_get_L_big for aad_nblocks + 1. That helper requires a boundary-aligned block number, so the off-by-one request reaches an internal assertion and aborts the process.

Vulnerable code

In cipher/cipher-ocb.c, function _gcry_cipher_ocb_authenticate:

c->u_mode.ocb.aad_nblocks++;

if ((c->u_mode.ocb.aad_nblocks % table_maxblks) == 0)
  {
    /* Table overflow, L needs to be generated. */
    ocb_get_L_big(c, c->u_mode.ocb.aad_nblocks + 1, l_tmp);
  }

Why it matters

The red/green test first supplied 65,535 full blocks plus one byte, then the remaining 15 bytes. That ordinary split completes block 65,536 and reliably triggers the assertion; passing the current count instead made the test succeed. The total AAD is about one MiB, making the condition realistic wherever an attacker can control both AAD size and update boundaries. The impact is availability, not tag forgery.

Proposed fix

Pass c->u_mode.ocb.aad_nblocks to ocb_get_L_big in this buffered-block branch, matching the block actually being authenticated. Add regression vectors that compare one-shot and split AAD around blocks 65,535 through 65,537, including every possible split within the boundary block, and ensure tags match without assertions.

Related Objects

StatusAssignedTask
ResolvedNone

Event Timeline

werner triaged this task as Normal priority.Tue, Aug 4, 5:03 PM
werner created this task.
werner created this object with visibility "Public (No Login Required)".
werner created this object with edit policy "Contributor (Project)".

Comment by jk: Looks as valid OCB-AAD bug, triggerable with specific buffer sizes:

  • 65536 blocks + 1byte buffer
  • 1 block - 1byte buffer

Should be fixed.

werner shifted this object from the Restricted Space space to the S1 Public space.