corretto / amazon-corretto-crypto-provider

The Amazon Corretto Crypto Provider is a collection of high-performance cryptographic implementations exposed via standard JCA/JCE interfaces.
Apache License 2.0
237 stars 56 forks source link

Which elliptic curves are supported #47

Closed PythEsc closed 5 years ago

PythEsc commented 5 years ago

Hi,

from your README I have seen that ACCP supports elliptical curves. Unfortunately it does not describe which curves exactly are supported. For my application I need support for the NIST and Brainpool curves. NIST is usually supported, but what about Brainpool?

I would also like to know if the provider offers an X509 CertificateFactory implementation and if it is planned to release a Windows 64-bit version of the provider on maven.

Best,

Florian

SalusaSecondus commented 5 years ago

For curves I'll need a bit more time to dig up the answer to make sure I get you fully accurate information. It's a little complicated because it has to do with the interactions between the native and the Java code.

For the other two:

SalusaSecondus commented 5 years ago

The curves question is (as I mentioned) a tad complicated. We support the intersection of the curves supported by OpenSSL 1.0.2 and the Java environment we are using. This is because we need OpenSSL to actually do the math but we need Java to manage the keys, curves, appropriate KeyFactorys and similar. This means that on a standard Java install we only support those curves listed in the EcGenTest because the default providers which come with Java do not support other curves.

BouncyCastle, however, does support more curves (including the Brainpool curves). This means that if BouncyCastle is a sufficiently high priority provider on your system that ACCP can use it to parse and handle the keys. Specifically, if ACCP is the highest priority provider and BouncyCastle is the second highest priority provider, then ACCP can use libcrypto to do the cryptography using Brainpool curves and leverage BouncyCastle for the key handling in java.

public class BPTest {
    public static void main(String args[]) throws Exception {
        // Inserts BouncyCastle at the highest priority
        Security.insertProviderAt(new BouncyCastleProvider(), 1);
        // Inserts ACCP at the highest priority, bumping down the others (including BouncyCastle)
        AmazonCorrettoCryptoProvider.install();
        System.out.println(Arrays.toString(Security.getProviders()));

        KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");

        kpg.initialize(new ECGenParameterSpec("brainpoolp192t1"));
        System.out.println(kpg.generateKeyPair().getPublic());
        System.out.println("KeyPairGenerator Provider: " + kpg.getProvider());
    }
}

Please let me know if this answers your questions.

PythEsc commented 5 years ago

Hello @SalusaSecondus,

thank you so much. This information is really useful. We're already using the Bouncycastle provider, so it shouldn't be a problem for us to go the way you suggested. We expect to see improved performance in TLS handshake with the addition of ACCP. Especially the SHAwithECDSA verification is still very slow at the moment and could be significantly faster with an OpenSSL based implementation.

I think we'll have to evaluate this a bit more, but it sounds pretty promising.

If I understood your first answer correctly, then I should continue to use Sun/Bouncycastle implementations to generate the keys and certificate objects, but can pass the Bouncycastle X509 implementation to your provider?

SalusaSecondus commented 5 years ago

My recommendation is that you configure your providers as follows and then (whenever possible) don't use an explicit provider for any calls to getInstance(), but rather let the system just figure out which implementation to use.

  1. AmazonCorrettoCryptoProvider
  2. BouncyCastleCryptoProvider
  3. (And lower) All standard Java providers in the standard order.

So, this means you wouldn't explicitly use BouncyCastle (or Sun) for key generation or parsing certificates. Rather Java would figure out that those are the highest priority providers which implement certificate parsing (and would use ACCP for key generation). It isn't that ACCP cannot generate Brainpool keys, it just cannot (currently) generate them without the assistance of BouncyCastle for parsing them.

PythEsc commented 5 years ago

Okay, thanks for clearing up the final details. I think we can close this ticket. Unfortunately we can't use ACCP up to Windows 64 bit support anyway. I follow your issue on this topic and as soon as something happens and there are first releases, we will do an evaluation with ACCP.