miscreant
Version:
Misuse resistant symmetric encryption library providing AES-SIV (RFC 5297), AES-PMAC-SIV, and STREAM constructions
47 lines (35 loc) • 1.34 kB
text/typescript
// Copyright (C) 2016-2017 Dmitry Chestnykh, Tony Arcieri
// MIT License. See LICENSE file for details.
import { suite, test } from "mocha-typescript";
import { expect } from "chai";
import { AesPmacExample } from "./support/test_vectors";
import WebCrypto = require("node-webcrypto-ossl");
import * as miscreant from "../src/index";
class PolyfillAesPmacSpec {
static vectors: AesPmacExample[];
static async before() {
this.vectors = await AesPmacExample.loadAll();
}
async "passes the AES-PMAC test vectors"() {
const polyfillProvider = new miscreant.PolyfillCryptoProvider();
for (let v of PolyfillAesPmacSpec.vectors) {
const mac = await miscreant.PMAC.importKey(polyfillProvider, v.key);
await mac.update(v.message);
expect(v.tag).to.eql(await mac.finish());
}
}
}
class WebCryptoAesPmacSpec {
static vectors: AesPmacExample[];
static async before() {
this.vectors = await AesPmacExample.loadAll();
}
async "passes the AES-PMAC test vectors"() {
const webCryptoProvider = new miscreant.WebCryptoProvider(new WebCrypto());
for (let v of PolyfillAesPmacSpec.vectors) {
const mac = await miscreant.PMAC.importKey(webCryptoProvider, v.key);
await mac.update(v.message);
expect(v.tag).to.eql(await mac.finish());
}
}
}