azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

Key Vault does not support elliptic curve `secp256k1` on Java 16+

Open vcolin7 opened this issue 3 years ago • 4 comments

Oracle stopped supporting some elliptic curves starting on Java 16 and one of those is secp256k1, which needs to be supported by Key Vault Key's CryptographyClient when running on local mode only, that is, not communicating with the Key Vault service to perform cryptographic operations.

Given that we are trying to transition from supporting Java 11 to Java 17 in the Azure SDK, we need to figure out a way to support cryptographic operations that use this algorithm.

Options for achieving this are:

  • Using a third-party library
  • Writing our own implementation
  • Allowing users to pass their own Security Providers via method overloads. (Suggested in #25570 as well for different reasons).
  • Shading the code that Oracle used for this and including it with the SDK

NOTE: Tests that fail due to this on Java 17 have been disabled for the time being.

vcolin7 avatar Jan 25 '22 02:01 vcolin7

any news on this?

eliquinox avatar Mar 20 '22 23:03 eliquinox

any news ?

hhanquez avatar Jun 28 '22 13:06 hhanquez

Any chance of getting it addressed?

pentiak avatar Sep 12 '22 08:09 pentiak

Any news ?

VinceBCD avatar Sep 15 '22 10:09 VinceBCD

Hi everyone, sorry for the lack of updates, we had a few other items ahead of this in our queue. I will start working on an alternative for our Java 16+ users soon. In the meantime, you can still create and use keys with elliptic curve secp256k1 by using the Cryptography clients in default mode, that is, letting the client delegate these tasks to the Key Vault service as opposed to doing the operations locally.

vcolin7 avatar Oct 06 '22 18:10 vcolin7

Hi @vcolin7 , are there any updates (or workaround) on this issue? Our code is failing on Java 17 as well.

 final CryptographyClient cryptoClient =
        vault.fetchKey(config.getKeyName(), config.getKeyVersion());

    final byte[] dataToSign = needsToHash ? Hash.sha3(data) : data;
    final SignResult result = cryptoClient.sign(signingAlgo, dataToSign);
java.lang.IllegalStateException: java.security.InvalidAlgorithmParameterException: Curve not supported: secp256k1 (1.3.132.0.10)
at com.azure.security.keyvault.keys.models.JsonWebKey.toEc(JsonWebKey.java:816) ~[azure-security-keyvault-keys-4.6.0.jar:4.6.0]
at com.azure.security.keyvault.keys.cryptography.EcKeyCryptographyClient.<init>(EcKeyCryptographyClient.java:49) ~[azure-security-keyvault-keys-4.6.0.jar:4.6.0]

How do you switch CryptographyClient from local mode to default mode?

usmansaleem avatar Apr 12 '23 03:04 usmansaleem

@usmansaleem, looking at your mention, have you confirmed that both local and default(remote) signing modes do not work on newer JREs?

pentiak avatar Jun 12 '23 09:06 pentiak

@pentiak our code is constructing CryptographyClient is follows:

    return new CryptographyClientBuilder()
        .credential(tokenCredential)
        .keyIdentifier(keyId)
        .buildClient();

The exception is raised when we perform cryptoClient.sign(...) operation. I am not 100% sure how to set local mode? The default mode definitely failed in Java 17 because it does not support SECP256K1 curve anymore (though BouncyCastle does). We need SECP256K1 because our code deals in signing for Eth1 private keys.

usmansaleem avatar Jun 12 '23 13:06 usmansaleem

I would really like this bug to be fixed. It is the only thing holding us back from upgrading JRE & Spring.

pentiak avatar Jul 07 '23 10:07 pentiak

Please fix this bug ! Or at least answer to this question !

How do you switch CryptographyClient from local mode to default mode?

hhanquez avatar Jul 07 '23 13:07 hhanquez

Hey folks, I'm sorry it took so long to address this. I just merged a change in PR #36657 to ensure the CryptographyClient goes back to use the service if it was not able to create a crypto client for local-only operation, which is the case when trying to use elliptic curve secp256k1 in Java 16+. We'll release this change in a new version in the next few days.

vcolin7 avatar Sep 13 '23 20:09 vcolin7

Hi @vcolin7, we deeply appreciate your input into this project. Regrettably, this issue has remained inactive for over 2 years, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.

github-actions[bot] avatar Mar 13 '24 18:03 github-actions[bot]