harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r987212 - in /harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared: cipherList.h sslParameters.c
Date Thu, 19 Aug 2010 16:14:14 GMT
Author: odeakin
Date: Thu Aug 19 16:14:13 2010
New Revision: 987212

URL: http://svn.apache.org/viewvc?rev=987212&view=rev
Log:
Add tables to allow us to convert between the OpenSSL and spec names for cipher suites. Eventually
I may modify this to list to be loaded from a file rather than stored in arrays.

Added:
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/cipherList.h
  (with props)
Modified:
    harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c

Added: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/cipherList.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/cipherList.h?rev=987212&view=auto
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/cipherList.h
(added)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/cipherList.h
Thu Aug 19 16:14:13 2010
@@ -0,0 +1,75 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+#define CIPHER_COUNT 119
+
+char *specNames[CIPHER_COUNT] = { "SSL2_DES_64_CFB64_WITH_MD5_1", "SSL2_NULL_WITH_MD5", "SSL2_RC4_128_WITH_MD5",
"SSL2_RC4_128_EXPORT40_WITH_MD5", 
+    "SSL2_RC2_128_CBC_WITH_MD5", "SSL2_RC2_128_CBC_EXPORT40_WITH_MD5", "SSL2_IDEA_128_CBC_WITH_MD5",
"SSL2_DES_64_CBC_WITH_MD5", 
+    "SSL2_DES_64_CBC_WITH_SHA", "SSL2_DES_192_EDE3_CBC_WITH_MD5", "SSL2_DES_192_EDE3_CBC_WITH_SHA",
"SSL2_RC4_64_WITH_MD5", 
+    "SSL3_RSA_NULL_MD5", "SSL3_RSA_NULL_SHA", "SSL3_RSA_RC4_40_MD5", "SSL3_RSA_RC4_128_MD5",
"SSL3_RSA_RC4_128_SHA", 
+    "SSL3_RSA_RC2_40_MD5", "SSL3_RSA_IDEA_128_SHA", "SSL3_RSA_DES_40_CBC_SHA", "SSL3_RSA_DES_64_CBC_SHA",

+    "SSL3_RSA_DES_192_CBC3_SHA", "SSL3_DH_DSS_DES_40_CBC_SHA", "SSL3_DH_DSS_DES_64_CBC_SHA",
"SSL3_DH_DSS_DES_192_CBC3_SHA", 
+    "SSL3_DH_RSA_DES_40_CBC_SHA", "SSL3_DH_RSA_DES_64_CBC_SHA", "SSL3_DH_RSA_DES_192_CBC3_SHA",
"SSL3_EDH_DSS_DES_40_CBC_SHA", 
+    "SSL3_EDH_DSS_DES_64_CBC_SHA", "SSL3_EDH_DSS_DES_192_CBC3_SHA", "SSL3_EDH_RSA_DES_40_CBC_SHA",
"SSL3_EDH_RSA_DES_64_CBC_SHA", 
+    "SSL3_EDH_RSA_DES_192_CBC3_SHA", "SSL3_ADH_RC4_40_MD5", "SSL3_ADH_RC4_128_MD5", "SSL3_ADH_DES_40_CBC_SHA",

+    "SSL3_ADH_DES_64_CBC_SHA", "SSL3_ADH_DES_192_CBC_SHA", "SSL3_KRB5_DES_64_CBC_SHA", "SSL3_KRB5_DES_192_CBC3_SHA",

+    "SSL3_KRB5_RC4_128_SHA", "SSL3_KRB5_IDEA_128_CBC_SHA", "SSL3_KRB5_DES_64_CBC_MD5", "SSL3_KRB5_DES_192_CBC3_MD5",

+    "SSL3_KRB5_RC4_128_MD5", "SSL3_KRB5_IDEA_128_CBC_MD5", "SSL3_KRB5_DES_40_CBC_SHA", "SSL3_KRB5_RC2_40_CBC_SHA",

+    "SSL3_KRB5_RC4_40_SHA", "SSL3_KRB5_DES_40_CBC_MD5", "SSL3_KRB5_RC2_40_CBC_MD5", "SSL3_KRB5_RC4_40_MD5",

+    "TLS1_RSA_EXPORT1024_WITH_RC4_56_MD5", "TLS1_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5", "TLS1_RSA_EXPORT1024_WITH_DES_CBC_SHA",

+    "TLS1_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA", "TLS1_RSA_EXPORT1024_WITH_RC4_56_SHA", "TLS1_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA",

+    "TLS1_DHE_DSS_WITH_RC4_128_SHA", "TLS1_RSA_WITH_AES_128_SHA", "TLS1_DH_DSS_WITH_AES_128_SHA",
"TLS1_DH_RSA_WITH_AES_128_SHA", 
+    "TLS1_DHE_DSS_WITH_AES_128_SHA", "TLS1_DHE_RSA_WITH_AES_128_SHA", "TLS1_ADH_WITH_AES_128_SHA",
"TLS1_RSA_WITH_AES_256_SHA", 
+    "TLS1_DH_DSS_WITH_AES_256_SHA", "TLS1_DH_RSA_WITH_AES_256_SHA", "TLS1_DHE_DSS_WITH_AES_256_SHA",

+    "TLS1_DHE_RSA_WITH_AES_256_SHA", "TLS1_ADH_WITH_AES_256_SHA", "TLS1_ECDH_ECDSA_WITH_NULL_SHA",
"TLS1_ECDH_ECDSA_WITH_RC4_128_SHA", 
+    "TLS1_ECDH_ECDSA_WITH_DES_192_CBC3_SHA", "TLS1_ECDH_ECDSA_WITH_AES_128_CBC_SHA", "TLS1_ECDH_ECDSA_WITH_AES_256_CBC_SHA",

+    "TLS1_ECDHE_ECDSA_WITH_NULL_SHA", "TLS1_ECDHE_ECDSA_WITH_RC4_128_SHA", "TLS1_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA",

+    "TLS1_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS1_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS1_ECDH_RSA_WITH_NULL_SHA",

+    "TLS1_ECDH_RSA_WITH_RC4_128_SHA", "TLS1_ECDH_RSA_WITH_DES_192_CBC3_SHA", "TLS1_ECDH_RSA_WITH_AES_128_CBC_SHA",

+    "TLS1_ECDH_RSA_WITH_AES_256_CBC_SHA", "TLS1_ECDHE_RSA_WITH_NULL_SHA", "TLS1_ECDHE_RSA_WITH_RC4_128_SHA",

+    "TLS1_ECDHE_RSA_WITH_DES_192_CBC3_SHA", "TLS1_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS1_ECDHE_RSA_WITH_AES_256_CBC_SHA",

+    "TLS1_ECDH_anon_WITH_NULL_SHA", "TLS1_ECDH_anon_WITH_RC4_128_SHA", "TLS1_ECDH_anon_WITH_DES_192_CBC3_SHA",

+    "TLS1_ECDH_anon_WITH_AES_128_CBC_SHA", "TLS1_ECDH_anon_WITH_AES_256_CBC_SHA", "TLS1_PSK_WITH_RC4_128_SHA",

+    "TLS1_PSK_WITH_3DES_EDE_CBC_SHA", "TLS1_PSK_WITH_AES_128_CBC_SHA", "TLS1_PSK_WITH_AES_256_CBC_SHA",

+    "TLS1_RSA_WITH_CAMELLIA_128_CBC_SHA", "TLS1_DH_DSS_WITH_CAMELLIA_128_CBC_SHA", "TLS1_DH_RSA_WITH_CAMELLIA_128_CBC_SHA",

+    "TLS1_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA", "TLS1_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA", "TLS1_ADH_WITH_CAMELLIA_128_CBC_SHA",

+    "TLS1_RSA_WITH_CAMELLIA_256_CBC_SHA", "TLS1_DH_DSS_WITH_CAMELLIA_256_CBC_SHA", "TLS1_DH_RSA_WITH_CAMELLIA_256_CBC_SHA",

+    "TLS1_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA", "TLS1_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA", "TLS1_ADH_WITH_CAMELLIA_256_CBC_SHA",

+    "TLS1_RSA_WITH_SEED_SHA", "TLS1_DH_DSS_WITH_SEED_SHA", "TLS1_DH_RSA_WITH_SEED_SHA", "TLS1_DHE_DSS_WITH_SEED_SHA",

+    "TLS1_DHE_RSA_WITH_SEED_SHA", "TLS1_ADH_WITH_SEED_SHA"
+};
+
+char *openSSLNames[CIPHER_COUNT] = { "DES-CFB-M1", "NULL-MD5", "RC4-MD5", "EXP-RC4-MD5",
"RC2-CBC-MD5", "EXP-RC2-CBC-MD5", "IDEA-CBC-MD5", "DES-CBC-MD5", 
+    "DES-CBC-SHA", "DES-CBC3-MD5", "DES-CBC3-SHA", "RC4-64-MD5", "NULL-MD5", "NULL-SHA",
"EXP-RC4-MD5", "RC4-MD5", "RC4-SHA", "EXP-RC2-CBC-MD5", 
+    "IDEA-CBC-SHA", "EXP-DES-CBC-SHA", "DES-CBC-SHA", "DES-CBC3-SHA", "EXP-DH-DSS-DES-CBC-SHA",
"DH-DSS-DES-CBC-SHA", "DH-DSS-DES-CBC3-SHA", 
+    "EXP-DH-RSA-DES-CBC-SHA", "DH-RSA-DES-CBC-SHA", "DH-RSA-DES-CBC3-SHA", "EXP-EDH-DSS-DES-CBC-SHA",
"EDH-DSS-DES-CBC-SHA", "EDH-DSS-DES-CBC3-SHA", 
+    "EXP-EDH-RSA-DES-CBC-SHA", "EDH-RSA-DES-CBC-SHA", "EDH-RSA-DES-CBC3-SHA", "EXP-ADH-RC4-MD5",
"ADH-RC4-MD5", "EXP-ADH-DES-CBC-SHA", 
+    "ADH-DES-CBC-SHA", "ADH-DES-CBC3-SHA", "KRB5-DES-CBC-SHA", "KRB5-DES-CBC3-SHA", "KRB5-RC4-SHA",
"KRB5-IDEA-CBC-SHA", "KRB5-DES-CBC-MD5", 
+    "KRB5-DES-CBC3-MD5", "KRB5-RC4-MD5", "KRB5-IDEA-CBC-MD5", "EXP-KRB5-DES-CBC-SHA", "EXP-KRB5-RC2-CBC-SHA",
"EXP-KRB5-RC4-SHA", "EXP-KRB5-DES-CBC-MD5", 
+    "EXP-KRB5-RC2-CBC-MD5", "EXP-KRB5-RC4-MD5", "EXP1024-RC4-MD5", "EXP1024-RC2-CBC-MD5",
"EXP1024-DES-CBC-SHA", "EXP1024-DHE-DSS-DES-CBC-SHA", 
+    "EXP1024-RC4-SHA", "EXP1024-DHE-DSS-RC4-SHA", "DHE-DSS-RC4-SHA", "AES128-SHA", "DH-DSS-AES128-SHA",
"DH-RSA-AES128-SHA", "DHE-DSS-AES128-SHA", 
+    "DHE-RSA-AES128-SHA", "ADH-AES128-SHA", "AES256-SHA", "DH-DSS-AES256-SHA", "DH-RSA-AES256-SHA",
"DHE-DSS-AES256-SHA", "DHE-RSA-AES256-SHA", 
+    "ADH-AES256-SHA", "ECDH-ECDSA-NULL-SHA", "ECDH-ECDSA-RC4-SHA", "ECDH-ECDSA-DES-CBC3-SHA",
"ECDH-ECDSA-AES128-SHA", "ECDH-ECDSA-AES256-SHA", 
+    "ECDHE-ECDSA-NULL-SHA", "ECDHE-ECDSA-RC4-SHA", "ECDHE-ECDSA-DES-CBC3-SHA", "ECDHE-ECDSA-AES128-SHA",
"ECDHE-ECDSA-AES256-SHA", "ECDH-RSA-NULL-SHA", 
+    "ECDH-RSA-RC4-SHA", "ECDH-RSA-DES-CBC3-SHA", "ECDH-RSA-AES128-SHA", "ECDH-RSA-AES256-SHA",
"ECDHE-RSA-NULL-SHA", "ECDHE-RSA-RC4-SHA", 
+    "ECDHE-RSA-DES-CBC3-SHA", "ECDHE-RSA-AES128-SHA", "ECDHE-RSA-AES256-SHA", "AECDH-NULL-SHA",
"AECDH-RC4-SHA", "AECDH-DES-CBC3-SHA", 
+    "AECDH-AES128-SHA", "AECDH-AES256-SHA", "PSK-RC4-SHA", "PSK-3DES-EDE-CBC-SHA", "PSK-AES128-CBC-SHA",
"PSK-AES256-CBC-SHA", "CAMELLIA128-SHA", 
+    "DH-DSS-CAMELLIA128-SHA", "DH-RSA-CAMELLIA128-SHA", "DHE-DSS-CAMELLIA128-SHA", "DHE-RSA-CAMELLIA128-SHA",
"ADH-CAMELLIA128-SHA", 
+    "CAMELLIA256-SHA", "DH-DSS-CAMELLIA256-SHA", "DH-RSA-CAMELLIA256-SHA", "DHE-DSS-CAMELLIA256-SHA",
"DHE-RSA-CAMELLIA256-SHA", "ADH-CAMELLIA256-SHA", 
+    "SEED-SHA", "DH-DSS-SEED-SHA", "DH-RSA-SEED-SHA", "DHE-DSS-SEED-SHA", "DHE-RSA-SEED-SHA",
"ADH-SEED-SHA"
+};
+

