Fix: signature copy offset, CMAC slice, urandom FD#121
Closed
ariawisp wants to merge 1 commit intowhyoleg:mainfrom
Closed
Fix: signature copy offset, CMAC slice, urandom FD#121ariawisp wants to merge 1 commit intowhyoleg:mainfrom
ariawisp wants to merge 1 commit intowhyoleg:mainfrom
Conversation
…ndom FD check - ECDSA/signature: copyFrom=0 when writing into destination with offset to avoid truncated/garbled output (JDK, Apple, OpenSSL3) - JDK SignatureGenerator: same fix for signIntoByteArray - OpenSSL3 CMAC: use startIndex/endIndex slice in EVP_MAC_update instead of whole array - Linux URandom: consider fd<0 as error (fd==0 is valid) Build: jvmMainClasses and jvmTest for JDK provider pass; metadata compilation for Apple/OpenSSL3 OK.
Owner
|
Fixed into ecaa965 |
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.
Summary
Fixes three correctness/security issues:
startIndex..endIndex) instead of the entire array./dev/urandomopen: treat onlyfd < 0as error (0 is a valid descriptor).Why these changes are correct
Signature copy offset
signIntoByteArray(destination, destinationOffset)contract writes the full signature atdestinationOffset. UsingcopyInto(destination, destinationOffset, destinationOffset)erroneously interprets the offset as the source start index, truncating whendestinationOffset > 0.copyInto(destination, destinationOffset, 0, size), i.e. copy from the start of the signature into the requested offset.public expect fun ByteArray.copyInto(destination: ByteArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = size): ByteArrayCMAC slice update (OpenSSL 3)
EVP_MAC_update(ctx, data, datalen)digests exactly thedatalenbytes starting atdata. PassingsafeAddressOf(0)andsource.sizeignores the requested slice and can MAC unintended bytes.safeAddressOf(startIndex)and(endIndex - startIndex)matches the streaming API’supdate(source, startIndex, endIndex)contract./dev/urandomfile descriptor checkopen(2)returns a non-negative file descriptor on success; only-1indicates error. FD0is valid (stdin) and can be returned depending on process state.fd <= 0tofd < 0avoids false-positive error handling.Impact
fd = 0.Validation
Follow‑ups (separate PR)