Bug 1243594 (part 1) - remove misleading references to utf8 in Credentials.jsm. r=rfkelly
authorMark Hammond <mhammond@skippinet.com.au>
Fri, 26 Feb 2016 15:46:30 +1100
changeset 322052 6decc397d3d5233fea362fccc072605594d7a689
parent 322051 ec700560eba22e7efcb4e263650bc5e88f65d4bf
child 322053 19950e70819a7f7a6089059cea59e04b9ef078fc
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrfkelly
bugs1243594
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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");
 });