Examples of generateSeed()


Examples of java.security.SecureRandom.generateSeed()

            // and afterwards (in the thread) using the regular algorithm.
            Runnable runnable = new Runnable() {
                public void run() {
                    try {
                        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
                        byte[] seed = sr.generateSeed(20);
                        synchronized (cachedSecureRandom) {
                            cachedSecureRandom.setSeed(seed);
                            seeded = true;
                        }
                    } catch (Exception e) {
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

  private byte[] generateSalt(int saltSize) throws NoSuchAlgorithmException, NoSuchProviderException {
    SecureRandom sr = new SecureRandom();
    // Note that the nexus code seeds the SecureRandom:
    // this seems to be both unnecessary and incorrect
    return sr.generateSeed(saltSize);
  }

  private Cipher buildCipher(String passphrase, byte[] salt, int mode) throws InvalidKeySpecException,
      NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException {
    KeySpec keySpec = new PBEKeySpec(passphrase.toCharArray());
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

            // and afterwards (in the thread) using the regular algorithm.
            Runnable runnable = new Runnable() {
                public void run() {
                    try {
                        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
                        byte[] seed = sr.generateSeed(20);
                        synchronized (cachedSecureRandom) {
                            cachedSecureRandom.setSeed(seed);
                            seeded = true;
                        }
                    } catch (Exception e) {
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

        // generator "self seeds".  If a setSeed() is called before
        // any nextBytes call, no self seeding is done.  We use the
        // self seeding and our own bytes.
       
        // Access the internal seed generator.
        byte[] seed1 = sRandom.generateSeed(16) ;
        byte[] seed2 = LibUUID.makeSeed() ;
        // seeds are cumulative
        sRandom.setSeed(seed1) ;                    
        sRandom.setSeed(seed2) ;                    
        return sRandom ;
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

                ("Hash algorithm '"+hashAlgo+"' is not supported for document write protection.");
            }

       
            SecureRandom random = new SecureRandom();
            byte salt[] = random.generateSeed(16);
   
            // Iterations specifies the number of times the hashing function shall be iteratively run (using each
            // iteration's result as the input for the next iteration).
            int spinCount = 100000;
   
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

    new SecureRandom(seed).nextBytes(new byte[20]);
  }

  public final void testGenerateSeed() {
    SecureRandom sr = new SecureRandom();
    byte[] seed = sr.generateSeed(5);
    new SecureRandom(seed).nextBytes(new byte[20]);
  }
}
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

        // generator "self seeds".  If a setSeed() is called before
        // any nextBytes call, no self seeding is done.  We use the
        // self seeding and our own bytes.
       
        // Access the internal seed generator.
        byte[] seed1 = sRandom.generateSeed(16) ;
        byte[] seed2 = LibUUID.makeSeed() ;
        // seeds are cumulative
        sRandom.setSeed(seed1) ;                    
        sRandom.setSeed(seed2) ;                    
        return sRandom ;
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

                newRandom = SecureRandom.getInstance(algorithm, algorithmProvider);
            }

            /* ensure the SecureRandom gets seeded */
            long before = log.isDebugEnabled() ? 0 : System.currentTimeMillis();
            newRandom.setSeed(newRandom.generateSeed(seedLength));
            if (log.isDebugEnabled()) {
                long now = System.currentTimeMillis();
                log.debug("secureRandom.setSeed took " + ((now - before) / 1000.0) +" seconds.");
            }
            delegate = newRandom;
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

            log.info("Falling back to default random algorithm provider because '" + algorithmProvider + "' is not available.", e);
            /* use the default provider */
            try {
                newRandom = SecureRandom.getInstance(algorithm);
                /* ensure the SecureRandom gets seeded */
                newRandom.setSeed(newRandom.generateSeed(seedLength));
                delegate = newRandom;
            } catch (NoSuchAlgorithmException e1) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here

Examples of java.security.SecureRandom.generateSeed()

                if (LOG.isDebugEnabled())
                    LOG.debug("Reseeding {}",this);
                if (_random instanceof SecureRandom)
                {
                    SecureRandom secure = (SecureRandom)_random;
                    secure.setSeed(secure.generateSeed(8));
                }
                else
                {
                    _random.setSeed(_random.nextLong()^System.currentTimeMillis()^seedTerm^Runtime.getRuntime().freeMemory());
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.