2010-06-22 00:20:31 -07:00
|
|
|
Cu.import("resource://services-sync/util.js");
|
|
|
|
|
2009-07-21 15:02:30 -07:00
|
|
|
function run_test() {
|
2010-06-22 00:20:31 -07:00
|
|
|
let cryptoSvc = Svc.Crypto;
|
2009-07-21 15:02:30 -07:00
|
|
|
|
|
|
|
var salt = cryptoSvc.generateRandomBytes(16);
|
|
|
|
var iv = cryptoSvc.generateRandomIV();
|
|
|
|
|
|
|
|
// Tests with a 2048 bit key (the default)
|
|
|
|
do_check_eq(cryptoSvc.keypairBits, 2048)
|
|
|
|
var privOut = {};
|
|
|
|
cryptoSvc.generateKeypair("passphrase", salt, iv, {}, privOut);
|
|
|
|
var privKey = privOut.value;
|
|
|
|
|
|
|
|
// Check with correct passphrase
|
|
|
|
var shouldBeTrue = cryptoSvc.verifyPassphrase(privKey, "passphrase",
|
|
|
|
salt, iv);
|
|
|
|
do_check_eq(shouldBeTrue, true);
|
|
|
|
|
|
|
|
// Check with incorrect passphrase
|
|
|
|
var shouldBeFalse = cryptoSvc.verifyPassphrase(privKey, "NotPassphrase",
|
|
|
|
salt, iv);
|
|
|
|
do_check_eq(shouldBeFalse, false);
|
|
|
|
}
|