зеркало из https://github.com/mozilla/gecko-dev.git
Fix crypto component to not mangle certain strings when doing 8/16 bit character conversion.
This commit is contained in:
Родитель
c0ef3a39f4
Коммит
7eb4f6a421
|
@ -40,7 +40,7 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(d3b0f750-c976-46d0-be20-96b24f4684bc)]
|
||||
[scriptable, uuid(f4463043-315e-41f3-b779-82e900e6fffa)]
|
||||
interface IWeaveCrypto : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ interface IWeaveCrypto : nsISupports
|
|||
* A base64-encoded initialization vector
|
||||
* @returns Encrypted data, base64 encoded
|
||||
*/
|
||||
ACString encrypt(in ACString clearText,
|
||||
ACString encrypt(in AUTF8String clearText,
|
||||
in ACString symmetricKey, in ACString iv);
|
||||
|
||||
/**
|
||||
|
@ -95,7 +95,7 @@ interface IWeaveCrypto : nsISupports
|
|||
* A base64-encoded initialization vector
|
||||
* @returns Decrypted data (not base64-encoded)
|
||||
*/
|
||||
ACString decrypt(in ACString cipherText,
|
||||
AUTF8String decrypt(in ACString cipherText,
|
||||
in ACString symmetricKey, in ACString iv);
|
||||
|
||||
/**
|
||||
|
|
|
@ -58,6 +58,14 @@ function run_test() {
|
|||
do_check_eq(cipherText, "HeC7miVGDcpxae9RmiIKAw==");
|
||||
do_check_eq(clearText, mySecret);
|
||||
|
||||
// Test non-ascii input
|
||||
// ("testuser1" using similar-looking glyphs)
|
||||
mySecret = String.fromCharCode(355, 277, 349, 357, 533, 537, 101, 345, 185);
|
||||
cipherText = cryptoSvc.encrypt(mySecret, key, iv);
|
||||
clearText = cryptoSvc.decrypt(cipherText, key, iv);
|
||||
do_check_eq(cipherText, "Pj4ixByXoH3SU3JkOXaEKPgwRAWplAWFLQZkpJd5Kr4=");
|
||||
do_check_eq(clearText, mySecret);
|
||||
|
||||
// Tests input spanning a block boundary (AES block size is 16 bytes)
|
||||
mySecret = "123456789012345";
|
||||
cipherText = cryptoSvc.encrypt(mySecret, key, iv);
|
||||
|
|
Загрузка…
Ссылка в новой задаче