Skip to content

Commit

Permalink
Do not remove the CRYPTO_library_init call
Browse files Browse the repository at this point in the history
  • Loading branch information
kruton committed Dec 27, 2016
1 parent 892bd88 commit c514a7f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions common/src/jni/main/cpp/org_conscrypt_NativeCrypto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,15 @@ static bool setBlocking(int fd, bool blocking) {
#define THROW_SOCKETTIMEOUTEXCEPTION (-3)
#define THROWN_EXCEPTION (-4)

/**
* Initialization phase for every OpenSSL job: Loads the Error strings, the
* crypto algorithms and reset the OpenSSL library
*/
static void NativeCrypto_clinit(JNIEnv*, jclass)
{
CRYPTO_library_init();
}

/**
* private static native int EVP_PKEY_new_RSA(byte[] n, byte[] e, byte[] d, byte[] p, byte[] q);
*/
Expand Down Expand Up @@ -9922,6 +9931,7 @@ static int NativeCrypto_ENGINE_SSL_write_heap(JNIEnv* env, jclass, jlong sslRef,
#define REF_HMAC_CTX "L" TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/NativeRef$HMAC_CTX;"
#define REF_BIO_IN_STREAM "L" TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/OpenSSLBIOInputStream;"
static JNINativeMethod sNativeCryptoMethods[] = {
NATIVE_METHOD(NativeCrypto, clinit, "()V"),
NATIVE_METHOD(NativeCrypto, EVP_PKEY_new_RSA, "([B[B[B[B[B[B[B[B)J"),
NATIVE_METHOD(NativeCrypto, EVP_PKEY_new_EC_KEY, "(" REF_EC_GROUP REF_EC_POINT "[B)J"),
NATIVE_METHOD(NativeCrypto, EVP_PKEY_type, "(" REF_EVP_PKEY ")I"),
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/java/org/conscrypt/NativeCrypto.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ public final class NativeCrypto {
// --- OpenSSL library initialization --------------------------------------
static {
NativeCryptoJni.init();
clinit();
}

private native static void clinit();

// --- DSA/RSA public/private key handling functions -----------------------

public static native long EVP_PKEY_new_DSA(byte[] p, byte[] q, byte[] g,
Expand Down

0 comments on commit c514a7f

Please sign in to comment.