[BUG] CBC ciphertext stealing differs from CBC-CS3 #10
Labels
No labels
alpha-1
bug
ci
docs
duplicate
enhancement
help wanted
invalid
performance
phase-6
question
refactor
security
wontfix
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
erix/lib-aes#10
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The CTS functions do not produce the stated CBC-CS3 format. Partial blocks use the wrong chaining block; aligned inputs of at least two blocks omit the required final-block exchange. Encryption and decryption mirror these errors, so their round-trip test passes while independent ciphertext answers fail.
Reproduction
Use the AES-256 key and IV from NIST SP 800-38A F.2.5, with its first 17 plaintext bytes. The independent controls also cover every byte length through 64. On revision
52c81b0760f4646f3e38fee1eea5c4b6334e5d40, both directions fail for partial and aligned ciphertext, consistently.To run the independent controls against the previous implementation in a disposable checkout:
Expected and actual behavior
For the 17-byte input, expected ciphertext is
29d372a201f3b07d72f459881d34e62ef5; actual ciphertext is38ea91680df3dcf7fcf02234b9dd9dc7cf5. For 32 bytes, the implementation returns ordinary CBC instead of exchanging the final complete blocks. NIST SP 800-38A Addendum section 4 defines the required ordering.Environment and identity
52c81b0760f4646f3e38fee1eea5c4b6334e5d40.Evidence and prior checks
The four independent encryption/decryption controls fail on the preceding source and pass after the correction. They use 49 fixed answers derived from independent CBC output and the NIST CS3 specification. The old round-trip control passes on the defective source.
Tracking
The filename consumer is lib-fs-crypto. Correcting this format changes previously nonstandard ciphertext; stored data needs an explicit owner-managed migration rather than an automatic alternate-mode fallback.
The correction is now on
mainthrough #6, including the independent CBC-CS3 answers and key-schedule ownership checks. The filesystem filename consumer also passed its original debug/release checks against the corrected AES main and is merged. The explicit migration requirement for earlier prototype ciphertext still applies.