Java 类java.security.SecureRandomSpi 实例源码

项目:crypto-gwt    文件:SecureRandomSpiFactory.java   
public SecureRandomSpi create(Object constructorParam) {
    try {
        return Adaptor.adapt(type.newInstance(), SecureRandomSpi.class);
    } catch (Exception e) {
        throw new IllegalArgumentException("Invalid type: " + type, e);
    }
}
项目:freeVM    文件:F_SecureRandomTest_04.java   
public int test() {
    if ("failed".equalsIgnoreCase(Security.getProperty("policy.allowSystemProperty"))) {
        return error("An extra policy feature is disabled by default.");
    }

    System.setSecurityManager(new SecurityManager());       

    Provider p = new SecureRandomProvider(ProviderName, Version, Description);
    if (p == null) {
        return fail("Couldn't create secure random provider. Test failed.");           
    }

    SecureRandomSpi secureRandomSpi = new SecureRandomSPImplementation();
    if (secureRandomSpi == null) {
        return fail("Couldn't create an instance of SecureRandomSPImplementation. Test failed.");
    }

    Security.addProvider(p);
    SecureRandom random = new MySecureRandom(secureRandomSpi, p);        

    log.info("Generating seed...");
    byte[] seed = random.generateSeed(100);
    log.info("OK\nSeeding pseudo-random number generator...");
    random.setSeed(seed);
    log.info("OK\nGetting pseudo-random numbers...");
    byte[] numbers = new byte[10];        
    random.nextBytes(numbers);
    log.info("OK");

    return pass("Test passed");
}
项目:ModifiableVariable    文件:BadRandom.java   
public BadRandom(Random r, SecureRandomSpi secureRandomSpi, Provider provider) {
    this.r = r;
}
项目:PasswordSafe    文件:EntropyGathererBase.java   
protected EntropyGathererBase(String name)
{
    jvmRandom = new SecureRandom();

    random = new DigestRandomGenerator(new SHA512Digest());

    spi = new SecureRandomSpi()
    {
        private boolean init = true;

        protected final void engineSetSeed(byte[] seed)
        {
            random.addSeedMaterial(seed);
        }

        protected final void engineNextBytes(byte[] bytes)
        {
            if(init)
            {
                // initialize generator with randomness from jvm
                random.addSeedMaterial(jvmRandom.generateSeed(256));
                init = false;
            }
            else
            {
                random.addSeedMaterial(jvmRandom.nextLong());                   
            }

            random.addSeedMaterial(System.currentTimeMillis());
            random.addSeedMaterial(Runtime.getRuntime().freeMemory());
            random.addSeedMaterial(System.nanoTime());

            random.nextBytes(bytes);
        }

        protected final byte[] engineGenerateSeed(int numBytes)
        {
            byte[] b = new byte[numBytes];
            engineNextBytes(b);
            return b;
        }
    };

    provider = new Provider(name, 1.2, "andy goryachev") { };
}
项目:j2objc    文件:SecureRandom2Test.java   
public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
    super(secureRandomSpi, provider);
}
项目:In-the-Box-Fork    文件:SecureRandom2Test.java   
public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
    super(secureRandomSpi, provider);
}
项目:crypto-gwt    文件:SecureRandomSpiFactory.java   
public SecureRandomSpiFactory(Class<? extends java.security.SecureRandomSpi> type) {
    this.type = type;
}
项目:cn1    文件:SecureRandom2Test.java   
public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
    super(secureRandomSpi, provider);
}
项目:freeVM    文件:SecureRandom2Test.java   
public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
    super(secureRandomSpi, provider);
}
项目:freeVM    文件:SecureRandom2Test.java   
public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
    super(secureRandomSpi, provider);
}
项目:freeVM    文件:F_SecureRandomTest_04.java   
public MySecureRandom(SecureRandomSpi secureRandomSpi, Provider provider) {
    super(secureRandomSpi, provider);
    log.info("MySecureRandom ctor has been called.");
}