diff options
3 files changed, 29 insertions, 19 deletions
diff --git a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp index 08628f2..8af33aa 100644 --- a/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp +++ b/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp @@ -1803,15 +1803,14 @@ static jint org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl_accept(JNIEn return (jint) ssl; } -#define SSL_AUTH_MASK 0x00007F00L -#define SSL_aRSA 0x00000100L /* Authenticate with RSA */ -#define SSL_aDSS 0x00000200L /* Authenticate with DSS */ -#define SSL_DSS SSL_aDSS -#define SSL_aFZA 0x00000400L -#define SSL_aNULL 0x00000800L /* no Authenticate, ADH */ -#define SSL_aDH 0x00001000L /* no Authenticate, ADH */ -#define SSL_aKRB5 0x00002000L /* Authenticate with KRB5 */ -#define SSL_aECDSA 0x00004000L /* Authenticate with ECDSA */ +#define SSL_aRSA 0x00000001L +#define SSL_aDSS 0x00000002L +#define SSL_aNULL 0x00000004L +#define SSL_aDH 0x00000008L +#define SSL_aECDH 0x00000010L +#define SSL_aKRB5 0x00000020L +#define SSL_aECDSA 0x00000040L +#define SSL_aPSK 0x00000080L /** * Sets the client's crypto algorithms and authentication methods. @@ -1824,12 +1823,12 @@ static jstring org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl_cipheraut return NULL; } - SSL_CIPHER* cipher = SSL_get_current_cipher(ssl); + const SSL_CIPHER* cipher = SSL_get_current_cipher(ssl); - unsigned long alg = cipher->algorithms; + unsigned long alg_auth = cipher->algorithm_auth; const char *au; - switch (alg&SSL_AUTH_MASK) { + switch (alg_auth) { case SSL_aRSA: au="RSA"; break; @@ -1839,8 +1838,11 @@ static jstring org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl_cipheraut case SSL_aDH: au="DH"; break; - case SSL_aFZA: - au = "FZA"; + case SSL_aKRB5: + au="KRB5"; + break; + case SSL_aECDH: + au = "ECDH"; break; case SSL_aNULL: au="None"; @@ -1848,6 +1850,9 @@ static jstring org_apache_harmony_xnet_provider_jsse_OpenSSLSocketImpl_cipheraut case SSL_aECDSA: au="ECDSA"; break; + case SSL_aPSK: + au="PSK"; + break; default: au="unknown"; break; @@ -2349,7 +2354,7 @@ static jstring OpenSSLSessionImpl_getProtocol(JNIEnv* env, jclass, jint ssl_sess */ static jstring OpenSSLSessionImpl_getCipherSuite(JNIEnv* env, jclass, jint ssl_session_address) { SSL_SESSION* ssl_session = reinterpret_cast<SSL_SESSION*>(static_cast<uintptr_t>(ssl_session_address)); - SSL_CIPHER* cipher = ssl_session->cipher; + const SSL_CIPHER* cipher = ssl_session->cipher; jstring result = env->NewStringUTF(SSL_CIPHER_get_name(cipher)); return result; } diff --git a/x-net/src/test/java/tests/api/javax/net/ssl/SSLServerSocketTest.java b/x-net/src/test/java/tests/api/javax/net/ssl/SSLServerSocketTest.java index c4bae0a..d12959b 100644 --- a/x-net/src/test/java/tests/api/javax/net/ssl/SSLServerSocketTest.java +++ b/x-net/src/test/java/tests/api/javax/net/ssl/SSLServerSocketTest.java @@ -33,6 +33,7 @@ import java.io.InputStream; import java.net.InetAddress; import java.security.KeyStore; import java.security.SecureRandom; +import java.util.Arrays; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; @@ -327,7 +328,9 @@ public class SSLServerSocketTest extends TestCase { sss.setEnabledCipherSuites(sss.getSupportedCipherSuites()); String[] res = sss.getEnabledCipherSuites(); assertNotNull("NULL result", res); - assertTrue("No enabled cipher suites.", res.length == count); + assertEquals("not all supported cipher suites were enabled", + Arrays.asList(sss.getSupportedCipherSuites()), + Arrays.asList(res)); } /** diff --git a/x-net/src/test/java/tests/api/javax/net/ssl/SSLSocketTest.java b/x-net/src/test/java/tests/api/javax/net/ssl/SSLSocketTest.java index 13a0e59..a17df93 100644 --- a/x-net/src/test/java/tests/api/javax/net/ssl/SSLSocketTest.java +++ b/x-net/src/test/java/tests/api/javax/net/ssl/SSLSocketTest.java @@ -27,7 +27,7 @@ import javax.security.cert.X509Certificate; import java.net.*; import java.security.KeyStore; import java.security.SecureRandom; -import java.lang.String; +import java.util.Arrays; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -636,8 +636,10 @@ public class SSLSocketTest extends TestCase { } ssl.setEnabledCipherSuites(ssl.getSupportedCipherSuites()); String[] res = ssl.getEnabledCipherSuites(); - assertEquals("not all supported cipher suites where enabled", - ssl.getSupportedCipherSuites().length, res.length); + assertNotNull("NULL result", res); + assertEquals("not all supported cipher suites were enabled", + Arrays.asList(ssl.getSupportedCipherSuites()), + Arrays.asList(res)); } /** |