Skip to content

Conversation

@huskcasaca
Copy link
Contributor

@huskcasaca huskcasaca commented Dec 13, 2024

This PR add support for Compressed and Uncompressed(default) format under RAW EC Public Key.

  • JDK(BC)
  • WebCrypto
  • Apple (Not Supported)
  • CryptoKit
  • OpenSSL3

@huskcasaca huskcasaca marked this pull request as ready for review December 18, 2024 03:51
@whyoleg whyoleg self-requested a review January 19, 2025 22:32
Copy link
Owner

@whyoleg whyoleg left a 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
Copy link
Owner

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?

Comment on lines 104 to 106
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))
Copy link
Owner

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:

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

Copy link
Owner

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

Copy link
Contributor Author

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.

Copy link
Owner

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!

Copy link
Contributor Author

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.

@whyoleg whyoleg linked an issue May 13, 2025 that may be closed by this pull request
Copy link
Owner

@whyoleg whyoleg left a 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!

@whyoleg whyoleg added the enhancement New feature or request label May 24, 2025
@whyoleg
Copy link
Owner

whyoleg commented Jun 16, 2025

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 :)

@huskcasaca
Copy link
Contributor Author

Sorry, can give me another week?

@whyoleg
Copy link
Owner

whyoleg commented Jun 17, 2025

@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)

@huskcasaca
Copy link
Contributor Author

Added support for CryptoKit

@huskcasaca huskcasaca requested a review from whyoleg June 25, 2025 15:26
Copy link
Owner

@whyoleg whyoleg left a 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 {
Copy link
Owner

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:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks!

@whyoleg whyoleg merged commit e7c5eca into whyoleg:main Jun 26, 2025
86 of 89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for encoding/decoding compressed EC keys

2 participants