Skip to content

Add secp256k1 & brainpool EC curves #60

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

Closed
wants to merge 6 commits into from

Conversation

waltkb
Copy link
Contributor

@waltkb waltkb commented Feb 12, 2025

No description provided.

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 initiative and PR!
Are those added curves (brainpool) supported by both openssl and JDK (with BC and with default) providers?
It would be nice to add tests for them.

Additionally, you will need to run apiDump task

@waltkb
Copy link
Contributor Author

waltkb commented Feb 19, 2025

secp256k1:

  • I can confirm this works with val provider = CryptographyProvider.JDK(BouncyCastleProvider()).
  • On the normal JVM provider (val provider = CryptographyProvider.JDK) this also works for me.
  • I also verified that with cryptography-provider-openssl3-prebuilt it works

brainpoolP256r1:

  • works with val provider = CryptographyProvider.JDK(BouncyCastleProvider())
  • and also val provider = CryptographyProvider.Openssl3

@whyoleg
Copy link
Owner

whyoleg commented Feb 19, 2025

Nice!
That means that we could add tests for those in:

  • EcdsaTest - in both tests, probably curves could be extracted in class variable
  • EcCompatibilityTest - it will affect both ECDH and ECDSA tests. Let's add all curves there and see how will it affect tests duration on CI.

secp256k1 is already tested there, so only brainpool curves should be added to tests

@whyoleg
Copy link
Owner

whyoleg commented Apr 15, 2025

Hey @waltkb, are you planning to finalize PR based on the comment above, or could I finish it by myself?

@waltkb
Copy link
Contributor Author

waltkb commented Apr 18, 2025

Hi, is it fine like this now?

@waltkb waltkb requested a review from whyoleg April 23, 2025 22: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.

Nice!
Some small remarks and we are good to go!


generateDigests { digest, _ ->
if (!supportsDigest(digest)) return@generateDigests
if (!supportsDigest(digest)) {
println("Skipping digest $digest for curve ${curve.name}")
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 remove all such println?
It's possible to enable more logging for supports* and executes algorithms via flipping enabled flag here

In case you think that the logging is necessary, please use logger.log, as there could be problems with excessive logging on CI if enabled :(

assertEquals(
rawSignatureSize,
sigEmpty.size,
"RAW signature size mismatch for empty data on ${curve.name} / ${digest.name}"
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 for adding those!

@@ -87,27 +149,41 @@ abstract class EcdsaTest(provider: CryptographyProvider) : AlgorithmTest<ECDSA>(

@Test
fun testFunctions() = testWithAlgorithm {
if (!supportsFunctions()) return@testWithAlgorithm
if (!supportsFunctions()) {
println("Skipping function test because functions are not supported by provider")
Copy link
Owner

@whyoleg whyoleg Apr 24, 2025

Choose a reason for hiding this comment

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

same here about println (in whole file)

@@ -24,40 +24,94 @@ abstract class EcdsaTest(provider: CryptographyProvider) : AlgorithmTest<ECDSA>(
data class EcdsaSize(
val curve: EC.Curve,
val rawSignatureSize: Int,
val derSignatureSizes: List<Int>,
val derSignatureSizes: IntRange,
Copy link
Owner

Choose a reason for hiding this comment

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

nice idea!

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

sake commented Jun 16, 2025

Hi there! Thanks for the work on adding the BP curves.
As I need to use these curves for a project I would like to help to get this into the next release.

I made a patch replacing the println statements.
https://github.com/sake/cryptography-kotlin/tree/add-ec-curves

As the merge request has conflicts I also performed a rebase against main.
https://github.com/sake/cryptography-kotlin/tree/add-ec-curves-rebased

I can issue a merge request against the walt repo if that helps.
If there is anything more I can do, I'm happy to help.

@whyoleg
Copy link
Owner

whyoleg commented Jun 16, 2025

Hey @sake!
Thanks for taking care of it!
Feel free to create a PR with your changes (rebased one) against the main (whyoleg) repo.
As far as I see, the commits still show @waltkb as an author, so it should be fine, and so both of you will become contributors after the PR is merged :)

@whyoleg
Copy link
Owner

whyoleg commented Jun 18, 2025

Merged via #78

@whyoleg whyoleg closed this Jun 18, 2025
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.

3 participants