| <script src="../../resources/js-test-pre.js"></script> |
| <script src="../resources/common.js"></script> |
| description("Test encrypting&decrypting using AES-GCM algorithm with a generated 256bit key"); |
| var plainText = "Hello, World!"; |
| iv: asciiToUint8Array("jnOw99oOZFLIEPMr"), |
| debug("Generating a key..."); |
| crypto.subtle.generateKey({name: "aes-gcm", length: 256}, true, ["decrypt", "encrypt"]).then(function(result) { |
| return crypto.subtle.encrypt(aesGcmParams, key, asciiToUint8Array(plainText)); |
| }).then(function(result) { |
| shouldNotBeEqualToString("bytesToASCIIString(cipherText)", plainText); |
| return crypto.subtle.decrypt(aesGcmParams, key, cipherText); |
| }).then(function(result) { |
| shouldBe("bytesToASCIIString(decryptedText)", "plainText"); |
| <script src="../../resources/js-test-post.js"></script> |