@peculiar/webcrypto-test
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.7 • Public • Published

    webcrypto-test

    License Node.js CI Coverage Status npm version

    This module allows you to test cryptographic modules.

    Table Of Contents

    Installing

    npm install @peculiar/webcrypto-test
    

    Using

    Run all tests

    const { WebcryptoTest } = require("@peculiar/webcrypto-test");
    const { Crypto } = require("@peculiar/webcrypto");
     
    WebcryptoTest.check( new Crypto());

    Run selected tests

    const { WebcryptoTest } = require("@peculiar/webcrypto-test");
    const  vectors = require("./vectors");
    const { Crypto } = require("@peculiar/webcrypto");
     
    WebcryptoTest.check(new Crypto(), [vectors.ECDSA, vectors.ECDH]);

    Disable tests

    To exclude vectors, you must set them to true

    const { WebcryptoTest } = require("@peculiar/webcrypto-test");
    const { Crypto } = require("@peculiar/webcrypto");
     
    WebcryptoTest.check(new Crypto(), {
      ECDSA: true,
      ECDH: true,
    });

    Run custom test

    const { WebcryptoTest } = require("@peculiar/webcrypto-test");
    const { Crypto } = require("@peculiar/webcrypto");
     
    const myVector = {
      name: "AES-128-CBC",
      actions: {
        generateKey: [
          {
            algorithm: { name: "AES-CBC", length: 128 },
            extractable: true,
            keyUsages: ["encrypt", "decrypt"],
          },
        ],
        encrypt: [
          {
            algorithm: {
              name: "AES-CBC",
              iv: Buffer.from("1234567890abcdef"),
            },
            data: Buffer.from("test message"),
            encData: Buffer.from("d5df3ea1598defe7446420802baef28e", "hex"),
            key: {
              format: "raw",
              data: Buffer.from("1234567890abcdef"),
              algorithm: { name: "AES-CBC" },
              extractable: true,
              keyUsages: ["encrypt", "decrypt"],
            },
          },
        ]
      }
    }
     
    WebcryptoTest.add(new Crypto(), myVector);

    Install

    npm i @peculiar/webcrypto-test

    DownloadsWeekly Downloads

    8

    Version

    1.0.7

    License

    MIT

    Unpacked Size

    130 kB

    Total Files

    31

    Last publish

    Collaborators

    • donskov
    • apilguk
    • peculiarventures
    • yury.strozhevsky
    • microshine
    • rmhrisk