describe('Authentication', () => {
	it('generate MAC and verify it against original message', done => {
		window.newMacKey().then(key => {
			const message = 'The quick brown fox jumps over the lazy dog';
			const encoded = new TextEncoder('utf-8').encode(message);

			return window.generateMac(encoded, key).then(signature => {
				return window.verifyMac(signature, encoded, key).then(valid => {
					expect(valid).toBe(true);
					done();
				});
			});
		}).catch(error => done.fail(error.message));
	});
});

@@ -502,13 +502,637 @@
 ));%0A%09%7D);
+%0A%0A%09it('tamper with the message to verify that it will fail MAC verification', done =%3E %7B%0A%09%09window.newMacKey().then(key =%3E %7B%0A%09%09%09const message = 'The quick brown fox jumps over the lazy dog';%0A%09%09%09const encoded = new TextEncoder('utf-8').encode(message);%0A%0A%09%09%09return window.generateMac(encoded, key).then(signature =%3E %7B%0A%09%09%09%09encoded%5Bencoded.length - 1%5D %5E= 1;%0A%0A%09%09%09%09return window.verifyMac(signature, encoded, key).then(valid =%3E %7B%0A%09%09%09%09%09if (valid) %7B%0A%09%09%09%09%09%09done.fail('Expected message to be rejected');%0A%09%09%09%09%09%7D else %7B%0A%09%09%09%09%09%09expect(true).toBe(true);%0A%09%09%09%09%09%09done();%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D);%0A%09%09%09%7D);%0A%09%09%7D).catch(error =%3E done.fail(error.message));%0A%09%7D);
 %0A%7D);%0A

Add test for authenticated message tampering