Skip to content
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

Java 13 (I know...) Compatibility - XDH Key Generation (Works on Java 12) #589

Closed
brcolow opened this issue Sep 11, 2019 · 39 comments
Closed

Comments

@brcolow
Copy link

brcolow commented Sep 11, 2019

I am not sure if this has anything to do with Bouncycastle. Java 13 has JEP 353 which rewrites (parts) of the legacy socket API. I am using Bouncycastle 1.62.

When I try to connect to Amazon AWS DynamoDB on Java 13, I get the following (partial) stack trace:

Caused by: java.lang.RuntimeException: Could not generate XDH keypair
at java.base/sun.security.ssl.XDHKeyExchange$XDHEPossession.<init>(XDHKeyExchange.java:110)
at java.base/sun.security.ssl.NamedGroup$XDHFunctions.createPossession(NamedGroup.java:750)
at java.base/sun.security.ssl.NamedGroup.createPossession(NamedGroup.java:390)
at java.base/sun.security.ssl.SSLKeyExchange$T13KeyAgreement.createPossession(SSLKeyExchange.java:568)
at java.base/sun.security.ssl.SSLKeyExchange.createPossessions(SSLKeyExchange.java:84)
at java.base/sun.security.ssl.KeyShareExtension$CHKeyShareProducer.produce(KeyShareExtension.java:255)
at java.base/sun.security.ssl.SSLExtension.produce(SSLExtension.java:571)
at java.base/sun.security.ssl.SSLExtensions.produce(SSLExtensions.java:250)
at java.base/sun.security.ssl.ClientHello$ClientHelloKickstartProducer.produce(ClientHello.java:649)
at java.base/sun.security.ssl.SSLHandshake.kickstart(SSLHandshake.java:519)
at java.base/sun.security.ssl.ClientHandshakeContext.kickstart(ClientHandshakeContext.java:107)
at java.base/sun.security.ssl.TransportContext.kickstart(TransportContext.java:231)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:430)
... 61 more
Caused by: java.security.InvalidAlgorithmParameterException: invalid parameterSpec: java.security.spec.NamedParameterSpec@15e0fe05
at org.bouncycastle.jcajce.provider.asymmetric.edec.KeyPairGeneratorSpi.initialize(Unknown Source)
at java.base/java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:699)
at java.base/sun.security.ssl.XDHKeyExchange$XDHEPossession.<init>(XDHKeyExchange.java:105)
... 73 more

Downgrading to the latest nightly build of the Java 12 repository makes the error go away.

The actual chain of events here is that the Amazon AWS SDK is calling Apache's HTTP client which is trying to make an SSL connection. I am not 100% sure how Bouncycastle comes into it unless the only XDH provider accessible is Bouncycastle? I tried to put the provider at position 2, but it made no difference.

I believe the full stack trace where a custom AWS Lambda runtime calls a Lambda request handler, calls DynamoDB, calls Apache, calls, etc. etc. is essentially obfuscation. I think this would show up trying to make an SSL connection to Amazon's DynamoDB server that happens to use XDH key exchange. I see some changes to the sun.security.ssl.SSLSocketImpl classes (as well as other classes in the stack trace) new to Java 13 (most likely related to the aforementioned JEP).

This could very well be a bug in the new Java socket implementation and if so I will certainly open this upstream.

Thanks for your time.

@brcolow
Copy link
Author

brcolow commented Sep 11, 2019

