mirror of
https://github.com/moparisthebest/mail
synced 2024-11-25 18:32:20 -05:00
21 lines
415 B
JavaScript
21 lines
415 B
JavaScript
|
module("ECC Crypto");
|
||
|
|
||
|
var keys,
|
||
|
ciphertext,
|
||
|
plaintext = 'Hello, World!';
|
||
|
|
||
|
test("Generate Keys", function() {
|
||
|
// generate keypair
|
||
|
keys = sjcl.ecc.elGamal.generateKeys(384, 1);
|
||
|
ok(keys);
|
||
|
});
|
||
|
|
||
|
test("Encrypt", function() {
|
||
|
ciphertext = sjcl.encrypt(keys.pub, plaintext);
|
||
|
ok(ciphertext);
|
||
|
});
|
||
|
|
||
|
test("Decrypt", function() {
|
||
|
var decrypted = sjcl.decrypt(keys.sec, ciphertext);
|
||
|
equal(plaintext, decrypted);
|
||
|
});
|