/* * Copyright 2018 Scytl Secure Electronic Voting SA * * All rights reserved * * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package */ /* jshint node:true */ 'use strict'; var SecureRandomService = require('./service'); var validator = require('./input-validator'); module.exports = { /** * Creates a new SecureRandomService object, which encapsulates a secure * random service. * *
* As soon as this service is instantiated, entropy collection will start.
* The first time that a random generator created by the service is used,
* the entropy collection will stop and the pseudo-random number generator
* (PRNG) of the service will be initialized with the collected entropy.
*
* @function newService
* @global
* @param {Object}
* [options] An object containing optional arguments.
* @param {Uint8Array}
* [options.prngSeed=Internally generated] The seed to initialize
* the PRNG.
* @param {number}
* [options.maxEntropyCounter=256] The amount of entropy to
* accumulate before stopping collectors. It must be a positive
* number.
* @param {number}
* [options.hashUpdaterInterval=1000] The interval (in
* milliseconds) at which entropy data is to be hashed. It must be a postive
* number.
* @param {Object}
* [options.windowObject=Built-in window object]
* The window
object provided to the collectors.
* @param {Object}
* [options.cryptoApi=Built-in cryptographic library]
* The cryptographic library supplied to the WebKit collector (if
* the latter is being used).
* @param {Object}
* [options.privateKeyData=Not used] The private key collector
* data.
* @param {string}
* options.privateKeyData.privateKey The private key, in PEM
* format.
* @param {number}
* options.privateKeyData.pinEntropy The PIN entropy of the
* private key. It must be a positive number.
* @param {boolean}
* [options.noDefaultCollectors=false] If true
, no
* default entropy collectors are to be used.
* @returns {SecureRandomService} The new SecureRandomService object.
* @example