File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
test/java/ibm/jceplus/junit/base Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -2119,6 +2119,7 @@ JNIEXPORT jbyteArray JNICALL Java_com_ibm_crypto_plus_provider_ock_NativeInterfa
21192119 unsigned char * secretBytesNative = NULL ;
21202120 jboolean isCopy = 0 ;
21212121 size_t secret_key_len = 0 ;
2122+ int rc = 0 ;
21222123
21232124 if (debug ) {
21242125 gslogFunctionEntry (functionName );
@@ -2143,7 +2144,10 @@ JNIEXPORT jbyteArray JNICALL Java_com_ibm_crypto_plus_provider_ock_NativeInterfa
21432144 if (NULL == secretBytesNative ) {
21442145 throwOCKException (env , 0 , "NULL from GetPrimitiveArrayCritical" );
21452146 } else {
2146- ICC_EVP_PKEY_derive (ockCtx , gen_ctx , secretBytesNative , & secret_key_len );
2147+ rc = ICC_EVP_PKEY_derive (ockCtx , gen_ctx , secretBytesNative , & secret_key_len );
2148+ if (rc != ICC_OSSL_SUCCESS ) {
2149+ throwOCKException (env , 0 , "ICC_EVP_PKEY_derive failed to derive a key" );
2150+ }
21472151 ICC_EVP_PKEY_CTX_free (ockCtx , gen_ctx );
21482152 (* env )-> ReleasePrimitiveArrayCritical (env , secretBytes , secretBytesNative , 0 );
21492153 if (debug ) {
Original file line number Diff line number Diff line change 3030import java .security .spec .XECPublicKeySpec ;
3131import java .util .Arrays ;
3232import javax .crypto .KeyAgreement ;
33+ import org .junit .jupiter .api .Assertions ;
3334import org .junit .jupiter .api .Test ;
3435import static org .junit .Assert .assertTrue ;
3536
@@ -336,20 +337,10 @@ private void runSmallOrderTest() throws Exception {
336337 private void testSmallOrder (String name , String a_pri , String b_pub , String result )
337338 throws Exception {
338339
339- try {
340- //System.out.println("Pub - "+b_pub);
340+ Exception thrown = Assertions .assertThrows (IllegalStateException .class , () -> {
341341 runDiffieHellmanTest (name , a_pri , b_pub , result );
342- } catch (InvalidKeyException ex ) {
343- assertTrue (true );
344- return ;
345- } catch (InvalidKeySpecException ex ) {
346- assertTrue (true );
347- return ;
348- } catch (Exception e1 ) {
349- System .out .println (e1 .getMessage ());
350- }
351-
352- throw new RuntimeException ("No exception on small-order point" );
342+ });
343+ Assertions .assertEquals ("ICC_EVP_PKEY_derive failed to derive a key" , thrown .getMessage ());
353344 }
354345
355346 private void runNonCanonicalTest () throws Exception {
You can’t perform that action at this time.
0 commit comments