Propchange: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/cipherList.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c?rev=987212&r1=987211&r2=987212&view=diff
==============================================================================
--- harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c
(original)
+++ harmony/enhanced/java/branches/omd/classlib/modules/x-net/src/main/native/jsse/shared/sslParameters.c
Thu Aug 19 16:14:13 2010
@@ -24,12 +24,14 @@
 #include "openssl/err.h"
 #include "jsse_rand.h"
 
+#include "cipherList.h"
+
 JNIEXPORT jobjectArray JNICALL Java_org_apache_harmony_xnet_provider_jsse_SSLParameters_initialiseDefaults
   (JNIEnv *env, jclass clazz)
 {
     SSL_CTX *context;
     SSL *ssl;
-    int i, count;
+    int i, count, ret;
     jclass stringClass;
     jobjectArray stringArray; 
     STACK_OF(SSL_CIPHER) *ciphers;
@@ -40,10 +42,10 @@ JNIEXPORT jobjectArray JNICALL Java_org_
 
     context = SSL_CTX_new(SSLv23_method());
 
-    /*ret = SSL_CTX_set_cipher_list(context, "ALL");
+    ret = SSL_CTX_set_cipher_list(context, "ALL");
     if (ret<=0) {
        ERR_print_errors_fp(stderr);
-    }*/
+    }
 
     ssl = SSL_new(context);
 