Click to expand (Full Stack Trace)
Caused by: javax.net.ssl.SSLException: Could not generate XDH keypair
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:133)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:324)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:267)
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:262)
at java.base/sun.security.ssl.SSLSocketImpl.handleException(SSLSocketImpl.java:1652)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:443)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:436)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:384)
at software.amazon.awssdk.http.apache.internal.conn.SdkTlsSocketFactory.connectSocket(SdkTlsSocketFactory.java:113)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:374)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at software.amazon.awssdk.http.apache.internal.conn.ClientConnectionManagerFactory$Handler.invoke(ClientConnectionManagerFactory.java:80)
at com.sun.proxy.$Proxy5.connect(Unknown Source)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at software.amazon.awssdk.http.apache.internal.impl.ApacheSdkHttpClient.execute(ApacheSdkHttpClient.java:72)
at software.amazon.awssdk.http.apache.ApacheHttpClient.execute(ApacheHttpClient.java:240)
at software.amazon.awssdk.http.apache.ApacheHttpClient.access$500(ApacheHttpClient.java:106)
at software.amazon.awssdk.http.apache.ApacheHttpClient$1.call(ApacheHttpClient.java:221)
at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.executeHttpRequest(MakeHttpRequestStage.java:66)
at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:51)
at software.amazon.awssdk.core.internal.http.pipeline.stages.MakeHttpRequestStage.execute(MakeHttpRequestStage.java:35)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.RequestPipelineBuilder$ComposingRequestPipelineStage.execute(RequestPipelineBuilder.java:206)
at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:64)
at software.amazon.awssdk.core.internal.http.pipeline.stages.ApiCallAttemptTimeoutTrackingStage.execute(ApiCallAttemptTimeoutTrackingStage.java:36)
at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:77)
at software.amazon.awssdk.core.internal.http.pipeline.stages.TimeoutExceptionHandlingStage.execute(TimeoutExceptionHandlingStage.java:39)
at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.doExecute(RetryableStage.java:113)
at software.amazon.awssdk.core.internal.http.pipeline.stages.RetryableStage$RetryExecutor.execute(RetryableStage.java:86)
... 27 more
Caused by: java.lang.RuntimeException: Could not generate XDH keypair
at java.base/sun.security.ssl.XDHKeyExchange$XDHEPossession.<init>(XDHKeyExchange.java:110)
at java.base/sun.security.ssl.NamedGroup$XDHFunctions.createPossession(NamedGroup.java:750)
at java.base/sun.security.ssl.NamedGroup.createPossession(NamedGroup.java:390)
at java.base/sun.security.ssl.SSLKeyExchange$T13KeyAgreement.createPossession(SSLKeyExchange.java:568)
at java.base/sun.security.ssl.SSLKeyExchange.createPossessions(SSLKeyExchange.java:84)
at java.base/sun.security.ssl.KeyShareExtension$CHKeyShareProducer.produce(KeyShareExtension.java:255)
at java.base/sun.security.ssl.SSLExtension.produce(SSLExtension.java:571)
at java.base/sun.security.ssl.SSLExtensions.produce(SSLExtensions.java:250)
at java.base/sun.security.ssl.ClientHello$ClientHelloKickstartProducer.produce(ClientHello.java:649)
at java.base/sun.security.ssl.SSLHandshake.kickstart(SSLHandshake.java:519)
at java.base/sun.security.ssl.ClientHandshakeContext.kickstart(ClientHandshakeContext.java:107)
at java.base/sun.security.ssl.TransportContext.kickstart(TransportContext.java:231)
at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:430)
... 61 more
Caused by: java.security.InvalidAlgorithmParameterException: invalid parameterSpec: java.security.spec.NamedParameterSpec@7318daf8
at org.bouncycastle.jcajce.provider.asymmetric.edec.KeyPairGeneratorSpi.initialize(Unknown Source)
at java.base/java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:699)
at java.base/sun.security.ssl.XDHKeyExchange$XDHEPossession.<init>(XDHKeyExchange.java:105)
... 73 more

@peterdettman
Copy link
Collaborator

peterdettman commented Sep 12, 2019

So it turns out that JDK 13 builds have added support for X25519 and X448 to the SunJSSE provider: https://bugs.openjdk.java.net/browse/JDK-8171279 . The SunJSSE provider relies on other provider(s) to supply KeyPairGenerator, KeyFactory and KeyAgreement engines.

