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

Remove conditional use of bouncy castle #144

Merged
merged 3 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
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
18 changes: 1 addition & 17 deletions sigstore-java/src/main/java/dev/sigstore/encryption/Keys.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,7 @@ public class Keys {
private static final Logger log = Logger.getLogger(Keys.class.getName());

static {
// Added for EdDSA support for Java <15

// This should work as JDK version strings are of the form '1.x.x' up to Java 8, and '9.x..'
// afterwards.
if (getJavaVersion() < 15) {
try {
log.info(
"Adding BouncyCastleProvider to SecurityManager for EdDSA algorithm support on Java <15.");
Security.addProvider(new BouncyCastleProvider());
} catch (SecurityException e) {
log.warning(
"Could not configure BouncyCastleProvider due to SecurityManager restrictions."
+ " EdDSA algorithms will not be supported. Refer to "
+ "https://docs.oracle.com/cd/E19830-01/819-4712/ablsc/index.html to configure BouncyCastle "
+ "for your JVM");
}
}
Security.addProvider(new BouncyCastleProvider());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ class KeysTest {
void parsePublicKey_rsa() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
PublicKey result =
Keys.parsePublicKey(Resources.toByteArray(Resources.getResource(RSA_PUB_PATH)));
assertEquals(result.getAlgorithm(), "RSA");
assertEquals("RSA", result.getAlgorithm());
}

@Test
void parsePublicKey_rsaPkcs1()
throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
PublicKey result =
Keys.parsePublicKey(Resources.toByteArray(Resources.getResource(RSA_PUB_PKCS1_PATH)));
assertEquals(result.getAlgorithm(), "RSA");
assertEquals("RSA", result.getAlgorithm());
}

@Test
void parsePublicKey_ec() throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
PublicKey result =
Keys.parsePublicKey(Resources.toByteArray(Resources.getResource(EC_PUB_PATH)));
assertEquals(result.getAlgorithm(), "EC");
assertEquals("EC", result.getAlgorithm());
}

@Test
Expand All @@ -64,7 +64,7 @@ void parsePublicKey_ed25519_withBouncyCastle()
PublicKey result =
Keys.parsePublicKey(Resources.toByteArray(Resources.getResource(ED25519_PUB_PATH)));
// BouncyCastle names the algorithm differently than the JDK
assertEquals(result.getAlgorithm(), "Ed25519");
assertEquals("Ed25519", result.getAlgorithm());
}

@Test
Expand All @@ -73,7 +73,7 @@ void parsePublicKey_ed25519_withStdLib()
throws IOException, InvalidKeySpecException, NoSuchAlgorithmException {
PublicKey result =
Keys.parsePublicKey(Resources.toByteArray(Resources.getResource(ED25519_PUB_PATH)));
assertEquals(result.getAlgorithm(), "EdDSA");
assertEquals("EdDSA", result.getAlgorithm());
}

@Test
Expand Down