@@ -56,9 +58,16 @@ JNIEXPORT jobjectArray JNICALL Java_org_
     for (i=0; i<count; i++)
     {
         const char *cipherName = SSL_CIPHER_get_name(sk_value(&ciphers->stack, i));
-        jstring jcipherName = (*env)->NewStringUTF(env, cipherName);
-        (*env)->SetObjectArrayElement(env, stringArray, i, jcipherName);
-        (*env)->DeleteLocalRef(env, jcipherName);
+        int j;
+        for (j=0; j<CIPHER_COUNT; j++) {
+            if (!strcmp(cipherName, openSSLNames[j])) {
+                jstring jcipherName;
+                jcipherName = (*env)->NewStringUTF(env, specNames[j]);
+                (*env)->SetObjectArrayElement(env, stringArray, i, jcipherName);
+                (*env)->DeleteLocalRef(env, jcipherName);
+                break;
+            }
+        }
     }
 
     SSL_free(ssl);
@@ -241,10 +250,17 @@ JNIEXPORT void JNICALL Java_org_apache_h
     for (i=0; i<count; i++) {
         jstring jcipher = (jstring)(*env)->GetObjectArrayElement(env, jenabledCiphers,
i);
         const char *cipher = (*env)->GetStringUTFChars(env, jcipher, NULL);
-        strcat(cipherList, cipher);
-        if (i != count-1) {
-            strcat(cipherList, ":");
+        int j;
+        for (j=0; j<CIPHER_COUNT; j++) {
+            if (!strcmp(cipher, specNames[j])) {
+                strcat(cipherList, openSSLNames[j]);
+                if (i != count-1) {
+                    strcat(cipherList, ":");
+                }
+                break;
+            }
         }
+        
         (*env)->ReleaseStringUTFChars(env, jcipher, cipher);
     }
 



Mime
View raw message