BC provider has implementations for all these, but unfortunately SunJSSE is using java.security.spec.NamedParameterSpec (a type introduced in JDK 11) as the AlgorithmParameterSpec when initialising the X25519/X448 KeyPairGenerator, and BC doesn't recognize/support it (yet), and so the error.

Lowering the priority of the BC provider should avoid this, but it would need to be moved below the SunEC provider in the list.

Another option is to set the system property jdk.tls.namedGroups so that x25519 and x448 are not enabled. e.g.:
jdk.tls.namedGroups="secp256r1, secp384r1, ffdhe2048, ffdhe3072"
(this covers the most common named groups besides X25519/X448, but you may need to add more).

Thanks for the early report of a looming issue; we'll add NamedParameterSpec support for our next release.

@brcolow
Copy link
Author

brcolow commented Sep 12, 2019

Thanks for the information and fast response. So essentially we need to add an override method to
https://github.com/bcgit/bc-java/blob/25b8c29939f4c80ae42f274a74bf6f299bc9c084/prov/src/main/java/org/bouncycastle/jcajce/provider/asymmetric/edec/KeyPairGeneratorSpi.java ?

Namely:

   @Override
  public void initialize(AlgorithmParameterSpec params,
                SecureRandom random) {
        NamedParameterSpec nps = (NamedParameterSpec) params;
        // Etc...
   }

If this is the right approach I could try and submit a PR.

@peterdettman
Copy link
Collaborator

Well we already have that method, but it needs to also recognise NamedParameterSpec. That's relatively trivial; the complication is that NamedParameterSpec was added in JDK 11 but our jars have to run on earlier JDKs still. It's probably best to just leave it with us for now.

@brcolow
Copy link
Author

brcolow commented Sep 12, 2019

Gotcha. Thanks again.

@brcolow
Copy link
Author

brcolow commented Sep 27, 2019

Even with:

    static {
        if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
            int requestedPosition = 2;
            int actualPosition = Security.insertProviderAt(new BouncyCastleProvider(), 9999);
            System.out.println("Requested to add BouncyCastleProvider at position: " + requestedPosition +
                    " and was actually added at position: " + actualPosition);
        }
    }

The Bouncycastle provider is still being called and the same error is resulting.

@bcgit bcgit self-assigned this Sep 28, 2019
@brcolow
Copy link
Author

brcolow commented Oct 2, 2019

The System.setProperty("jdk.tls.namedGroups", "secp256r1, secp384r1, ffdhe2048, ffdhe3072"); work-around does indeed work.

@peterdettman
Copy link
Collaborator

OK, glad that's working. Moving the provider to after SunEC provider should also work; the code snippet shown above does not convince me that you tested this properly.

@brcolow
Copy link
Author

brcolow commented Oct 3, 2019

Is there a way to query what "slot" the SunEC provider is in to make sure that BouncyCastle is after that number?

@peterdettman
Copy link
Collaborator

Well you can see the list in your java.security config file, and even install BC that way. If it has to be programmatic, then look at the other methods available on java.security.Security class, in particular the getProviders method will return all installed providers "in their preference order".

@bcgit
Copy link
Collaborator

bcgit commented Oct 6, 2019

Okay, I think this is now fixed, I've added handling of any algorithm parameter spec that has a getName() method. This will appear in 1.64.

@spadou
Copy link

spadou commented Oct 18, 2019

Hi, using 1.64 I have the following exception:

