You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "tomaswolf (via GitHub)" <gi...@apache.org> on 2024/08/31 17:31:56 UTC
[PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
tomaswolf opened a new pull request, #591:
URL: https://github.com/apache/mina-sshd/pull/591
Decouple the registrar name from the security provider name. Also check whether the BC RandomGenerator exists at all; in BC-FIPS, it doesn't.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2328109530
In other words: you must have run with the flag set to `true`, and the bc-fips libraries present, but without the BCFIPS `java.security.Provider` being installed. Only then would the code try to install the provider itself.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2325114458
And in `FIPSRegistarInitPlugin` two lines can be removed:
```
if(FIPS140.useCompliantAlgorithms() && Security.getProvider("BCFIPS") != null) {
LOG.info("register FIPSBouncyCastleSecurityProviderRegistar");
System.setProperty("org.apache.sshd.security.registrars", "io.jenkins.plugins.mina_sshd_api.core.bouncycaslte_registar.FIPSBouncyCastleSecurityProviderRegistar");
- System.setProperty("org.apache.sshd.security.defaultProvider", "BCFIPS");
- System.setProperty("org.apache.sshd.common.util.security.bouncycastle.provider.name", "BCFIPS");
} else {
LOG.config("not needed to register FIPSBouncyCastleSecurityProviderRegistar");
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2328158858
Yes, correct.
I probably mix up some local build of snapshots from various PR, branches...
Sorry for the wrong alert. I haven't been to reproduce this (and I really tried :))
All looks good to me to me to be merged.
And released?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2323171539
Thanks for the PR but hardcoded "BC" gives me this:
```
java.lang.IllegalArgumentException: BouncyCastle not registered
at PluginClassLoader for mina-sshd-api-common//org.apache.sshd.common.util.ValidateUtils.createFormattedException(ValidateUtils.java:213)
at PluginClassLoader for mina-sshd-api-common//org.apache.sshd.common.util.ValidateUtils.throwIllegalArgumentException(ValidateUtils.java:179)
at PluginClassLoader for mina-sshd-api-common//org.apache.sshd.common.util.ValidateUtils.checkTrue(ValidateUtils.java:156)
at PluginClassLoader for mina-sshd-api-common//org.apache.sshd.common.util.security.SecurityUtils.getBouncycastleEncryptedPrivateKeyInfoDecryptor(SecurityUtils.java:546)
at PluginClassLoader for mina-sshd-api-common//org.apache.sshd.common.config.keys.loader.pem.PKCS8PEMResourceKeyPairParser.decryptKeyPairs(PKCS8PEMResourceKeyPairParser.java:107)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2325455038
> > this one ^ is still needed because we want to use BCFIPS.
>
> Right.
>
> However, for FIPS mode I think we may have another problem: we use our own ChaCha20-Poly1305 implementation, and we use the bcyrypt KDF for encrypted OpenSSH "new format" keys.
>
right as far as I understand ` ChaCha20-Poly1305` is not FIPS compliant.
Regarding `OpenSSH "new format" keys`, I'm not quite sure.
> Probably we should have a way to disable those if you want to run in FIPS mode?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2323503443
Hm. Actually, I had a link, but can't find it anymore. Anyway, it said bc-fips had no pbe... (not that FIPS didn't have it). Might be technically true since I don't see any such code in bundle bc-fips, but there's also bundle bcpkix-fips which seems to have the classes I was missing. I'll keep trying.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf merged PR #591:
URL: https://github.com/apache/mina-sshd/pull/591
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2327761877
@tomaswolf I did some successful testing.
But I will still need the registar because the environment where it's running is very restrictive and even have a SecurityManager installed to block registration of SecurityProvider.
So without using the registar, the Apache Mina is trying to register the `BCFIPS` and `BC` :)
```
Caused: java.lang.IllegalArgumentException: Failed to register BC as a JCE provider
at PluginClassLoader for mina-sshd-api-common//org.apache.sshd.common.util.security.SecurityUtils.registerSecurityProvider(SecurityUtils.java:534)
at PluginClassLoader for mina-sshd-api-common//org.apache.sshd.common.util.security.SecurityUtils.register(SecurityUtils.java:489)
at PluginClassLoader for mina-sshd-api-common//org.apache.sshd.common.util.security.SecurityUtils.isBouncyCastleRegistered(SecurityUtils.java:438)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2330469421
@tomaswolf All is working fine.
Thanks a lot for your help!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2325332537
> this one ^ is still needed because we want to use BCFIPS.
Right.
However, for FIPS mode I think we may have another problem: we use our own ChaCha20-Poly1305 implementation, and we use the bcyrypt KDF for encrypted OpenSSH "new format" keys.
Probably we should have a way to disable those if you want to run in FIPS mode?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2323172538
as long as there is this check https://github.com/apache/mina-sshd/blob/40a08a4fc4b469185b1dd4f7c90cdf8949dc0c80/sshd-common/src/main/java/org/apache/sshd/common/util/security/SecurityUtils.java#L396 still using the hardcoded `BC` this will not work
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2323497946
Ah. Do you have any link for this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2330722708
Thanks for testing. I'll finish this this evening (documentation needs some updates still), then merge.
> And released?
I have a few other things to fix or clean-up first. But after that I'll ask our release manager if we could do a release.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2329462150
> I'll push an update this evening.
Done. The bug fix is https://github.com/apache/mina-sshd/compare/31234defad60f723ba5f3de4d2a7527784e46e49..8092f28b9f379e3652907a8cad3916e1163bc646#diff-b775cafcbee766e042f74d6790cbaa143b5f175756db29140865a41222e7b94aR310 .
Hope I didn't miss anything else.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2323216947
There is a test for this with this PR https://github.com/jenkinsci/mina-sshd-api-plugin/pull/114
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2325732111
> I'm not quite sure. with new do you mean this from 2018? :) https://www.openssh.com/txt/release-7.8
Yes: https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
I also think neither ChaCha20-Poly1305 nor bcrypt are covered by FIPS.
For ChaCha20-Poly1305 we have two options: either we say it's the user's responsibility to configure the SshClient appropriately by removing the cipher via configuration (`SshClient.setCipherFactories()`), or we add a flag (with system property and setter) in `SecurityUtils` and then hard-disable this Cipher if the flag is set.
The bcrypt thing is less critical. I don't know which KDF's are FIPS-approved, but I'd be surprised if bcrypt was. If not, anyone using this OpenSSH format for stored keys would deviate from FIPS anyway, so we could say it's entirely the user's responsibility. (As is using only PEM keys with FIPS-approved encryptions and KDFs.) Or we could use the aforementioned flag to also disable bcrypt (with the effect that such keys cannot be read or written in FIPS mode). Or we might only disable writing such files, while still allowing to read them.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2325318758
@tomaswolf Thanks a lot!!
> @olamy: All right. The original idea _was_ sound after all. With this PR at commit [9518312](https://github.com/apache/mina-sshd/commit/9518312b76aa4552343c56ad58b54e0ebb0b4950) and the following patch applied to your test [jenkinsci/mina-sshd-api-plugin#114](https://github.com/jenkinsci/mina-sshd-api-plugin/pull/114) that test succeeds.
>
> Patch:
>
> ```
> public class FIPSBouncyCastleSecurityProviderRegistar extends AbstractSecurityProviderRegistrar {
>
> public FIPSBouncyCastleSecurityProviderRegistar() {
> - super("BCFIPS");
> + super("BC");
> + }
> +
> + @Override
> + public String getProviderName() {
> + return "BCFIPS";
> }
>
> @Override
> ```
>
> Test run succeeds:
>
> ```
> [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.665 s -- in io.jenkins.plugins.mina_sshd_api.core.bouncycaslte_registar.TestBCFIPSRegistar
> ```
>
> Note that I did not include the customizeable RandomFactory. Not sure it's needed; it'll use `JceRandom` with BCFIPS anyway. (And JceRandom is changed to use `SecureRandom.getInstanceStrong()`.)
>
Right so it's not needed anymore.
> Two observations:
>
> 1. The typo in the package name I mentioned before is io.jenkins.plugins.mina_sshd_api.core.bouncyca**slte**_registar. That should probably be "bouncyca**stl**e_registrar".
Haha good catch. I was checking if String constants in System.setProperty were right but the problem was something else. Uhm I need some new glasses...
> 2. I think typical applications will include either the BCFIPS bundles _or_ the normal BC bundles, but not both. Mix and match won't work anyway. In such typical applications, there shouldn't be a need for an extra registrar at all, since the built-in `BouncyCastleSecurityRegistrar` can handle either, depending on what is accessible or what security providers are installed already. I presume no application would have both the BCFIPS _and_ the BC provider installed.
>
> Your use case seems to be in Jenkins and apparently both libraries (BC and BCFIPS) may be present. That use case may still need its special-purpose registrar. Also you mentioned you'd not want to use the SunJCE AES, so a system property to disable the SunJCEWrapper registrar would be needed anyway if you don't override the registrars. (If you do -- as is currently the case -- that SunJCEWrapper won't be registered at all.)
No we don't. If Jenkins is running in FIPS mode, the classic BC is not registered (not easy to figure when looking at the poms only but it's here https://github.com/jenkinsci/bouncycastle-api-plugin/blob/e27176eb46cbe94c1d1de6a9f318e3d538c34a4a/src/main/java/jenkins/bouncycastle/api/BouncyCastlePlugin.java#L27)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "jtnord (via GitHub)" <gi...@apache.org>.
jtnord commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2325944241
> The bcrypt thing is less critical. I don't know which KDF's are FIPS-approved, but I'd be surprised if bcrypt was.
for BouncyCastle FIPS see section 6 of https://downloads.bouncycastle.org/fips-java/docs/BC-FJA-UserGuide-1.0.2.pdf
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2325319889
> And in `FIPSRegistarInitPlugin` two lines can be removed:
>
> ```
> if(FIPS140.useCompliantAlgorithms() && Security.getProvider("BCFIPS") != null) {
> LOG.info("register FIPSBouncyCastleSecurityProviderRegistar");
> System.setProperty("org.apache.sshd.security.registrars", "io.jenkins.plugins.mina_sshd_api.core.bouncycaslte_registar.FIPSBouncyCastleSecurityProviderRegistar");
> - System.setProperty("org.apache.sshd.security.defaultProvider", "BCFIPS");
this one ^ is still needed because we want to use BCFIPS.
> - System.setProperty("org.apache.sshd.common.util.security.bouncycastle.provider.name", "BCFIPS");
> } else {
> LOG.config("not needed to register FIPSBouncyCastleSecurityProviderRegistar");
> }
> ```
Running few tests and this is looking really great. Thanks for your help.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2323496261
The exception you show above shows that you are trying to load an encrypted PEM key. (Starts with "-----BEGIN ENCRYPTED PRIVATE KEY-----").
AFAIK that is not possible in a FIPS environments as FIPS has no PBE/PBES2.
So the exception is totally correct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2324990575
@olamy: All right. The original idea _was_ sound after all. With this PR at commit 9518312 and the following patch applied to your that's failing my tests here https://github.com/jenkinsci/mina-sshd-api-plugin/pull/114 your test succeeds.
Patch:
```
public class FIPSBouncyCastleSecurityProviderRegistar extends AbstractSecurityProviderRegistrar {
public FIPSBouncyCastleSecurityProviderRegistar() {
- super("BCFIPS");
+ super("BC");
+ }
+
+ @Override
+ public String getProviderName() {
+ return "BCFIPS";
}
@Override
```
Test run succeeds:
```
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.665 s -- in io.jenkins.plugins.mina_sshd_api.core.bouncycaslte_registar.TestBCFIPSRegistar
```
Note that I did not include the customizeable RandomFactory. Not sure it's needed; it'll use `JceRandom` with BCFIPS anyway. (And JceRandom is changed to use `SecureRandom.getInstanceStrong()`.)
Two observations:
1. The typo in the package name I mentioned before is io.jenkins.plugins.mina_sshd_api.core.bouncyca**slte**_registar. That should probably be "bouncyca**stl**e_registrar".
2. I think typical applications will include either the BCFIPS bundles _or_ the normal BC bundles, but not both. Mix and match won't work anyway. In such typical applications, there shouldn't be a need for an extra registrar at all, since the built-in `BouncyCastleSecurityRegistrar` can handle either, depending on what is accessible or what security providers are installed already. I presume no application would have both the BCFIPS _and_ the BC provider installed.
Your use case seems to be in Jenkins and apparently both libraries (BC and BCFIPS) may be present. That use case may still need its special-purpose registrar. Also you mentioned you'd not want to use the SunJCE AES, so a system property to disable the SunJCEWrapper registrar would be needed anyway if you don't override the registrars. (If you do -- as is currently the case -- that SunJCEWrapper won't be registered at all.)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2323499830
TBI have been always thinking this `openssl genrsa -des3 -out rsa2048 rsa2048 ` would generate a FIPS compatible key.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2327379523
So here's another commit on top of this PR for this single flag. See the commit message.
With this, I think you don't need the `FIPSBouncyCastleSecurityProviderRegistar` anymore, and the `FIPSRegistarInitPlugin` can just do
```
System.setProperty("org.apache.sshd.security.fipsEnabled", "true");
System.setProperty("org.apache.sshd.security.defaultProvider", "BCFIPS");
```
If the flag is set, a number of non-FIPS-approved crypto-algorithms get disabled (ed25519, curve25519, curve448, sntrup761, bcrypt, chacha20-poly1305).
Disabling sntrup761 and curve25519 means that this FIPS mode is left without any post-quantum key exchange method.
[FIPS 203](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.203.pdf) has come out recently; it specifies the post-quantum ML-KEM key encapsulation method. There is a [draft RFC](https://datatracker.ietf.org/doc/html/draft-kampanakis-curdle-ssh-pq-ke-04) for incorporating this into SSH as key exchange algorithm. Once OpenSSH has support for this and Bouncy Castle also provides these ML-KEM instances, we can add them easily. At that point there would be mlkem1024nistp384-sha384 available as (I believe) FIPS-compliant post-quantum algorithm. When we do have that algorithm, I think we should keep it enabled even in FIPS mode.
Can you test that this works for your use case in Jenkins?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2328055218
That's strange. I did test this with your change, and it worked like a charm.
Your plug-in sets FIPS mode only if the "BCFIPS" security provider is already registered. So this code should never try to add the BCFIPS provider at run-time. Somehow it looks as if the BCFIPS security provider is not present in your environment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2328165470
I'll push an update this evening.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2328196631
Thanks.
By the way, I confirm I can reproduce. Sorry I made other changes in my test and forgot to correctly setup `-Djava.security.manager=` which is obviously mandatory to reproduce that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2328164958
> Edited my comments. There is indeed a bug; I missed one place where getName() must be replaced by getProviderName().
ah so I need to test again because I'm confused :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "tomaswolf (via GitHub)" <gi...@apache.org>.
tomaswolf commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2328162462
Edited my comments. There is indeed a bug; I missed one place where getName() must be replaced by getProviderName().
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2325965028
> > I'm not quite sure. with new do you mean this from 2018? :) https://www.openssh.com/txt/release-7.8
>
> Yes: https://github.com/openssh/openssh-portable/blob/master/PROTOCOL.key
>
> I also think neither ChaCha20-Poly1305 nor bcrypt are covered by FIPS.
>
> For ChaCha20-Poly1305 we have two options: either we say it's the user's responsibility to configure the SshClient appropriately by removing the cipher via configuration (`SshClient.setCipherFactories()`), or we add a flag (with system property and setter) in `SecurityUtils` and then hard-disable this Cipher if the flag is set.
>
LGTM
> The bcrypt thing is less critical. I don't know which KDF's are FIPS-approved, but I'd be surprised if bcrypt was. If not, anyone using this OpenSSH format for stored keys would deviate from FIPS anyway, so we could say it's entirely the user's responsibility. (As is using only PEM keys with FIPS-approved encryptions and KDFs.) Or we could use the aforementioned flag to also disable bcrypt (with the effect that such keys cannot be read or written in FIPS mode). Or we might only disable writing such files, while still allowing to read them.
what about something such a general flag `fips enabled`? Will turn reponsibility to the library but could be a great user feature?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2327424711
@tomaswolf Thanks a lot. I will test this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org
Re: [PR] GH-590: Be more careful with Bouncy Castle in FIPS environment [mina-sshd]
Posted by "olamy (via GitHub)" <gi...@apache.org>.
olamy commented on PR #591:
URL: https://github.com/apache/mina-sshd/pull/591#issuecomment-2323901361
that's failing my tests here https://github.com/jenkinsci/mina-sshd-api-plugin/pull/114/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org