Home Reference Source Test

test/hasher/sha384Test.mjs

/*global describe, it */
'use strict';
import TestHasher from "../TestHasher";
import Sha512 from "../../src/hasher/sha512";

// The SHA384 test suite
// http://tools.ietf.org/html/rfc4634

class Sha384Test extends TestHasher {
  test() {
    let t = this;
    /** @test {Sha512} */
    describe('Hash sha384 tests', function () {
      it("sha384('')", function () {
        t.testHash({
          message: '',
          hash: '38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b'
        });
      });

      it("sha384('abc')", function () {
        t.testHash({
          message: 'abc',
          hash: 'cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7'
        });
      });

      it("sha384('abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq')", function () {
        t.testHash({
          message: 'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq',
          hash: '3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b'
        });
      });

      it("sha384('abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu')", function () {
        t.testHash({
          message: 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu',
          hash: '09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039'
        });
      });

      it("sha384('01234567' x 80)", function () {
        t.testHash({
          message: new Array(81).join('01234567'),
          hash: '2fc64a4f500ddb6828f6a3430b8dd72a368eb7f3a8322a70bc84275b9c0b3ab00d27a5cc3c2d224aa6b61a0d79fb4596'
        });
      });

      /**
       * @test {Sha512#setState}
       * @test {Sha512#getState}
       */
      it('hash setState() getState()', function () {
        t.testSetGetState();
      });
    });
  }

  getInstance(options) {
    return new Sha512(options || {length: 384});
  }
}

export default Sha384Test;