Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Evolving Conscrypt's Open Source Approach

Hello Conscrypt Developers,
Expand Down Expand Up @@ -68,7 +69,7 @@ try {
// Example: Listing providers to see what's available
// val providers = Security.getProviders()
// providers.forEach { provider ->
// println("Provider: ${provider.name}")
// println("Provider: " + provider.name)
// }
} catch (e: NoSuchAlgorithmException) {
// Handle exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void CompatibilityCloseMonitor::init() {
return;
}
#ifdef CONSCRYPT_UNBUNDLED
// Only attempt to initialise the legacy C++ API if the C API symbols were not found.
// Only attempt to initialise the legacy C++ API if the C API symbols were not
// found.
lib = dlopen("libjavacore.so", RTLD_NOW);
if (lib != nullptr) {
if (asyncCloseMonitorCreate == nullptr) {
Expand Down
8 changes: 5 additions & 3 deletions common/src/jni/main/cpp/conscrypt/jniload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,17 @@ jint libconscrypt_JNI_OnLoad(JavaVM* vm, void*) {
// Register all of the native JNI methods.
NativeCrypto::registerNativeMethods(env);

// Perform static initialization of the close monitor (if required on this platform).
// Perform static initialization of the close monitor (if required on this
// platform).
CompatibilityCloseMonitor::init();
return CONSCRYPT_JNI_VERSION;
}

#ifdef STATIC_LIB

// A version of OnLoad called when the Conscrypt library has been statically linked to the JVM (For
// Java >= 1.8). The manner in which the library is statically linked is implementation specific.
// A version of OnLoad called when the Conscrypt library has been statically
// linked to the JVM (For Java >= 1.8). The manner in which the library is
// statically linked is implementation specific.
//
// See http://openjdk.java.net/jeps/178
CONSCRYPT_PUBLIC jint JNI_OnLoad_conscrypt(JavaVM* vm, void* reserved) {
Expand Down
19 changes: 12 additions & 7 deletions common/src/jni/main/cpp/conscrypt/jniutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ void init(JavaVM* vm, JNIEnv* env) {
openSslInputStreamClass = getGlobalRefToClass(
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/OpenSSLBIOInputStream");
sslHandshakeCallbacksClass = getGlobalRefToClass(
env, TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/NativeCrypto$SSLHandshakeCallbacks");
env,
TO_STRING(
JNI_JARJAR_PREFIX) "org/conscrypt/"
"NativeCrypto$SSLHandshakeCallbacks");

nativeRef_address = getFieldRef(env, nativeRefClass, "address", "J");
#if defined(ANDROID) && !defined(CONSCRYPT_OPENJDK)
Expand All @@ -119,7 +122,7 @@ void init(JavaVM* vm, JNIEnv* env) {
sslHandshakeCallbacks_clientCertificateRequested = getMethodRef(
env, sslHandshakeCallbacksClass, "clientCertificateRequested", "([B[I[[B)V");
sslHandshakeCallbacks_serverCertificateRequested =
getMethodRef(env, sslHandshakeCallbacksClass, "serverCertificateRequested", "()V");
getMethodRef(env, sslHandshakeCallbacksClass, "serverCertificateRequested", "([I)V");
sslHandshakeCallbacks_clientPSKKeyRequested = getMethodRef(
env, sslHandshakeCallbacksClass, "clientPSKKeyRequested", "(Ljava/lang/String;[B[B)I");
sslHandshakeCallbacks_serverPSKKeyRequested =
Expand Down Expand Up @@ -178,8 +181,8 @@ int jniGetFDFromFileDescriptor(JNIEnv* env, jobject fileDescriptor) {
}

extern bool isDirectByteBufferInstance(JNIEnv* env, jobject buffer) {
// Some versions of ART do not check the buffer validity when handling GetDirectBufferAddress()
// and GetDirectBufferCapacity().
// Some versions of ART do not check the buffer validity when handling
// GetDirectBufferAddress() and GetDirectBufferCapacity().
if (buffer == nullptr) {
return false;
}
Expand All @@ -191,7 +194,8 @@ extern bool isDirectByteBufferInstance(JNIEnv* env, jobject buffer) {

bool isGetByteArrayElementsLikelyToReturnACopy(size_t size) {
#if defined(ANDROID) && !defined(CONSCRYPT_OPENJDK)
// ART's GetByteArrayElements creates copies only for arrays smaller than 12 kB.
// ART's GetByteArrayElements creates copies only for arrays smaller than 12
// kB.
return size <= 12 * 1024;
#else
(void)size;
Expand Down Expand Up @@ -447,8 +451,9 @@ void throwExceptionFromBoringSSLError(JNIEnv* env, CONSCRYPT_UNUSED const char*
return;
}

// If there's an error from BoringSSL it may have been caused by an exception in Java code, so
// ensure there isn't a pending exception before we throw a new one.
// If there's an error from BoringSSL it may have been caused by an exception
// in Java code, so ensure there isn't a pending exception before we throw a
// new one.
if (!env->ExceptionCheck()) {
char message[256];
ERR_error_string_n(error, message, sizeof(message));
Expand Down
Loading
Loading