Bug 1243594 (part 1) - remove misleading references to utf8 in Credentials.jsm. r=rfkelly
☠☠ backed out by fb7ceaf4b009 ☠ ☠
authorMark Hammond <mhammond@skippinet.com.au>
Tue, 16 Feb 2016 12:44:49 +1100
changeset 331221 4f941cddcf34462a4b15694000bf3388e1b00cc4
parent 331220 49adf1dee4ddf45d6090c5c7849b512ad8377f6c
child 331222 5688da9024b661ebd6db4ef81bd19c59b4d15386
push id10938
push userBogdan.Postelnicu@softvision.ro
push dateTue, 16 Feb 2016 15:52:05 +0000
reviewersrfkelly
bugs1243594
milestone47.0a1
Bug 1243594 (part 1) - remove misleading references to utf8 in Credentials.jsm. r=rfkelly
services/fxaccounts/Credentials.jsm
services/fxaccounts/FxAccountsClient.jsm
services/fxaccounts/tests/xpcshell/test_credentials.js
--- a/services/fxaccounts/Credentials.jsm
+++ b/services/fxaccounts/Credentials.jsm
@@ -99,20 +99,17 @@ this.Credentials = Object.freeze({
 
     let hkdfSalt = options.hkdfSalt || HKDF_SALT;
     let hkdfLength = options.hkdfLength || HKDF_LENGTH;
     let hmacLength = options.hmacLength || HMAC_LENGTH;
     let hmacAlgorithm = options.hmacAlgorithm || HMAC_ALGORITHM;
     let stretchedPWLength = options.stretchedPassLength || STRETCHED_PW_LENGTH_BYTES;
     let pbkdf2Rounds = options.pbkdf2Rounds || PBKDF2_ROUNDS;
 
-    let result = {
-      emailUTF8: emailInput,
-      passwordUTF8: passwordInput,
-    };
+    let result = {};
 
     let password = CommonUtils.encodeUTF8(passwordInput);
     let salt = this.keyWordExtended("quickStretch", emailInput);
 
     let runnable = () => {
       let start = Date.now();
       let quickStretchedPW = CryptoUtils.pbkdf2Generate(
           password, salt, pbkdf2Rounds, stretchedPWLength, hmacAlgorithm, hmacLength);
--- a/services/fxaccounts/FxAccountsClient.jsm
+++ b/services/fxaccounts/FxAccountsClient.jsm
@@ -87,17 +87,17 @@ this.FxAccountsClient.prototype = {
    *                               email
    *        }
    */
   _createSession: function(path, email, password, getKeys=false,
                            retryOK=true) {
     return Credentials.setup(email, password).then((creds) => {
       let data = {
         authPW: CommonUtils.bytesAsHex(creds.authPW),
-        email: creds.emailUTF8,
+        email: email,
       };
       let keys = getKeys ? "?keys=true" : "";
 
       return this._request(path + keys, "POST", null, data).then(
         // Include the canonical capitalization of the email in the response so
         // the caller can set its signed-in user state accordingly.
         result => {
           result.email = data.email;
--- a/services/fxaccounts/tests/xpcshell/test_credentials.js
+++ b/services/fxaccounts/tests/xpcshell/test_credentials.js
@@ -66,40 +66,34 @@ add_task(function* test_onepw_setup_cred
   do_check_eq(b2h(unwrapKey), "8ff58975be391338e4ec5d7138b5ed7b65c7d1bfd1f3a4f93e05aa47d5b72be9");
 });
 
 add_task(function* test_client_stretch_kdf() {
   let pbkdf2 = CryptoUtils.pbkdf2Generate;
   let hkdf = CryptoUtils.hkdf;
   let expected = vectors["client stretch-KDF"];
 
-  let emailUTF8 = h2s(expected.email);
-  let passwordUTF8 = h2s(expected.password);
+  let email = h2s(expected.email);
+  let password = h2s(expected.password);
 
   // Intermediate value from sjcl implementation in fxa-js-client
   // The key thing is the c3a9 sequence in "andré"
-  let salt = Credentials.keyWordExtended("quickStretch", emailUTF8);
+  let salt = Credentials.keyWordExtended("quickStretch", email);
   do_check_eq(b2h(salt), "6964656e746974792e6d6f7a696c6c612e636f6d2f7069636c2f76312f717569636b537472657463683a616e6472c3a9406578616d706c652e6f7267");
 
   let options = {
     stretchedPassLength: 32,
     pbkdf2Rounds: 1000,
     hmacAlgorithm: Ci.nsICryptoHMAC.SHA256,
     hmacLength: 32,
     hkdfSalt: h2b("00"),
     hkdfLength: 32,
   };
 
-  let results = yield Credentials.setup(emailUTF8, passwordUTF8, options);
-
-  do_check_eq(emailUTF8, results.emailUTF8,
-      "emailUTF8 is wrong");
-
-  do_check_eq(passwordUTF8, results.passwordUTF8,
-      "passwordUTF8 is wrong");
+  let results = yield Credentials.setup(email, password, options);
 
   do_check_eq(expected.quickStretchedPW, b2h(results.quickStretchedPW),
       "quickStretchedPW is wrong");
 
   do_check_eq(expected.authPW, b2h(results.authPW),
       "authPW is wrong");
 });