Skip to content

Commit 4024096

Browse files
authored
Merge pull request #269 from pshipton/opensslfail
(0.41) Always revert to Java impl when OpenSSL fails
2 parents 07c8dd8 + 5674a79 commit 4024096

File tree

1 file changed

+9
-19
lines changed

1 file changed

+9
-19
lines changed

closed/src/jdk.crypto.ec/share/classes/sun/security/ec/NativeECKeyPairGenerator.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,13 @@ public KeyPair generateKeyPair() {
166166
return this.javaImplementation.generateKeyPair();
167167
}
168168

169-
boolean absent;
170169
long nativePointer = NativeECUtil.encodeGroup(this.params);
171170

172171
if (nativePointer == -1) {
173-
absent = NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
174-
if (!absent) {
175-
throw new ProviderException("Could not encode group");
176-
}
172+
NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
177173
if (nativeCryptTrace) {
178-
System.err.println(this.curve +
179-
" is not supported by OpenSSL, using Java crypto implementation.");
174+
System.err.println("Could not encode group for curve " + this.curve
175+
+ " in OpenSSL, using Java crypto implementation.");
180176
}
181177
try {
182178
this.initializeJavaImplementation();
@@ -193,13 +189,10 @@ public KeyPair generateKeyPair() {
193189
} else if (field instanceof ECFieldF2m) {
194190
fieldType = NativeCrypto.ECField_F2m;
195191
} else {
196-
absent = NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
197-
if (!absent) {
198-
throw new ProviderException("Field type not supported");
199-
}
192+
NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
200193
if (nativeCryptTrace) {
201-
System.err.println(this.curve +
202-
" is not supported by OpenSSL, using Java crypto implementation.");
194+
System.err.println("Field type not supported for curve " + this.curve
195+
+ " by OpenSSL, using Java crypto implementation.");
203196
}
204197
try {
205198
this.initializeJavaImplementation();
@@ -224,13 +217,10 @@ public KeyPair generateKeyPair() {
224217
fieldType);
225218

226219
if (ret == -1) {
227-
absent = NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
228-
if (!absent) {
229-
throw new ProviderException("Could not generate key pair");
230-
}
220+
NativeECUtil.putCurveIfAbsent(this.curve, Boolean.FALSE);
231221
if (nativeCryptTrace) {
232-
System.err.println(this.curve +
233-
" is not supported by OpenSSL, using Java crypto implementation for key generation.");
222+
System.err.println("Could not generate key pair for curve " + this.curve
223+
+ " using OpenSSL, using Java crypto implementation for key generation.");
234224
}
235225
try {
236226
this.initializeJavaImplementation();

0 commit comments

Comments
 (0)