iana cipher suite list handle

pull/23/head
Jacob Barthelmeh 2019-03-20 11:46:22 -06:00
parent 54fd9aebef
commit 56a6a9e5bf
4 changed files with 54 additions and 9 deletions

View File

@ -628,6 +628,23 @@ JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getEnabledCipherSuites
return retString;
}
JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getEnabledCipherSuitesIana
(JNIEnv *jenv, jclass jcl)
{
int ret;
char ciphers[4096];
jstring retString;
ret = wolfSSL_get_ciphers_iana(ciphers, sizeof(ciphers));
if (ret != WOLFSSL_SUCCESS) {
return NULL;
}
retString = (*jenv)->NewStringUTF(jenv, ciphers);
return retString;
}
JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_isEnabledCRL
(JNIEnv* jenv, jclass jcl)
{

View File

@ -307,6 +307,14 @@ JNIEXPORT jint JNICALL Java_com_wolfssl_WolfSSL_getBulkCipherAlgorithmEnumRABBIT
JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getEnabledCipherSuites
(JNIEnv *, jclass);
/*
* Class: com_wolfssl_WolfSSL
* Method: getEnabledCipherSuitesIana
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_wolfssl_WolfSSL_getEnabledCipherSuitesIana
(JNIEnv *, jclass);
/*
* Class: com_wolfssl_WolfSSL
* Method: TLSv1Enabled

View File

@ -268,6 +268,7 @@ public class WolfSSL {
static native int getBulkCipherAlgorithmEnumRABBIT();
static native String getEnabledCipherSuites();
static native String getEnabledCipherSuitesIana();
/* ------------------------- Java methods --------------------------- */
@ -787,6 +788,21 @@ public class WolfSSL {
return suiteArray;
}
/**
* Gets a list of all cipher suites supported and uses the format TLS_*
* @return list of all cipher suites supported
*/
public static String[] getCiphersIana() {
String cipherSuites = getEnabledCipherSuitesIana();
if (cipherSuites == null)
return null;
String[] suiteArray = cipherSuites.split(":");
return suiteArray;
}
/* ------------------------- isEnabled methods -------------------------- */

View File

@ -79,17 +79,13 @@ public class WolfSSLEngineHelper {
/* gets all supported cipher suites */
protected String[] getAllCiphers() {
return WolfSSL.getCiphers();
return WolfSSL.getCiphersIana();
}
/* gets all enabled cipher suites
* @TODO is this supposed to return null if no ciphers was set? */
protected String[] getCiphers() {
String[] ret = this.params.getCipherSuites();
if (ret == null) {
return this.getAllCiphers();
}
return ret;
return this.params.getCipherSuites();
}
protected void setCiphers(String[] suites) throws IllegalArgumentException {
@ -156,16 +152,24 @@ public class WolfSSLEngineHelper {
String list;
StringBuilder sb = new StringBuilder();
if (suites == null) {
/* use default cipher suites */
return;
}
for (String s : suites) {
sb.append(s);
sb.append(":");
}
/* remove last : */
sb.deleteCharAt(sb.length());
sb.deleteCharAt(sb.length() - 1);
list = sb.toString();
this.ssl.setCipherList(list);
if (this.ssl.setCipherList(list) != WolfSSL.SSL_SUCCESS) {
if (debug.DEBUG) {
log("error setting cipher list " + list);
}
}
} catch (IllegalStateException e) {
throw new IllegalArgumentException(e);