Caused by: java.lang.ClassCastException: class org.bouncycastle.jcajce.provider.asymmetric.edec.BCXDHPublicKey cannot be cast to class java.security.interfaces.XECPublicKey (org.bouncycastle.jcajce.provider.asymmetric.edec.BCXDHPublicKey is in unnamed module of loader 'app'; java.security.interfaces.XECPublicKey is in module java.base of loader 'bootstrap')
	at java.base/sun.security.ssl.XDHKeyExchange$XDHEPossession.<init>(XDHKeyExchange.java:108)
	at java.base/sun.security.ssl.NamedGroup$XDHFunctions.createPossession(NamedGroup.java:750)
	at java.base/sun.security.ssl.NamedGroup.createPossession(NamedGroup.java:390)
	at java.base/sun.security.ssl.SSLKeyExchange$T13KeyAgreement.createPossession(SSLKeyExchange.java:568)
	at java.base/sun.security.ssl.SSLKeyExchange.createPossessions(SSLKeyExchange.java:84)
	at java.base/sun.security.ssl.KeyShareExtension$CHKeyShareProducer.produce(KeyShareExtension.java:255)
	at java.base/sun.security.ssl.SSLExtension.produce(SSLExtension.java:571)
	at java.base/sun.security.ssl.SSLExtensions.produce(SSLExtensions.java:250)
	at java.base/sun.security.ssl.ClientHello$ClientHelloKickstartProducer.produce(ClientHello.java:649)
	at java.base/sun.security.ssl.SSLHandshake.kickstart(SSLHandshake.java:519)
	at java.base/sun.security.ssl.ClientHandshakeContext.kickstart(ClientHandshakeContext.java:107)
	at java.base/sun.security.ssl.TransportContext.kickstart(TransportContext.java:231)
	at java.base/sun.security.ssl.SSLEngineImpl.beginHandshake(SSLEngineImpl.java:107)
	... 1 more

Look like the key exchange implementation expect a XECPublicKey interface for the public key.

@brcolow
Copy link
Author

brcolow commented Oct 18, 2019

@SamuelPadou I don't think that is related to this issue.

@spadou
Copy link

spadou commented Oct 18, 2019

It's not exactly the same error but it seem related. It is also linked to the added support for X25519 and X448 by JDK-8171279 in the JDK13 build.

The fix above in 1.64 correct the exception in the KeyPairGenerator initialisation, but this other exception occurs 2 lines after when the XDHEPossession try to cast the public key to XECPublicKey. This interface was also introduced in JDK 11 and it look like BC doesn't support it either.

I'll do some more tests and open another issue if this isn't related to this one.

@brcolow
Copy link
Author

brcolow commented Jan 22, 2020

@spadou You are indeed correct that it is related.

@bcgit
Copy link
Collaborator

bcgit commented Mar 18, 2020

I think this one might also be fixed in the latest beta. https://www.bouncycastle.org/betas

ok3141 pushed a commit to ok3141/bc-java that referenced this issue Apr 14, 2020
@bcgit bcgit removed their assignment May 26, 2020
@dghgit
Copy link
Contributor

dghgit commented Oct 31, 2020

Closing as fixed.

@wei-kumar
Copy link

wei-kumar commented Feb 12, 2021

I am using JDK11.0.10, my BC-168 still hit this same issue.
I noticed that the case was closed on Oct 30, 2020.
BC-168 made available on 12/21/2020. I would expect the fix should in this BC-168 but apparently it is not.
I know the workaround is given in this thread but would like to sort out for permanent fix in BC.

Please look into this issue.

@jbakermk
Copy link

Just tested with Tomcat 9, Java 15 and bc 1.68:

