-
-
Notifications
You must be signed in to change notification settings - Fork 33
Add support for encoding/decoding compressed EC keys #57
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
Conversation
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.
Thanks for the PR!
Looks nice!
Here is the first round of review. I still need to check JDK implementation, as it contains more hand-written logic :)
| else -> null | ||
| format.name == "JWK" && !provider.isWebCrypto | ||
| -> "JWK key format" | ||
| format == EC.PublicKey.Format.RAW.Compressed && provider.isApple |
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.
could you please mention this in limitations of apple provider?
cryptography-providers/webcrypto/src/commonMain/kotlin/algorithms/WebCryptoEc.kt
Show resolved
Hide resolved
| val ecKey = checkError(EVP_PKEY_get1_EC_KEY(key)) | ||
| val ecGroup = checkError(EC_KEY_get0_group(ecKey)) | ||
| val ecPoint = checkError(EC_KEY_get0_public_key(ecKey)) |
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.
Those functions are deprecated in openssl:
- https://docs.openssl.org/3.1/man3/EC_KEY_new/#synopsis
- https://docs.openssl.org/3.1/man3/EVP_PKEY_set1_RSA/#synopsis
Could you please replace them?
Looks like we need to find a way to provide OPENSSL_API_COMPAT to cinterop to hide those declarations to avoid usage them in future
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.
FYI: I was able to enforce OPENSSL_NO_DEPRECATED in cinterop in eeea305 and now those declarations are not available.
This commit will be soon merged into main, so if you willing to proceed with changing those you can temporary cherry-pick it from whyoleg/dev branch
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.
Sorry for the late reply. I will check when free.
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.
No problem, take your time.
FYI: openssl changes mentioned are already in main, so you can just rebase.
FYI2: At the current moment, I plan to do a release in mid-June, so it would be really nice to include those changes in it, along with your other contribution of RIPEMD!
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've replaced those deprecated methods.
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.
Thanks for the PR one more and sorry for long review.
Finally I was able to validate the JDK implementation and left some small remarks.
Let's resolve them, migrate OpenSSL implementation to use non-deprecated APIs and we are good to go!
cryptography-providers/jdk/src/jvmMain/kotlin/algorithms/JdkEc.kt
Outdated
Show resolved
Hide resolved
cryptography-providers/jdk/src/jvmMain/kotlin/algorithms/JdkEc.kt
Outdated
Show resolved
Hide resolved
cryptography-providers/jdk/src/jvmMain/kotlin/algorithms/JdkEc.kt
Outdated
Show resolved
Hide resolved
|
Hey @huskcasaca, are you still willing to finish the PR? It's fine if you have no time for it. Just ping me, and I will rebase and finalize PR in your branch and so your contribution will still be there :) |
|
Sorry, can give me another week? |
|
@huskcasaca, yeah, sure, the release is planned by the end of the June, so you have roughly two weeks, otherwise it will go into the next major (0.6.0) release (as it's an ABI change) |
Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
# Conflicts: # cryptography-providers/jdk/src/jvmMain/kotlin/algorithms/JdkEc.kt
|
Added support for CryptoKit |
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.
Thanks for the work!
I will merge the PR right after the CI build
| ) | ||
| throws -> SwiftEcdhPublicKey | ||
| { | ||
| guard #available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *) else { |
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.
Nice!
| * For compressed points, the y-coordinate is computed by solving the curve equation: | ||
| * y² = x³ + ax + b (mod p) | ||
| * | ||
| * References: |
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.
Nice, thanks!
This PR add support for
CompressedandUncompressed(default) format underRAWEC Public Key.