From 0ed6a5113092ee99b66e6e402d28a1b351fc0ca2 Mon Sep 17 00:00:00 2001 From: David Keeler Date: Thu, 18 Jul 2013 15:55:10 -0700 Subject: [PATCH] Back out a5a5d2c176f7 (bug 882865) because of Android test failures on a CLOSED TREE --- security/manager/ssl/src/nsCrypto.cpp | 77 +++++++++---------- .../ssl/tests/mochitest/bugs/Makefile.in | 1 - .../tests/mochitest/bugs/test_bug882865.html | 39 ---------- 3 files changed, 36 insertions(+), 81 deletions(-) delete mode 100644 security/manager/ssl/tests/mochitest/bugs/test_bug882865.html diff --git a/security/manager/ssl/src/nsCrypto.cpp b/security/manager/ssl/src/nsCrypto.cpp index e572cbe996e..17654b4020c 100644 --- a/security/manager/ssl/src/nsCrypto.cpp +++ b/security/manager/ssl/src/nsCrypto.cpp @@ -37,7 +37,6 @@ #include "nsContentUtils.h" #include "nsCxPusher.h" #include "nsDOMJSUtils.h" -#include "nsJSUtils.h" #include "nsIXPConnect.h" #include "nsIRunnable.h" #include "nsIWindowWatcher.h" @@ -340,53 +339,53 @@ cryptojs_convert_to_mechanism(nsKeyGenType keyGenType) } /* - * This function takes a string read through JavaScript parameters + * This function converts a string read through JavaScript parameters * and translates it to the internal enumeration representing the - * key gen type. Leading and trailing whitespace must be already removed. + * key gen type. */ static nsKeyGenType -cryptojs_interpret_key_gen_type(const nsAString& keyAlg) +cryptojs_interpret_key_gen_type(char *keyAlg) { - if (keyAlg.EqualsLiteral("rsa-ex")) { + char *end; + if (!keyAlg) { + return invalidKeyGen; + } + /* First let's remove all leading and trailing white space */ + while (isspace(keyAlg[0])) keyAlg++; + end = strchr(keyAlg, '\0'); + if (!end) { + return invalidKeyGen; + } + end--; + while (isspace(*end)) end--; + end[1] = '\0'; + if (strcmp(keyAlg, "rsa-ex") == 0) { return rsaEnc; - } - if (keyAlg.EqualsLiteral("rsa-dual-use")) { + } else if (strcmp(keyAlg, "rsa-dual-use") == 0) { return rsaDualUse; - } - if (keyAlg.EqualsLiteral("rsa-sign")) { + } else if (strcmp(keyAlg, "rsa-sign") == 0) { return rsaSign; - } - if (keyAlg.EqualsLiteral("rsa-sign-nonrepudiation")) { + } else if (strcmp(keyAlg, "rsa-sign-nonrepudiation") == 0) { return rsaSignNonrepudiation; - } - if (keyAlg.EqualsLiteral("rsa-nonrepudiation")) { + } else if (strcmp(keyAlg, "rsa-nonrepudiation") == 0) { return rsaNonrepudiation; - } - if (keyAlg.EqualsLiteral("ec-ex")) { + } else if (strcmp(keyAlg, "ec-ex") == 0) { return ecEnc; - } - if (keyAlg.EqualsLiteral("ec-dual-use")) { + } else if (strcmp(keyAlg, "ec-dual-use") == 0) { return ecDualUse; - } - if (keyAlg.EqualsLiteral("ec-sign")) { + } else if (strcmp(keyAlg, "ec-sign") == 0) { return ecSign; - } - if (keyAlg.EqualsLiteral("ec-sign-nonrepudiation")) { + } else if (strcmp(keyAlg, "ec-sign-nonrepudiation") == 0) { return ecSignNonrepudiation; - } - if (keyAlg.EqualsLiteral("ec-nonrepudiation")) { + } else if (strcmp(keyAlg, "ec-nonrepudiation") == 0) { return ecNonrepudiation; - } - if (keyAlg.EqualsLiteral("dsa-sign-nonrepudiation")) { + } else if (strcmp(keyAlg, "dsa-sign-nonrepudiation") == 0) { return dsaSignNonrepudiation; - } - if (keyAlg.EqualsLiteral("dsa-sign")) { + } else if (strcmp(keyAlg, "dsa-sign") ==0 ){ return dsaSign; - } - if (keyAlg.EqualsLiteral("dsa-nonrepudiation")) { + } else if (strcmp(keyAlg, "dsa-nonrepudiation") == 0) { return dsaNonrepudiation; - } - if (keyAlg.EqualsLiteral("dh-ex")) { + } else if (strcmp(keyAlg, "dh-ex") == 0) { return dhEx; } return invalidKeyGen; @@ -917,7 +916,7 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx, PK11SlotInfo **slot, bool willEscrow) { JSString *jsString; - JSAutoByteString params; + JSAutoByteString params, keyGenAlg; int keySize; nsresult rv; @@ -943,16 +942,13 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx, jsString = JS_ValueToString(cx, argv[2]); NS_ENSURE_TRUE(jsString, NS_ERROR_OUT_OF_MEMORY); argv[2] = STRING_TO_JSVAL(jsString); - nsDependentJSString dependentKeyGenAlg; - NS_ENSURE_TRUE(dependentKeyGenAlg.init(cx, jsString), NS_ERROR_UNEXPECTED); - nsAutoString keyGenAlg(dependentKeyGenAlg); - keyGenAlg.Trim("\r\n\t "); - keyGenType->keyGenType = cryptojs_interpret_key_gen_type(keyGenAlg); + keyGenAlg.encodeLatin1(cx, jsString); + NS_ENSURE_TRUE(!!keyGenAlg, NS_ERROR_OUT_OF_MEMORY); + keyGenType->keyGenType = cryptojs_interpret_key_gen_type(keyGenAlg.ptr()); if (keyGenType->keyGenType == invalidKeyGen) { - NS_LossyConvertUTF16toASCII keyGenAlgNarrow(dependentKeyGenAlg); JS_ReportError(cx, "%s%s%s", JS_ERROR, "invalid key generation argument:", - keyGenAlgNarrow.get()); + keyGenAlg.ptr()); goto loser; } if (!*slot) { @@ -965,10 +961,9 @@ cryptojs_ReadArgsAndGenerateKey(JSContext *cx, *slot,willEscrow); if (rv != NS_OK) { - NS_LossyConvertUTF16toASCII keyGenAlgNarrow(dependentKeyGenAlg); JS_ReportError(cx,"%s%s%s", JS_ERROR, "could not generate the key for algorithm ", - keyGenAlgNarrow.get()); + keyGenAlg.ptr()); goto loser; } return NS_OK; diff --git a/security/manager/ssl/tests/mochitest/bugs/Makefile.in b/security/manager/ssl/tests/mochitest/bugs/Makefile.in index 70ca63e603a..4812cac4439 100644 --- a/security/manager/ssl/tests/mochitest/bugs/Makefile.in +++ b/security/manager/ssl/tests/mochitest/bugs/Makefile.in @@ -15,7 +15,6 @@ MOCHITEST_FILES = \ test_bug480509.html \ test_bug483440.html \ test_bug484111.html \ - test_bug882865.html \ test_ev_validation.html \ test_ev_validation_child.html \ $(NULL) diff --git a/security/manager/ssl/tests/mochitest/bugs/test_bug882865.html b/security/manager/ssl/tests/mochitest/bugs/test_bug882865.html deleted file mode 100644 index f3bf9925e80..00000000000 --- a/security/manager/ssl/tests/mochitest/bugs/test_bug882865.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - Test bug 882865 - - - - - - -