diff options
| author | J08nY | 2024-03-29 19:24:46 +0100 |
|---|---|---|
| committer | J08nY | 2024-03-29 19:24:46 +0100 |
| commit | 3222a7d206dadeb42422b796389768ac21f976be (patch) | |
| tree | 62ee4f4b0416383661a9dc00257773bca838e192 | |
| parent | 5a38980884f88ec0037d63098bc7ae0b68a8f9ed (diff) | |
| download | ECTester-3222a7d206dadeb42422b796389768ac21f976be.tar.gz ECTester-3222a7d206dadeb42422b796389768ac21f976be.tar.zst ECTester-3222a7d206dadeb42422b796389768ac21f976be.zip | |
Catch Botan exceptions on decoding.
| -rw-r--r-- | standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/botan.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/botan.cpp b/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/botan.cpp index 3e266f6..b26d11a 100644 --- a/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/botan.cpp +++ b/standalone/src/main/resources/cz/crcs/ectester/standalone/libs/jni/botan.cpp @@ -368,7 +368,14 @@ jbyteArray generate_secret(JNIEnv *env, jobject self, jbyteArray pubkey, jbyteAr jsize pubkey_length = env->GetArrayLength(pubkey); jbyte *pubkey_data = env->GetByteArrayElements(pubkey, nullptr); - Botan::PointGFp public_point = curve_group.OS2ECP((uint8_t*) pubkey_data, pubkey_length); + Botan::PointGFp public_point; + try { + public_point = curve_group.OS2ECP((uint8_t*) pubkey_data, pubkey_length); + } catch (Botan::Exception & ex) { + throw_new(env, "java/security/GeneralSecurityException", ex.what()); + return nullptr; + } + env->ReleaseByteArrayElements(pubkey, pubkey_data, JNI_ABORT); Botan::ECDH_PublicKey pkey(curve_group, public_point); @@ -499,7 +506,13 @@ JNIEXPORT jboolean JNICALL Java_cz_crcs_ectester_standalone_libs_jni_NativeSigna jsize pubkey_length = env->GetArrayLength(pubkey); jbyte *pubkey_data = env->GetByteArrayElements(pubkey, nullptr); - Botan::PointGFp public_point = curve_group.OS2ECP((uint8_t*) pubkey_data, pubkey_length); + Botan::PointGFp public_point; + try { + public_point = curve_group.OS2ECP((uint8_t*) pubkey_data, pubkey_length); + } catch (Botan::Exception & ex) { + throw_new(env, "java/security/GeneralSecurityException", ex.what()); + return JNI_FALSE; + } env->ReleaseByteArrayElements(pubkey, pubkey_data, JNI_ABORT); std::unique_ptr<Botan::EC_PublicKey> pkey; |
