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

Add option to be able to use BCFIPS when BC is blocked in a FIPS environment #589

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.ServiceLoader;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
Expand Down Expand Up @@ -92,7 +93,8 @@ public final class SecurityUtils {
/**
* Bouncycastle JCE provider name
*/
public static final String BOUNCY_CASTLE = "BC";
public static final String BOUNCY_CASTLE
= System.getProperty("org.apache.sshd.common.util.security.bouncycastle.provider.name", "BC");

/**
* EDDSA support - should match {@code EdDSAKey.KEY_ALGORITHM}
Expand Down Expand Up @@ -165,6 +167,12 @@ public final class SecurityUtils {

public static final String PROP_DEFAULT_SECURITY_PROVIDER = "org.apache.sshd.security.defaultProvider";

/**
* class name of the default random factory to use, the class must have a default empty constructor. If empty
* standard algorithm will be used
*/
public static final String PROP_RANDOM_FACTORY_CLASS = "org.apache.sshd.random.defaultFactory";

private static final AtomicInteger MIN_DHG_KEY_SIZE_HOLDER = new AtomicInteger(0);
private static final AtomicInteger MAX_DHG_KEY_SIZE_HOLDER = new AtomicInteger(0);

Expand Down Expand Up @@ -552,6 +560,10 @@ public static Decryptor getBouncycastleEncryptedPrivateKeyInfoDecryptor() {
* {@link JceRandomFactory} one
*/
public static RandomFactory getRandomFactory() {
RandomFactory randomFactory = ServiceLoader.load(RandomFactory.class).iterator().next();
Copy link
Member

Choose a reason for hiding this comment

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

This will need to handle the case that no such service is available.

if (randomFactory != null) {
return randomFactory;
}
if (isBouncyCastleRegistered()) {
return BouncyCastleRandomFactory.INSTANCE;
} else {
Expand Down
Loading