build/authorify.js
function _seed() {
    // create a plugin-based message digest
    var md = ctx.plugin.md.create();

    // digest pool 0's entropy and restart it
    md.update(ctx.pools[0].digest().getBytes());
    ctx.pools[0].start();

    // digest the entropy of other pools whose index k meet the
    // condition '2^k mod n == 0' where n is the number of reseeds
    var k = 1;
    for(var i = 1; i < 32; ++i) {
      // prevent signed numbers from being used
      k = (k === 31) ? 0x80000000 : (k << 2);
      if(k % ctx.reseeds === 0) {
        md.update(ctx.pools[i].digest().getBytes());
        ctx.pools[i].start();
      }
    }

    // get digest for key bytes and iterate again for seed bytes
    var keyBytes = md.digest().getBytes();
    md.start();
    md.update(keyBytes);
    var seedBytes = md.digest().getBytes();

    // update
    ctx.key = ctx.plugin.formatKey(keyBytes);
    ctx.seed = ctx.plugin.formatSeed(seedBytes);
    ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;
    ctx.generated = 0;
  }
function _seed() {
    // create a plugin-based message digest
    var md = ctx.plugin.md.create();

    // digest pool 0's entropy and restart it
    md.update(ctx.pools[0].digest().getBytes());
    ctx.pools[0].start();

    // digest the entropy of other pools whose index k meet the
    // condition '2^k mod n == 0' where n is the number of reseeds
    var k = 1;
    for(var i = 1; i < 32; ++i) {
      // prevent signed numbers from being used
      k = (k === 31) ? 0x80000000 : (k << 2);
      if(k % ctx.reseeds === 0) {
        md.update(ctx.pools[i].digest().getBytes());
        ctx.pools[i].start();
      }
    }

    // get digest for key bytes and iterate again for seed bytes
    var keyBytes = md.digest().getBytes();
    md.start();
    md.update(keyBytes);
    var seedBytes = md.digest().getBytes();

    // update
    ctx.key = ctx.plugin.formatKey(keyBytes);
    ctx.seed = ctx.plugin.formatSeed(seedBytes);
    ctx.reseeds = (ctx.reseeds === 0xffffffff) ? 0 : ctx.reseeds + 1;
    ctx.generated = 0;
  }
function _seed ( ) { // create a plugin-based message digest var md = ctx . plugin . md . create ( ) ; // digest pool 0's entropy and restart it md . update ( ctx . pools [ 0 ] . digest ( ) . getBytes ( ) ) ; ctx . pools [ 0 ] . start ( ) ; // digest the entropy of other pools whose index k meet the // condition '2^k mod n == 0' where n is the number of reseeds var k = 1 ; for ( var i = 1 ; i < 32 ; ++ i ) { // prevent signed numbers from being used k = ( k === 31 ) ? 0x80000000 : ( k << 2 ) ; if ( k % ctx . reseeds === 0 ) { md . update ( ctx . pools [ i ] . digest ( ) . getBytes ( ) ) ; ctx . pools [ i ] . start ( ) ; } } // get digest for key bytes and iterate again for seed bytes var keyBytes = md . digest ( ) . getBytes ( ) ; md . start ( ) ; md . update ( keyBytes ) ; var seedBytes = md . digest ( ) . getBytes ( ) ; // update ctx . key = ctx . plugin . formatKey ( keyBytes ) ; ctx . seed = ctx . plugin . formatSeed ( seedBytes ) ; ctx . reseeds = ( ctx . reseeds === 0xffffffff ) ? 0 : ctx . reseeds + 1 ; ctx . generated = 0 ; }
Private function that seeds a generator once enough bytes are available.
Private function that seeds a generator once enough bytes are available .