Files
firefox/security/manager/ssl/nsISecretDecoderRing.idl
T
Cykesiopka 59346183e8 Bug 1305531 - Use ACString instead of AUTF8String in nsISecretDecoderRing.idl to unbreak decrypting saved usernames and passwords. r=keeler
Bug 1275841 switched some IDL types from "string" to "AUTF8String".
This had the unintentional effect of breaking decryption of previously saved
passwords that contained special characters.

In particular, the AUTF8String type means XPConnect may convert any strings
using that type to UTF-16 when crossing XPConnect boundaries.
However, crypto-SDR.js (responsible for encrypting and decrypting for the
password manager) expects to do conversions between UTF-16 and UTF-8 itself.
What ends up happening is crypto-SDR.js decrypts a saved password and tries to
convert from UTF-8 to UTF-16, but fails because the decrypted text is already
UTF-16.

The solution is to use ACString instead of AUTF8String. ACString does not result
in automatic encoding changes, so the expectations of crypto-SDR.js are met
again, and lets SecretDecoderRing.cpp keep the benefit of working with smart
string types.

This change probably breaks passwords saved after Bug 1275841 landed and before
this patch landed, but the number of passwords this patch breaks is probably
much lower than the number of passwords that would be broken if this patch did
not land.

MozReview-Commit-ID: 6Z01zfwJ6t7
2016-10-01 09:29:28 +08:00

50 lines
1.6 KiB
Plaintext

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
[scriptable, uuid(0EC80360-075C-11d4-9FD4-00C04F1B83D8)]
interface nsISecretDecoderRing: nsISupports {
/**
* Encrypt to Base64 output.
* Note that the input must basically be a byte array (i.e. the code points
* must be within the range [0, 255]). Hence, using this method directly to
* encrypt passwords (or any text, really) won't work as expected.
* Instead, use something like nsIScriptableUnicodeConverter to first convert
* the desired password or text to UTF-8, then encrypt that. Remember to
* convert back when calling decryptString().
*
* @param text The text to encrypt.
* @return The encrypted text, encoded as Base64.
*/
ACString encryptString(in ACString text);
/**
* Decrypt Base64 input.
* See the encryptString() documentation - this method has basically the same
* limitations.
*
* @param encryptedBase64Text Encrypted input text, encoded as Base64.
* @return The decoded text.
*/
ACString decryptString(in ACString encryptedBase64Text);
/**
* Prompt the user to change the password on the SDR key.
*/
void changePassword();
/**
* Logout of the security device that protects the SDR key.
*/
void logout();
/**
* Logout of the security device that protects the SDR key and tear
* down authenticated objects.
*/
void logoutAndTeardown();
};