Package java.security

Examples of java.security.SecureRandom.nextBytes()


    //random_bits1 = md5.digest(SshMisc.addArrayOfBytes(md5.digest((password + login).getBytes()), random_bits1));
    //random_bits2 = md5.digest(SshMisc.addArrayOfBytes(md5.digest((password + login).getBytes()), random_bits2));


    SecureRandom random = new java.security.SecureRandom(random_bits1); //no supported by netscape :-(
    random.nextBytes(random_bits1);
    random.nextBytes(random_bits2);

    session_key = SshMisc.addArrayOfBytes(random_bits1, random_bits2);

    //Xor the 16 first bytes with the session-id
View Full Code Here


    //random_bits2 = md5.digest(SshMisc.addArrayOfBytes(md5.digest((password + login).getBytes()), random_bits2));


    SecureRandom random = new java.security.SecureRandom(random_bits1); //no supported by netscape :-(
    random.nextBytes(random_bits1);
    random.nextBytes(random_bits2);

    session_key = SshMisc.addArrayOfBytes(random_bits1, random_bits2);

    //Xor the 16 first bytes with the session-id
    byte[] session_keyXored = SshMisc.XORArrayOfBytes(random_bits1, hash_md5);
View Full Code Here

  static public byte getNotZeroRandomByte() {
    byte[] randomBytes = new byte[32];

    SecureRandom random = new java.security.SecureRandom(randomBytes);
    while (true) {
      random.nextBytes(randomBytes);
      for (int i = 0; i < randomBytes.length; i++)
        if (randomBytes[i] != 0)
          return randomBytes[i];
    }
  }
View Full Code Here

            sr = SecureRandom.getInstance(SHA_1_PRNG);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("Could not find algorithm: " + SHA_1_PRNG, e);
        }
        byte[] salt = new byte[SALT_LENGTH];
        sr.nextBytes(salt);
        return salt;
    }

    public static byte[] hashPassword(String password, byte[] salt) {
        try {
View Full Code Here

              if(cis == null || cisCounter > Long.MAX_VALUE/2) {
                  // Reset it well before the birthday paradox (note this is actually counting bytes).
                  byte[] key = new byte[16];
                  byte[] iv = new byte[16];
                  SecureRandom rng = NodeStarter.getGlobalSecureRandom();
                  rng.nextBytes(key);
                  rng.nextBytes(iv);
                  AESFastEngine e = new AESFastEngine();
                  SICBlockCipher ctr = new SICBlockCipher(e);
                  ctr.init(true, new ParametersWithIV(new KeyParameter(key),iv));
                  cis = new CipherInputStream(zis, new BufferedBlockCipher(ctr));
View Full Code Here

                  // Reset it well before the birthday paradox (note this is actually counting bytes).
                  byte[] key = new byte[16];
                  byte[] iv = new byte[16];
                  SecureRandom rng = NodeStarter.getGlobalSecureRandom();
                  rng.nextBytes(key);
                  rng.nextBytes(iv);
                  AESFastEngine e = new AESFastEngine();
                  SICBlockCipher ctr = new SICBlockCipher(e);
                  ctr.init(true, new ParametersWithIV(new KeyParameter(key),iv));
                  cis = new CipherInputStream(zis, new BufferedBlockCipher(ctr));
                  cisCounter = 0;
View Full Code Here

    // Confirm
    {
      byte[] b1 = new byte[128];
      byte[] b2 = new byte[128];
      r1.nextBytes(b1);
      r2.nextBytes(b2);
      if (!Arrays.equals(b1, b2)) {
        System.err.println("SHA1PRNG is not repeatable despite same seed, skipping test");
        return;
      }
    }
View Full Code Here

            if ((opmode == Cipher.ENCRYPT_MODE) || (opmode == Cipher.WRAP_MODE))
            {
                byte[]  iv = new byte[ivLength];

                ivRandom.nextBytes(iv);
                param = new ParametersWithIV(param, iv);
                ivParam = (ParametersWithIV)param;
            }
            else
            {
View Full Code Here

            if ((opmode == Cipher.ENCRYPT_MODE) || (opmode == Cipher.WRAP_MODE))
            {
                byte[]  iv = new byte[ivLength];

                ivRandom.nextBytes(iv);
                param = new ParametersWithIV(param, iv);
                ivParam = (ParametersWithIV)param;
            }
            else if (cipher.getUnderlyingCipher().getAlgorithmName().indexOf("PGPCFB") < 0)
            {
View Full Code Here

            if ((opmode == Cipher.ENCRYPT_MODE) || (opmode == Cipher.WRAP_MODE))
            {
                byte[]  iv = new byte[ivLength];

                ivRandom.nextBytes(iv);
                param = new ParametersWithIV(param, iv);
                ivParam = (ParametersWithIV)param;
            }
            else
            {
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.