2-Feb-2021 20:49:39.067 SEVERE [https-jsse-nio-8443-exec-9] org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun Error running socket processor
        java.lang.ClassCastException: class org.bouncycastle.jcajce.provider.asymmetric.edec.BCXDHPublicKey cannot be cast to class java.security.interfaces.XECPublicKey (org.bouncycastle.jcajce.provider.asymmetric.edec.BCXDHPublicKey is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @55e8ec2f; java.security.interfaces.XECPublicKey is in module java.base of loader 'bootstrap')
                at java.base/sun.security.ssl.XDHKeyExchange$XDHEPossession.<init>(XDHKeyExchange.java:107)
                at java.base/sun.security.ssl.NamedGroup$XDHScheme.createPossession(NamedGroup.java:661)
                at java.base/sun.security.ssl.NamedGroup$NamedGroupSpec.createPossession(NamedGroup.java:543)
                at java.base/sun.security.ssl.NamedGroup.createPossession(NamedGroup.java:431)
                at java.base/sun.security.ssl.SSLKeyExchange$T13KeyAgreement.createPossession(SSLKeyExchange.java:568)
                at java.base/sun.security.ssl.SSLKeyExchange.createPossessions(SSLKeyExchange.java:84)
                at java.base/sun.security.ssl.KeyShareExtension$SHKeyShareProducer.produce(KeyShareExtension.java:545)
                at java.base/sun.security.ssl.SSLExtension.produce(SSLExtension.java:603)
                at java.base/sun.security.ssl.SSLExtensions.produce(SSLExtensions.java:253)
                at java.base/sun.security.ssl.ServerHello$T13ServerHelloProducer.produce(ServerHello.java:587)
                at java.base/sun.security.ssl.SSLHandshake.produce(SSLHandshake.java:440)
                at java.base/sun.security.ssl.ClientHello$T13ClientHelloConsumer.goServerHello(ClientHello.java:1252)
                at java.base/sun.security.ssl.ClientHello$T13ClientHelloConsumer.consume(ClientHello.java:1188)
                at java.base/sun.security.ssl.ClientHello$ClientHelloConsumer.onClientHello(ClientHello.java:851)
                at java.base/sun.security.ssl.ClientHello$ClientHelloConsumer.consume(ClientHello.java:812)
                at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)
                at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480)
                at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1267)
                at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1254)
                at java.base/java.security.AccessController.doPrivileged(AccessController.java:691)
                at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:1199)
                at org.apache.tomcat.util.net.SecureNioChannel.tasks(SecureNioChannel.java:443)
                at org.apache.tomcat.util.net.SecureNioChannel.handshakeUnwrap(SecureNioChannel.java:507)
                at org.apache.tomcat.util.net.SecureNioChannel.handshake(SecureNioChannel.java:238)
                at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1568)
                at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
                at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
                at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
                at java.base/java.lang.Thread.run(Thread.java:832)

I believe this fix made it into bc 1.69 which is currently beta - any chance of a swift release? Thanks

@dghgit
Copy link
Contributor

dghgit commented Feb 12, 2021

The latest beta is at https://www.bouncycastle.org/betas

This was fixed in 1.68 though, would you provide a list of what is in META-INF for the jar you are using? Please move comments to #881

@jbakermk
Copy link

This was fixed in 1.68 though, would you provide a list of what is in META-INF for the jar you are using?

Which jar? There are loads in the WEB-INF/lib directory, all related to the project. But within the bc jar, a huge list under META-INF/versions. This seems to match the bc 1.68 jars downloaded from mvnrepository.

Can you be more specific so we can help further?

@jbakermk
Copy link

I've looked further into this issue. Our project was creating a 'fat jar' of dependencies and that causes the issue with v1.68. If the bc jars are removed from the fat jar and deployed separately, the error doesn't occur. I've got no idea why this would be an issue.

@dghgit
Copy link
Contributor

dghgit commented Feb 13, 2021

The "fat jar" concept doesn't work with the JCE/JCA - it's buried too deep in the JVM. As weird as it sounds, in some ways it does make sense - cryptography providers affect the security of the JVM, you would want extra caution around how they are handled otherwise the providing assurances, such as those around FIPS, become impossible.

@dghgit
Copy link
Contributor

dghgit commented Feb 13, 2021

The other thing I should add is you should probably look at the BC JSEE - this is not a criticism of the JSSE provider shipped with the JVM, but Oracle announced as of Java 1.9 that they were unable to keep supporting the FIPS mode, if FEDRamp is in your future, the BCJSSE is your best choice.

Flowdalic added a commit to Flowdalic/Smack that referenced this issue Feb 14, 2021
This causes

