aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Vartanian <flooey@google.com>2018-02-22 16:38:22 +0000
committerandroid-build-merger <android-build-merger@google.com>2018-02-22 16:38:22 +0000
commit74b916dab28b35923925a99a2e8f4bb9be152b7e (patch)
treea70a328b0054ca2246d7b931bd3391001b597e0d
parent50e73e23cf4c8987a63f5ae50709215f505bd179 (diff)
parentffccce66511ed940599530a9532128bd425a93e4 (diff)
downloadconscrypt-74b916dab28b35923925a99a2e8f4bb9be152b7e.tar.gz
Merge upstream master am: 1b7ad09993 am: 5b0eb6591e
am: ffccce6651 Change-Id: Ieeb873aa5d52c67551377cbcf0a61b01f5709edb
-rw-r--r--Android.mk4
-rw-r--r--common/src/jni/main/cpp/conscrypt/native_crypto.cc15
-rw-r--r--common/src/main/java/org/conscrypt/AbstractSessionContext.java6
-rw-r--r--common/src/main/java/org/conscrypt/NativeCrypto.java8
-rw-r--r--common/src/main/java/org/conscrypt/NativeSsl.java4
-rw-r--r--common/src/main/java/org/conscrypt/ServerSessionContext.java2
-rw-r--r--openjdk/src/test/java/org/conscrypt/NativeCryptoTest.java184
7 files changed, 113 insertions, 110 deletions
diff --git a/Android.mk b/Android.mk
index 2bc8a52c..d76f5ef0 100644
--- a/Android.mk
+++ b/Android.mk
@@ -67,7 +67,7 @@ ifeq ($(LIBCORE_SKIP_TESTS),)
# Make the conscrypt-tests library.
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(bundled_test_java_files)
-LOCAL_JAVA_RESOURCE_DIRS := openjdk/src/test/resources
+LOCAL_JAVA_RESOURCE_DIRS := openjdk/src/test/resources openjdk-integ-tests/src/test/resources
LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVA_LIBRARIES := \
core-oj \
@@ -126,7 +126,7 @@ ifeq ($(HOST_OS),linux)
ifeq ($(LIBCORE_SKIP_TESTS),)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(bundled_test_java_files)
- LOCAL_JAVA_RESOURCE_DIRS := openjdk/src/test/resources
+ LOCAL_JAVA_RESOURCE_DIRS := openjdk/src/test/resources openjdk-integ-tests/src/test/resources
LOCAL_JAVA_LIBRARIES := \
bouncycastle-nojarjar-hostdex \
bouncycastle-bcpkix-nojarjar-hostdex \
diff --git a/common/src/jni/main/cpp/conscrypt/native_crypto.cc b/common/src/jni/main/cpp/conscrypt/native_crypto.cc
index bd815876..053315e1 100644
--- a/common/src/jni/main/cpp/conscrypt/native_crypto.cc
+++ b/common/src/jni/main/cpp/conscrypt/native_crypto.cc
@@ -6533,7 +6533,7 @@ static jlong NativeCrypto_SSL_CTX_new(JNIEnv* env, jclass) {
/**
* public static native void SSL_CTX_free(long ssl_ctx)
*/
-static void NativeCrypto_SSL_CTX_free(JNIEnv* env, jclass, jlong ssl_ctx_address) {
+static void NativeCrypto_SSL_CTX_free(JNIEnv* env, jclass, jlong ssl_ctx_address, CONSCRYPT_UNUSED jobject holder) {
CHECK_ERROR_QUEUE_ON_RETURN;
SSL_CTX* ssl_ctx = to_SSL_CTX(env, ssl_ctx_address, true);
JNI_TRACE("ssl_ctx=%p NativeCrypto_SSL_CTX_free", ssl_ctx);
@@ -6544,6 +6544,7 @@ static void NativeCrypto_SSL_CTX_free(JNIEnv* env, jclass, jlong ssl_ctx_address
}
static void NativeCrypto_SSL_CTX_set_session_id_context(JNIEnv* env, jclass, jlong ssl_ctx_address,
+ CONSCRYPT_UNUSED jobject holder,
jbyteArray sid_ctx) {
CHECK_ERROR_QUEUE_ON_RETURN;
SSL_CTX* ssl_ctx = to_SSL_CTX(env, ssl_ctx_address, true);
@@ -6578,6 +6579,7 @@ static void NativeCrypto_SSL_CTX_set_session_id_context(JNIEnv* env, jclass, jlo
}
static jlong NativeCrypto_SSL_CTX_set_timeout(JNIEnv* env, jclass, jlong ssl_ctx_address,
+ CONSCRYPT_UNUSED jobject holder,
jlong seconds) {
CHECK_ERROR_QUEUE_ON_RETURN;
SSL_CTX* ssl_ctx = to_SSL_CTX(env, ssl_ctx_address, true);
@@ -6592,7 +6594,7 @@ static jlong NativeCrypto_SSL_CTX_set_timeout(JNIEnv* env, jclass, jlong ssl_ctx
/**
* public static native int SSL_new(long ssl_ctx) throws SSLException;
*/
-static jlong NativeCrypto_SSL_new(JNIEnv* env, jclass, jlong ssl_ctx_address) {
+static jlong NativeCrypto_SSL_new(JNIEnv* env, jclass, jlong ssl_ctx_address, CONSCRYPT_UNUSED jobject holder) {
CHECK_ERROR_QUEUE_ON_RETURN;
SSL_CTX* ssl_ctx = to_SSL_CTX(env, ssl_ctx_address, true);
JNI_TRACE("ssl_ctx=%p NativeCrypto_SSL_new", ssl_ctx);
@@ -9734,6 +9736,7 @@ static jlong NativeCrypto_SSL_get1_session(JNIEnv* env, jclass, jlong ssl_addres
#define REF_X509 "L" TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/OpenSSLX509Certificate;"
#define REF_X509_CRL "L" TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/OpenSSLX509CRL;"
#define REF_SSL "L" TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/NativeSsl;"
+#define REF_SSL_CTX "L" TO_STRING(JNI_JARJAR_PREFIX) "org/conscrypt/AbstractSessionContext;"
static JNINativeMethod sNativeCryptoMethods[] = {
CONSCRYPT_NATIVE_METHOD(clinit, "()V"),
CONSCRYPT_NATIVE_METHOD(EVP_PKEY_new_RSA, "([B[B[B[B[B[B[B[B)J"),
@@ -9934,10 +9937,10 @@ static JNINativeMethod sNativeCryptoMethods[] = {
CONSCRYPT_NATIVE_METHOD(asn1_write_free, "(J)V"),
CONSCRYPT_NATIVE_METHOD(EVP_has_aes_hardware, "()I"),
CONSCRYPT_NATIVE_METHOD(SSL_CTX_new, "()J"),
- CONSCRYPT_NATIVE_METHOD(SSL_CTX_free, "(J)V"),
- CONSCRYPT_NATIVE_METHOD(SSL_CTX_set_session_id_context, "(J[B)V"),
- CONSCRYPT_NATIVE_METHOD(SSL_CTX_set_timeout, "(JJ)J"),
- CONSCRYPT_NATIVE_METHOD(SSL_new, "(J)J"),
+ CONSCRYPT_NATIVE_METHOD(SSL_CTX_free, "(J" REF_SSL_CTX ")V"),
+ CONSCRYPT_NATIVE_METHOD(SSL_CTX_set_session_id_context, "(J" REF_SSL_CTX "[B)V"),
+ CONSCRYPT_NATIVE_METHOD(SSL_CTX_set_timeout, "(J" REF_SSL_CTX "J)J"),
+ CONSCRYPT_NATIVE_METHOD(SSL_new, "(J" REF_SSL_CTX ")J"),
CONSCRYPT_NATIVE_METHOD(SSL_enable_tls_channel_id, "(J" REF_SSL ")V"),
CONSCRYPT_NATIVE_METHOD(SSL_get_tls_channel_id, "(J" REF_SSL ")[B"),
CONSCRYPT_NATIVE_METHOD(SSL_set1_tls_channel_id, "(J" REF_SSL REF_EVP_PKEY ")V"),
diff --git a/common/src/main/java/org/conscrypt/AbstractSessionContext.java b/common/src/main/java/org/conscrypt/AbstractSessionContext.java
index 25a6b90a..565b33d0 100644
--- a/common/src/main/java/org/conscrypt/AbstractSessionContext.java
+++ b/common/src/main/java/org/conscrypt/AbstractSessionContext.java
@@ -153,9 +153,9 @@ abstract class AbstractSessionContext implements SSLSessionContext {
// to SSL_CTX_set_timeout in BoringSSL sets it to the default timeout instead.
// Pass INT_MAX seconds (68 years), since that's equivalent for practical purposes.
if (seconds > 0) {
- NativeCrypto.SSL_CTX_set_timeout(sslCtxNativePointer, seconds);
+ NativeCrypto.SSL_CTX_set_timeout(sslCtxNativePointer, this, seconds);
} else {
- NativeCrypto.SSL_CTX_set_timeout(sslCtxNativePointer, Integer.MAX_VALUE);
+ NativeCrypto.SSL_CTX_set_timeout(sslCtxNativePointer, this, Integer.MAX_VALUE);
}
Iterator<NativeSslSession> i = sessions.values().iterator();
@@ -190,7 +190,7 @@ abstract class AbstractSessionContext implements SSLSessionContext {
@Override
protected void finalize() throws Throwable {
try {
- NativeCrypto.SSL_CTX_free(sslCtxNativePointer);
+ NativeCrypto.SSL_CTX_free(sslCtxNativePointer, this);
} finally {
super.finalize();
}
diff --git a/common/src/main/java/org/conscrypt/NativeCrypto.java b/common/src/main/java/org/conscrypt/NativeCrypto.java
index edc5968b..5bd00740 100644
--- a/common/src/main/java/org/conscrypt/NativeCrypto.java
+++ b/common/src/main/java/org/conscrypt/NativeCrypto.java
@@ -856,13 +856,13 @@ public final class NativeCrypto {
return SUPPORTED_CIPHER_SUITES.clone();
}
- static native void SSL_CTX_free(long ssl_ctx);
+ static native void SSL_CTX_free(long ssl_ctx, AbstractSessionContext holder);
- static native void SSL_CTX_set_session_id_context(long ssl_ctx, byte[] sid_ctx);
+ static native void SSL_CTX_set_session_id_context(long ssl_ctx, AbstractSessionContext holder, byte[] sid_ctx);
- static native long SSL_CTX_set_timeout(long ssl_ctx, long seconds);
+ static native long SSL_CTX_set_timeout(long ssl_ctx, AbstractSessionContext holder, long seconds);
- static native long SSL_new(long ssl_ctx) throws SSLException;
+ static native long SSL_new(long ssl_ctx, AbstractSessionContext holder) throws SSLException;
static native void SSL_enable_tls_channel_id(long ssl, NativeSsl ssl_holder) throws SSLException;
diff --git a/common/src/main/java/org/conscrypt/NativeSsl.java b/common/src/main/java/org/conscrypt/NativeSsl.java
index b4e54702..8b559a7b 100644
--- a/common/src/main/java/org/conscrypt/NativeSsl.java
+++ b/common/src/main/java/org/conscrypt/NativeSsl.java
@@ -71,8 +71,8 @@ final class NativeSsl {
static NativeSsl newInstance(SSLParametersImpl parameters,
SSLHandshakeCallbacks handshakeCallbacks, AliasChooser chooser,
PSKCallbacks pskCallbacks) throws SSLException {
- long ctx = parameters.getSessionContext().sslCtxNativePointer;
- long ssl = NativeCrypto.SSL_new(ctx);
+ AbstractSessionContext ctx = parameters.getSessionContext();
+ long ssl = NativeCrypto.SSL_new(ctx.sslCtxNativePointer, ctx);
return new NativeSsl(ssl, parameters, handshakeCallbacks, chooser, pskCallbacks);
}
diff --git a/common/src/main/java/org/conscrypt/ServerSessionContext.java b/common/src/main/java/org/conscrypt/ServerSessionContext.java
index 4d144f64..08641c55 100644
--- a/common/src/main/java/org/conscrypt/ServerSessionContext.java
+++ b/common/src/main/java/org/conscrypt/ServerSessionContext.java
@@ -44,7 +44,7 @@ public final class ServerSessionContext extends AbstractSessionContext {
// sure you don't reuse sessions externalized with i2d_SSL_SESSION
// between apps. However our sessions are either in memory or
// exported to a app's SSLServerSessionCache.
- NativeCrypto.SSL_CTX_set_session_id_context(sslCtxNativePointer, new byte[] { ' ' });
+ NativeCrypto.SSL_CTX_set_session_id_context(sslCtxNativePointer, this, new byte[] { ' ' });
}
/**
diff --git a/openjdk/src/test/java/org/conscrypt/NativeCryptoTest.java b/openjdk/src/test/java/org/conscrypt/NativeCryptoTest.java
index 15cfe6ee..45e1d34a 100644
--- a/openjdk/src/test/java/org/conscrypt/NativeCryptoTest.java
+++ b/openjdk/src/test/java/org/conscrypt/NativeCryptoTest.java
@@ -325,32 +325,32 @@ public class NativeCryptoTest {
assertTrue(c != NULL);
long c2 = NativeCrypto.SSL_CTX_new();
assertTrue(c != c2);
- NativeCrypto.SSL_CTX_free(c);
- NativeCrypto.SSL_CTX_free(c2);
+ NativeCrypto.SSL_CTX_free(c, null);
+ NativeCrypto.SSL_CTX_free(c2, null);
}
@Test(expected = NullPointerException.class)
public void test_SSL_CTX_free_NullArgument() throws Exception {
- NativeCrypto.SSL_CTX_free(NULL);
+ NativeCrypto.SSL_CTX_free(NULL, null);
}
@Test
public void test_SSL_CTX_free() throws Exception {
- NativeCrypto.SSL_CTX_free(NativeCrypto.SSL_CTX_new());
+ NativeCrypto.SSL_CTX_free(NativeCrypto.SSL_CTX_new(), null);
}
@Test(expected = NullPointerException.class)
public void SSL_CTX_set_session_id_context_NullContextArgument() throws Exception {
- NativeCrypto.SSL_CTX_set_session_id_context(NULL, new byte[0]);
+ NativeCrypto.SSL_CTX_set_session_id_context(NULL, null, new byte[0]);
}
@Test(expected = NullPointerException.class)
public void SSL_CTX_set_session_id_context_withNullShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
try {
- NativeCrypto.SSL_CTX_set_session_id_context(c, null);
+ NativeCrypto.SSL_CTX_set_session_id_context(c, null, null);
} finally {
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -358,9 +358,9 @@ public class NativeCryptoTest {
public void test_SSL_CTX_set_session_id_context_withInvalidIdShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
try {
- NativeCrypto.SSL_CTX_set_session_id_context(c, new byte[33]);
+ NativeCrypto.SSL_CTX_set_session_id_context(c, null, new byte[33]);
} finally {
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -370,17 +370,17 @@ public class NativeCryptoTest {
long c = NativeCrypto.SSL_CTX_new();
try {
- NativeCrypto.SSL_CTX_set_session_id_context(c, empty);
- NativeCrypto.SSL_CTX_set_session_id_context(c, new byte[32]);
+ NativeCrypto.SSL_CTX_set_session_id_context(c, null, empty);
+ NativeCrypto.SSL_CTX_set_session_id_context(c, null, new byte[32]);
} finally {
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test
public void test_SSL_new() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
assertTrue(s != NULL);
assertTrue((NativeCrypto.SSL_get_options(s, null) & SSL_OP_NO_SSLv3) == 0);
@@ -388,12 +388,12 @@ public class NativeCryptoTest {
assertTrue((NativeCrypto.SSL_get_options(s, null) & SSL_OP_NO_TLSv1_1) == 0);
assertTrue((NativeCrypto.SSL_get_options(s, null) & SSL_OP_NO_TLSv1_2) == 0);
- long s2 = NativeCrypto.SSL_new(c);
+ long s2 = NativeCrypto.SSL_new(c, null);
assertTrue(s != s2);
NativeCrypto.SSL_free(s2, null);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -405,37 +405,37 @@ public class NativeCryptoTest {
@Test(expected = NullPointerException.class)
public void setLocalCertsAndPrivateKey_withNullCertificatesShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.setLocalCertsAndPrivateKey(s, null, null, getServerPrivateKey().getNativeRef());
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = NullPointerException.class)
public void setLocalCertsAndPrivateKey_withNullKeyShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.setLocalCertsAndPrivateKey(s, null, getEncodedServerCertificates(), null);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test
public void setLocalCertsAndPrivateKey() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
NativeCrypto.setLocalCertsAndPrivateKey(
s, null, getEncodedServerCertificates(), getServerPrivateKey().getNativeRef());
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -448,12 +448,12 @@ public class NativeCryptoTest {
initChannelIdKey();
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_set1_tls_channel_id(s, null, null);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -462,14 +462,14 @@ public class NativeCryptoTest {
initChannelIdKey();
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
// Use the key natively. This works because the initChannelIdKey method ensures that the
// key is backed by OpenSSL.
NativeCrypto.SSL_set1_tls_channel_id(s, null, CHANNEL_ID_PRIVATE_KEY.getNativeRef());
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -480,10 +480,10 @@ public class NativeCryptoTest {
@Test
public void test_SSL_get_mode() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
assertTrue(NativeCrypto.SSL_get_mode(s, null) != 0);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -494,7 +494,7 @@ public class NativeCryptoTest {
@Test
public void test_SSL_set_mode_and_clear_mode() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
// check SSL_MODE_ENABLE_FALSE_START on by default for BoringSSL
assertEquals(SSL_MODE_ENABLE_FALSE_START,
NativeCrypto.SSL_get_mode(s, null) & SSL_MODE_ENABLE_FALSE_START);
@@ -509,7 +509,7 @@ public class NativeCryptoTest {
assertTrue((NativeCrypto.SSL_get_mode(s, null) & SSL_MODE_ENABLE_FALSE_START) == 0);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -520,10 +520,10 @@ public class NativeCryptoTest {
@Test
public void test_SSL_get_options() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
assertTrue(NativeCrypto.SSL_get_options(s, null) != 0);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -534,12 +534,12 @@ public class NativeCryptoTest {
@Test
public void test_SSL_set_options() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
assertTrue((NativeCrypto.SSL_get_options(s, null) & SSL_OP_NO_SSLv3) == 0);
NativeCrypto.SSL_set_options(s, null, SSL_OP_NO_SSLv3);
assertTrue((NativeCrypto.SSL_get_options(s, null) & SSL_OP_NO_SSLv3) != 0);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -550,14 +550,14 @@ public class NativeCryptoTest {
@Test
public void test_SSL_clear_options() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
assertTrue((NativeCrypto.SSL_get_options(s, null) & SSL_OP_NO_SSLv3) == 0);
NativeCrypto.SSL_set_options(s, null, SSL_OP_NO_SSLv3);
assertTrue((NativeCrypto.SSL_get_options(s, null) & SSL_OP_NO_SSLv3) != 0);
NativeCrypto.SSL_clear_options(s, null, SSL_OP_NO_SSLv3);
assertTrue((NativeCrypto.SSL_get_options(s, null) & SSL_OP_NO_SSLv3) == 0);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -568,44 +568,44 @@ public class NativeCryptoTest {
@Test(expected = NullPointerException.class)
public void SSL_set_cipher_lists_withNullCiphersShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_set_cipher_lists(s, null, null);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = NullPointerException.class)
public void test_SSL_set_cipher_lists_withNullCipherShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_set_cipher_lists(s, null, new String[] {null});
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test
public void SSL_set_cipher_lists_withEmptyCiphersShouldSucceed() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
// Explicitly checking that the empty list is allowed.
// b/21816861
NativeCrypto.SSL_set_cipher_lists(s, null, new String[] {});
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test
public void SSL_set_cipher_lists_withIllegalCipherShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
// see OpenSSL ciphers man page
String[] illegals = new String[] {// empty
@@ -625,19 +625,19 @@ public class NativeCryptoTest {
}
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test
public void SSL_set_cipher_lists_withValidCiphersShouldSucceed() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
List<String> ciphers = new ArrayList<String>(NativeCrypto.SUPPORTED_CIPHER_SUITES_SET);
NativeCrypto.SSL_set_cipher_lists(s, null, ciphers.toArray(new String[ciphers.size()]));
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test(expected = NullPointerException.class)
@@ -648,13 +648,13 @@ public class NativeCryptoTest {
@Test
public void test_SSL_set_verify() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
NativeCrypto.SSL_set_verify(s, null, SSL_VERIFY_NONE);
NativeCrypto.SSL_set_verify(s, null, SSL_VERIFY_PEER);
NativeCrypto.SSL_set_verify(s, null, SSL_VERIFY_FAIL_IF_NO_PEER_CERT);
NativeCrypto.SSL_set_verify(s, null, (SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT));
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
private static final boolean DEBUG = false;
@@ -674,7 +674,7 @@ public class NativeCryptoTest {
}
public long beforeHandshake(long context) throws SSLException {
- long s = NativeCrypto.SSL_new(context);
+ long s = NativeCrypto.SSL_new(context, null);
// Limit cipher suites to a known set so authMethod is known.
List<String> cipherSuites = new ArrayList<String>();
if (enabledCipherSuites == null) {
@@ -714,7 +714,7 @@ public class NativeCryptoTest {
NativeCrypto.SSL_free(ssl, null);
}
if (context != NULL) {
- NativeCrypto.SSL_CTX_free(context);
+ NativeCrypto.SSL_CTX_free(context, null);
}
if (socket != null) {
socket.close();
@@ -1032,26 +1032,26 @@ public class NativeCryptoTest {
@Test(expected = NullPointerException.class)
public void test_SSL_do_handshake_withNullFdShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
NativeCrypto.SSL_set_connect_state(s, null);
try {
NativeCrypto.SSL_do_handshake(s, null, null, null, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = NullPointerException.class)
public void test_SSL_do_handshake_withNullShcShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
NativeCrypto.SSL_set_connect_state(s, null);
try {
NativeCrypto.SSL_do_handshake(s, null, INVALID_FD, null, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -1694,7 +1694,7 @@ public class NativeCryptoTest {
@SuppressWarnings("deprecation")
public void test_SSL_use_psk_identity_hint() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_use_psk_identity_hint(s, null, null);
NativeCrypto.SSL_use_psk_identity_hint(s, null, "test");
@@ -1713,7 +1713,7 @@ public class NativeCryptoTest {
}
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -1725,10 +1725,10 @@ public class NativeCryptoTest {
@Test
public void test_SSL_set_session() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
NativeCrypto.SSL_set_session(s, null, NULL);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
{
final long clientContext = NativeCrypto.SSL_CTX_new();
@@ -1778,7 +1778,7 @@ public class NativeCryptoTest {
}
@Override
public long beforeHandshake(long c) throws SSLException {
- long s = NativeCrypto.SSL_new(clientContext);
+ long s = NativeCrypto.SSL_new(clientContext, null);
NativeCrypto.SSL_set_session(s, null, clientSession[0]);
return s;
}
@@ -1811,8 +1811,8 @@ public class NativeCryptoTest {
}
NativeCrypto.SSL_SESSION_free(clientSession[0]);
NativeCrypto.SSL_SESSION_free(serverSession[0]);
- NativeCrypto.SSL_CTX_free(serverContext);
- NativeCrypto.SSL_CTX_free(clientContext);
+ NativeCrypto.SSL_CTX_free(serverContext, null);
+ NativeCrypto.SSL_CTX_free(clientContext, null);
}
}
@@ -1824,11 +1824,11 @@ public class NativeCryptoTest {
@Test
public void test_SSL_set_session_creation_enabled() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
NativeCrypto.SSL_set_session_creation_enabled(s, null, false);
NativeCrypto.SSL_set_session_creation_enabled(s, null, true);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
final ServerSocket listener = newServerSocket();
@@ -1901,20 +1901,20 @@ public class NativeCryptoTest {
@Test(expected = NullPointerException.class)
public void SSL_set_tlsext_host_name_withNullHostnameShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_set_tlsext_host_name(s, null, null);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = SSLException.class)
public void SSL_set_tlsext_host_name_withTooLongHostnameShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
char[] longHostname = new char[256];
@@ -1922,7 +1922,7 @@ public class NativeCryptoTest {
NativeCrypto.SSL_set_tlsext_host_name(s, null, new String(longHostname));
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -1930,14 +1930,14 @@ public class NativeCryptoTest {
public void test_SSL_set_tlsext_host_name() throws Exception {
final String hostname = "www.android.com";
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
assertNull(NativeCrypto.SSL_get_servername(s, null));
NativeCrypto.SSL_set_tlsext_host_name(s, null, hostname);
assertEquals(hostname, NativeCrypto.SSL_get_servername(s, null));
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
final ServerSocket listener = newServerSocket();
@@ -2121,10 +2121,10 @@ public class NativeCryptoTest {
@Test
public void SSL_get_servername_shouldReturnNull() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
assertNull(NativeCrypto.SSL_get_servername(s, null));
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
// additional positive testing by test_SSL_set_tlsext_host_name
}
@@ -2184,48 +2184,48 @@ public class NativeCryptoTest {
@Test(expected = NullPointerException.class)
public void SSL_read_withNullFdShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_read(s, null, null, DUMMY_CB, null, 0, 0, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = NullPointerException.class)
public void SSL_read_withNullCallbacksShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_read(s, null, INVALID_FD, null, null, 0, 0, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = NullPointerException.class)
public void SSL_read_withNullBytesShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_read(s, null, INVALID_FD, DUMMY_CB, null, 0, 0, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = SSLException.class)
public void SSL_read_beforeHandshakeShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_read(s, null, INVALID_FD, DUMMY_CB, new byte[1], 0, 1, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -2302,48 +2302,48 @@ public class NativeCryptoTest {
@Test(expected = NullPointerException.class)
public void SSL_write_withNullFdShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_write(s, null, null, DUMMY_CB, null, 0, 1, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = NullPointerException.class)
public void SSL_write_withNullCallbacksShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_write(s, null, INVALID_FD, null, null, 0, 1, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = NullPointerException.class)
public void SSL_write_withNullBytesShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_write(s, null, INVALID_FD, DUMMY_CB, null, 0, 1, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@Test(expected = SSLException.class)
public void SSL_write_beforeHandshakeShouldThrow() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
NativeCrypto.SSL_write(s, null, INVALID_FD, DUMMY_CB, new byte[1], 0, 1, 0);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -2357,10 +2357,10 @@ public class NativeCryptoTest {
public void SSL_interrupt_withoutHandshakeShouldSucceed() throws Exception {
// also works without handshaking
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
NativeCrypto.SSL_interrupt(s, null);
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
@Test
@@ -2407,12 +2407,12 @@ public class NativeCryptoTest {
private void wrapWithSSLSession(SSLSessionWrappedTask task) throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- long s = NativeCrypto.SSL_new(c);
+ long s = NativeCrypto.SSL_new(c, null);
try {
task.run(s);
} finally {
NativeCrypto.SSL_free(s, null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_CTX_free(c, null);
}
}
@@ -2465,8 +2465,8 @@ public class NativeCryptoTest {
@Test
public void test_SSL_free() throws Exception {
long c = NativeCrypto.SSL_CTX_new();
- NativeCrypto.SSL_free(NativeCrypto.SSL_new(c), null);
- NativeCrypto.SSL_CTX_free(c);
+ NativeCrypto.SSL_free(NativeCrypto.SSL_new(c, null), null);
+ NativeCrypto.SSL_CTX_free(c, null);
// additional positive testing elsewhere because handshake
// uses use SSL_free to cleanup in afterHandshake.