fix: [WLEO-339] Add function to remove leading zero from base64url encoded JWK properties#211
Merged
manuraf merged 5 commits intoeudiw-masterfrom Apr 4, 2025
Merged
fix: [WLEO-339] Add function to remove leading zero from base64url encoded JWK properties#211manuraf merged 5 commits intoeudiw-masterfrom
manuraf merged 5 commits intoeudiw-masterfrom
Conversation
grausof
requested changes
Apr 2, 2025
grausof
approved these changes
Apr 2, 2025
This was referenced Apr 4, 2025
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.
Warning
Breaking change for IT Wallet!
List of Changes
fixBase64WithLeadingZero(with its underlying helper,removeLeadingZeroAndParseB64Url), to sanitize JSON Web Key (JWK) properties. It addresses potential issues with cryptographic operations by processing the base64url encoded key components (x, y, e, and n). The new functions decode the input, remove any unwanted leading zero, and then re-encode the result to ensure proper formatting.fixBase64EncodingOnKeyinsideCryptoContextMotivation and Context
The method
getPublicKeyin theio-react-native-cryptolibrary returns a key with coordinates in base64 format. This base64 format is generated by converting hex to base64 internally, but sometimes the conversion does not conform to the P-256 key standard—which requires exactly 32 bytes—because the hex representation may result in 33 bytes.The problem stems from the behavior of BigInteger.toByteArray, which, in certain contexts (e.g., ASN.1 DER signatures), prepends a 0x00 byte if the coordinate starts with a value greater than 0x7F to avoid it being interpreted as a negative number.
This PR aims to temporarily bypass the issue within this library by ensuring that any unwanted leading zero is removed during the conversion process.
How Has This Been Tested?
Screenshots (if appropriate):
Checklist: