Skip to content

Commit b13f432

Browse files
Revert "Some tests still failing"
This reverts commit eb9a7d2.
1 parent eb9a7d2 commit b13f432

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

CMakeLists.txt

+14-1
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,18 @@ add_custom_target(check-install-via-properties-with-debug
833833

834834
DEPENDS accp-jar tests-jar)
835835

836+
add_custom_target(check-junit-edKeyFactory
837+
COMMAND ${TEST_JAVA_EXECUTABLE}
838+
-Dcom.amazon.corretto.crypto.provider.registerEdKeyFactory=true
839+
${TEST_RUNNER_ARGUMENTS}
840+
--select-class=com.amazon.corretto.crypto.provider.test.EdDSATest
841+
--select-class=com.amazon.corretto.crypto.provider.test.EvpKeyFactoryTest
842+
--select-class=com.amazon.corretto.crypto.provider.test.EvpSignatureSpecificTest
843+
--select-class=com.amazon.corretto.crypto.provider.test.EvpSignatureTest
844+
--select-class=com.amazon.corretto.crypto.provider.test.KeyReuseThreadStormTest
845+
846+
DEPENDS accp-jar tests-jar)
847+
836848
set(check_targets check-recursive-init
837849
check-install-via-properties
838850
check-install-via-properties-with-debug
@@ -841,7 +853,8 @@ set(check_targets check-recursive-init
841853
check-external-lib
842854
check-junit-AesLazy
843855
check-junit-AesEager
844-
check-junit-DifferentTempDir)
856+
check-junit-DifferentTempDir
857+
check-junit-edKeyFactory)
845858

846859
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
847860
set(check_targets ${check_targets} check-with-jni-flag)

src/com/amazon/corretto/crypto/provider/AmazonCorrettoCryptoProvider.java

+21-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public final class AmazonCorrettoCryptoProvider extends java.security.Provider {
6464
private final boolean relyOnCachedSelfTestResults;
6565
private final boolean shouldRegisterEcParams;
6666
private final boolean shouldRegisterSecureRandom;
67+
private final boolean shouldRegisterEdKeyFactory;
6768
private final boolean shouldRegisterMLDSA;
6869
private final Utils.NativeContextReleaseStrategy nativeContextReleaseStrategy;
6970

@@ -100,8 +101,14 @@ private void buildServiceMap() {
100101
addService("KeyFactory", "ML-DSA-87", "EvpKeyFactory$MLDSA");
101102
}
102103

103-
addService("KeyFactory", "EdDSA", "EvpKeyFactory$EdDSA");
104-
addService("KeyFactory", "Ed25519", "EvpKeyFactory$EdDSA");
104+
// KeyFactories are used to convert key encodings to Java Key objects. ACCP's KeyFactory for
105+
// Ed25519 returns keys of type EvpEdPublicKey and EvpEdPrivateKey that do not implement
106+
// EdECKey interface. One should register the KeyFactories from ACCP if they only use the
107+
// output of the factories with ACCP's services.
108+
if (shouldRegisterEdKeyFactory) {
109+
addService("KeyFactory", "EdDSA", "EvpKeyFactory$EdDSA");
110+
addService("KeyFactory", "Ed25519", "EvpKeyFactory$EdDSA");
111+
}
105112
addService("KeyPairGenerator", "EdDSA", "EdGen");
106113
addService("KeyPairGenerator", "Ed25519", "EdGen");
107114

@@ -498,6 +505,9 @@ public AmazonCorrettoCryptoProvider() {
498505
this.shouldRegisterSecureRandom =
499506
Utils.getBooleanProperty(PROPERTY_REGISTER_SECURE_RANDOM, true);
500507

508+
this.shouldRegisterEdKeyFactory =
509+
Utils.getBooleanProperty(PROPERTY_REGISTER_ED_KEYFACTORY, false);
510+
501511
this.shouldRegisterMLDSA = (!isFips() || isExperimentalFips());
502512

503513
this.nativeContextReleaseStrategy = Utils.getNativeContextReleaseStrategyProperty();
@@ -731,7 +741,7 @@ KeyFactory getKeyFactory(EvpKeyType keyType) {
731741
return ecFactory;
732742
case EdDSA:
733743
if (edFactory == null) {
734-
ecFactory = KeyFactory.getInstance(keyType.jceName, this);
744+
edFactory = new EdKeyFactory(this);
735745
}
736746
return edFactory;
737747
case MLDSA:
@@ -760,4 +770,12 @@ EvpKey translateKey(Key key, EvpKeyType keyType) throws InvalidKeyException {
760770
return (EvpKey) getKeyFactory(keyType).translateKey(key);
761771
}
762772
}
773+
774+
// In case the user does not register Ed25519 KeyFactories by ACCP, we still need one to be used
775+
// internally.
776+
private static class EdKeyFactory extends KeyFactory {
777+
EdKeyFactory(final AmazonCorrettoCryptoProvider provider) {
778+
super(new EvpKeyFactory.EdDSA(provider), provider, "Ed25519");
779+
}
780+
}
763781
}

0 commit comments

Comments
 (0)