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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

waltkb
Copy link

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

Choose a reason for hiding this comment

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

save 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants