--- old/jdk/src/jdk.crypto.ec/share/native/libsunec/ECC_JNI.cpp 2017-07-10 10:27:06.638074000 -0400 +++ new/jdk/src/jdk.crypto.ec/share/native/libsunec/ECC_JNI.cpp 2017-07-10 10:27:06.546028000 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,6 +89,50 @@ } /* + * Class: sun_security_ec_ECKeyPairGenerator + * Method: isCurveSupported + * Signature: ([B)Z + */ +JNIEXPORT jboolean +JNICALL Java_sun_security_ec_ECKeyPairGenerator_isCurveSupported + (JNIEnv *env, jclass clazz, jbyteArray encodedParams) +{ + SECKEYECParams params_item; + ECParams *ecparams = NULL; + jboolean result = JNI_FALSE; + + // The curve is supported if we can get parameters for it + params_item.len = env->GetArrayLength(encodedParams); + params_item.data = + (unsigned char *) env->GetByteArrayElements(encodedParams, 0); + if (params_item.data == NULL) { + goto cleanup; + } + + // Fill a new ECParams using the supplied OID + if (EC_DecodeParams(¶ms_item, &ecparams, 0) != SECSuccess) { + /* bad curve OID */ + goto cleanup; + } + + // If we make it to here, then the curve is supported + result = JNI_TRUE; + +cleanup: + { + if (params_item.data) { + env->ReleaseByteArrayElements(encodedParams, + (jbyte *) params_item.data, JNI_ABORT); + } + if (ecparams) { + FreeECParams(ecparams, true); + } + } + + return result; +} + +/* * Class: sun_security_ec_ECKeyPairGenerator * Method: generateECKeyPair * Signature: (I[B[B)[[B