Conversation
…nt over the first
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AEADBaseEngine.StreamCipherOperator.processBytessplits a decryption call that spans the buffered authentication tag into two output segments: bytes released from the tag buffer, then bytes taken straight from the input. The first is written atoutOffand advances the running countrlt, but the second is written atoutOffas well instead of atoutOff + rlt. The second therefore overwrites the head of the first, and the tail of the reported output is never written. The call still returns the full byte count, and the state update does not depend on where the output lands, sodoFinalstill accepts the tag: the wrong plaintext comes back with nothing raised. The equivalent step of the general decryption path,processEncDecBytes, already writes atoutOff + resultLength.Grain128AEADEngineis the only engine that selectsDataOperatorType.StreamCipher, so this is confined to chunked Grain-128AEAD decryption, where a chunk after the first carries more than the 8-byteMAC_SIZE. One-shot decryption, the encryption path and all other AEAD engines are unaffected. Grain-128AEAD is lightweight-API only, so callers constructGrain128AEADEnginedirectly.Reproduced on the released bcprov-jdk18on-1.86.jar: across a sweep of chunk boundaries 9156 of 12800 streamed decryptions returned plaintext differing from the one-shot result; a separate split sweep recorded 63 wrong plaintexts with zero tag failures and zero exceptions, and a 16 KiB read loop returned 12232 wrong bytes at a 4096-byte read size with the tag verifying. This is not fallout from the 1.86 lightweight-AEAD performance work, which covered Elephant, PhotonBeetle, Romulus and GIFT-COFB, not Grain-128AEAD: the 1.85.2 source reproduces the identical failure, the one functional change to
AEADBaseEnginebetween them is theprocessBytesingle-byte buffer, and the same call is present as far back as 1.81. Currentmainand the 1.87-SNAPSHOT beta (build 1.87.0.20709) match 1.86 here in source and in compiled classes, and both reproduce it.This change:
outOff + rlt; andtestStreamedDecryptiontoGrain128AEADTestthat splits a ciphertext at every point and asserts the streamed plaintext matches the one-shot decryption and the original, plus aCipherTest.checkAEADCipherMultipleBlockscall at PARTLEN 19 beside the existing 7. The existing call never reaches the second segment, sincelen > MAC_SIZEis never true at PARTLEN 7;testSplitUpdateonly initialises for encryption. Both added checks fail without the change and pass with it; the nine pre-existing checks pass either way, LWC_AEAD_KAT_128_96.txt included.Base tree only; no
module-infoor OSGi change is needed. A release-note entry is included, happy to move it to another block.