diff options
| author | J08nY | 2018-05-30 01:50:23 +0200 |
|---|---|---|
| committer | J08nY | 2018-05-30 01:51:13 +0200 |
| commit | f4063951527fa533d0b59998019b1a800dbc02d0 (patch) | |
| tree | b398a33f9199c6ecb3cd051fe5173bf2da960199 /src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp | |
| parent | 542edb2487615d1e680f1843f87446a653223bc1 (diff) | |
| download | ECTester-f4063951527fa533d0b59998019b1a800dbc02d0.tar.gz ECTester-f4063951527fa533d0b59998019b1a800dbc02d0.tar.zst ECTester-f4063951527fa533d0b59998019b1a800dbc02d0.zip | |
Diffstat (limited to 'src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp')
| -rw-r--r-- | src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp b/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp index cef4bfe..2e93a71 100644 --- a/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp +++ b/src/cz/crcs/ectester/standalone/libs/jni/cpp_utils.cpp @@ -56,4 +56,28 @@ void init_classes(JNIEnv *env, std::string lib_name) { void throw_new(JNIEnv *env, const std::string& klass, const std::string& message) { jclass clazz = env->FindClass(klass.c_str()); env->ThrowNew(clazz, message.c_str()); +} + +static void add_provider_property(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method) { + jstring type_str = env->NewStringUTF(type.c_str()); + jstring class_str = env->NewStringUTF(klass.c_str()); + env->CallObjectMethod(provider, put_method, type_str, class_str); +} + +void add_kpg(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method) { + const std::string full_type = "KeyPairGenerator." + type; + const std::string full_class = "cz.crcs.ectester.standalone.libs.jni.NativeKeyPairGeneratorSpi$" + klass; + add_provider_property(env, full_type, full_class, provider, put_method); +} + +void add_ka(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method) { + const std::string full_type = "KeyAgreement." + type; + const std::string full_class = "cz.crcs.ectester.standalone.libs.jni.NativeKeyAgreementSpi$" + klass; + add_provider_property(env, full_type, full_class, provider, put_method); +} + +void add_sig(JNIEnv *env, const std::string &type, const std::string &klass, jobject provider, jmethodID put_method) { + const std::string full_type = "Signature." + type; + const std::string full_class = "cz.crcs.ectester.standalone.libs.jni.NativeSignatureSpi$" + klass; + add_provider_property(env, full_type, full_class, provider, put_method); }
\ No newline at end of file |
