Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.bouncycastle.pqc.crypto.ntru;
An implementation of the deterministic pseudo-random generator in EESS section
public class NTRUSignerPrng
    private int counter;
    private byte[] seed;
    private Digest hashAlg;

Constructs a new PRNG and seeds it with a byte array.

seed a seed
hashAlg the hash algorithm to use
    NTRUSignerPrng(byte[] seedDigest hashAlg)
         = 0;
        this. = seed;
        this. = hashAlg;

Returns n random bytes

n number of bytes to return
the next n random bytes
    byte[] nextBytes(int n)
        ByteBuffer buf = ByteBuffer.allocate(n);
        while (buf.hasRemaining())
            ByteBuffer cbuf = ByteBuffer.allocate(. + 4);
            byte[] array = cbuf.array();
            byte[] hash = new byte[.getDigestSize()];
            .update(array, 0, array.length);
            .doFinal(hash, 0);
            if (buf.remaining() < hash.length)
                buf.put(hash, 0, buf.remaining());
        return buf.array();
New to GrepCode? Check out our FAQ X