-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add optional target length #44
Conversation
3dcfbe3
to
65ea7f8
Compare
65ea7f8
to
bfae48a
Compare
}) | ||
|
||
it("uncompresses raw P-256 public keys", async () => { | ||
let uncompressedFrom02 = TKHQ.uncompressRawPublicKey(TKHQ.uint8arrayFromHexString("02c6de3e1d08270d39076651a2b14fd38031dae89892dc124d2f9557816e7e5da4")); | ||
expect(uncompressedFrom02).toEqual(TKHQ.uint8arrayFromHexString("04c6de3e1d08270d39076651a2b14fd38031dae89892dc124d2f9557816e7e5da4f510c344715f84cf0ba0cc71bd04136c0fb2633a3f459e68ffb8620be16900f0", "hex")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this "hex"
parameter was not being used prior
@@ -208,16 +208,23 @@ <h2>Message log</h2> | |||
}; | |||
|
|||
/** | |||
* Takes a hex string (e.g. "e4567ab") and returns an array buffer (Uint8Array) | |||
* Takes a hex string (e.g. "e4567abc") and returns an array buffer (Uint8Array) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: e4567abc
is of even-length
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beauty 🙏
auth/index.html
Outdated
@@ -496,21 +503,22 @@ <h2>Message log</h2> | |||
/** | |||
* Converts a `BigInt` into a base64url encoded string | |||
* @param {BigInt} num | |||
* @param {number} length: optional expected length of the resulting buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't return a buffer, it returns a string. So...maybe this is "number of bytes contained in the resulting string"? Tricky tricky.
* @returns {Uint8Array} | ||
*/ | ||
var uint8arrayFromHexString = function(hexString) { | ||
var uint8arrayFromHexString = function(hexString, length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a test to exercise this new behavior? e.g. uint8arrayFromHexString("0001")
(should result in a buffer with a single byte) vs uint8arrayFromHexString("0001", 2)
(should result in a buffer with 2 bytes)
Some randomly generated credentials would not be large enough to fully occupy the expected length of 32 bytes. This is specifically to address an issue where a JWT token would have
d
,x
, ory
values that are too short.Here's a sample error message:
Note that this PR does not add similar optionality to other iframes (import/export), since those do not require importing a JWT token.
Sample webcrypto tests can be found here: https://chromium.googlesource.com/chromium/src/+/master/components/test/data/webcrypto/bad_ec_keys.json
Tested locally by: creating a credential that results in a buffer of length 31 for any of the
d
,x
, ory
components of the JWT, ensuring that the buffer is padded, and that ultimately the credential can be injected + used to stamp a payload.Screen.Recording.2024-07-23.at.5.03.38.PM.mov