java.security.InvalidKeyException: cannot identify XDH private key

on Java 11 or higher.

See also
- bcgit/bc-java#620
- bcgit/bc-java#589
- corretto/corretto-11#168
- https://bugs.openjdk.java.net/browse/JDK-8171279
@alvdavi
Copy link

alvdavi commented Feb 16, 2021

I've looked further into this issue. Our project was creating a 'fat jar' of dependencies and that causes the issue with v1.68. If the bc jars are removed from the fat jar and deployed separately, the error doesn't occur. I've got no idea why this would be an issue.

The solution to make this work in BouncyCastle makes use of the multi-release jar feature:
https://openjdk.java.net/jeps/238

This means the jar includes two (or more) copies of the class files, for different versions of java. If your fat jar creation logic is not multi-release jar aware, it will only include one copy of the class files, the default one. For compatibility reasons, the default ones are the ones targeting JDK8 and older (as those versions are not aware of what a multi-release jar is)

@ErikBergfurInfor
Copy link

How would you get access to the betas?

@jeffhuang26
Copy link

I hit same issue on bc-fips-1.0.2.jar. Which fips version will this fix get into? @dghgit

@dghgit
Copy link
Contributor

dghgit commented Aug 15, 2022

It's in 2.0.0.

@dghgit
Copy link
Contributor

dghgit commented Aug 15, 2022

How would you get access to the betas?

Some how I missed this, the betas are made available to support contract holders only - aside from the costs involved, they can't be made available for general access till we get sign off from NIST.

@mouse07410
Copy link

mouse07410 commented Aug 15, 2022

Not my business, but is there any reason to concentrate on any other JDK versions besides 11 and 17 (LTS releases)?

@sawanverma
Copy link

@dghgit I am using Java 110.20 from Amzn Corretto and org.bouncycastle:bc-fips:1.0.2.3. I have hit the same issue as above "Could not generate XDH keypair".

I tried System.setProperty("jdk.tls.namedGroups", "secp256r1, secp384r1, ffdhe2048, ffdhe3072"); but it doesnt work.
I cant move the security postion of bc-fips. It has to be at the top for fedramp. Please suggest when can we expect 2.0.0 bc-fips to be out. or any workaround.

@dghgit
Copy link
Contributor

dghgit commented Sep 12, 2023

Don't the use SunJSSE. To start with it's not FIPS compliant.

@sawanverma
Copy link

Don't the use SunJSSE. To start with it's not FIPS compliant.

Hi, not sure what do you mean by this. I am using bc-fips-1.0.2.3 which is FIPS complaint. and marking bouncy castle as top most security provider

@dghgit
Copy link
Contributor

dghgit commented Sep 13, 2023

See SP 800-52.

@sawanverma
Copy link

Ok got that and hence for the same reason we are using bc-fips security provider. Am I missing something? Please elaborate.

@dghgit
Copy link
Contributor

dghgit commented Sep 13, 2023

Are you using the BCJSSE in FIPS mode?

@sawanverma
Copy link

Are you using the BCJSSE in FIPS mode?

Not really or may be I am not sure. I am doing the following

lazy val bouncyCastle = "org.bouncycastle" % "bc-fips" % "1.0.2.3"
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider

Security.insertProviderAt(new BouncyCastleFipsProvider(), 1)

And I have my other service running on SSL , it throws the mentioned error while connecting to them.

@dghgit
Copy link
Contributor

dghgit commented Sep 15, 2023

You need to be using the BCJSSE. The Java JSSE does an internal cast to a class that does not exist as far as the FIPS module is concerned.

@sawanverma
Copy link

sawanverma commented Sep 15, 2023

It will be very helpful if you can provide how to use that with above code snippet? Because I havent specified any such. The only thing I am doing is "Security.insertProviderAt(new BouncyCastleFipsProvider(), 1)"

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

No branches or pull requests