Package java.security

Examples of java.security.SecureRandom.nextBytes()


            }
        } else {
            SecureRandom random = new SecureRandom();
            random.setSeed(System.currentTimeMillis());
            byte[] bytes = new byte[16];
            random.nextBytes(bytes);
            spec = new SecretKeySpec(bytes, "AES");
            File dir = location.getParentFile();
            if (!dir.exists()) {
                dir.mkdirs();
            }
View Full Code Here


            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
            sctBuilder.prepare(doc, crypto);

            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            byte[] tempSecret = new byte[16];
            random.nextBytes(tempSecret);

            // Store the secret
            this.secrets.put(sctBuilder.getIdentifier(), tempSecret);

            String tokenId = sctBuilder.getSctId();
View Full Code Here

            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
            sctBuilder.prepare(doc, crypto);

            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            byte[] tempSecret = new byte[16];
            random.nextBytes(tempSecret);

            // Store the secret
            this.secrets.put(sctBuilder.getIdentifier(), tempSecret);

            String tokenId = sctBuilder.getSctId();
View Full Code Here

            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
            sctBuilder.prepare(doc, crypto);

            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            byte[] tempSecret = new byte[16];
            random.nextBytes(tempSecret);

            // Store the secret
            this.secrets.put(sctBuilder.getIdentifier(), tempSecret);

            String tokenId = sctBuilder.getSctId();
View Full Code Here

            WSSecSecurityContextToken sctBuilder = new WSSecSecurityContextToken();
            sctBuilder.prepare(doc, crypto);

            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            byte[] tempSecret = new byte[16];
            random.nextBytes(tempSecret);

            // Store the secret
            this.secrets.put(sctBuilder.getIdentifier(), tempSecret);

            String tokenId = sctBuilder.getSctId();
View Full Code Here

        throws NoSuchAlgorithmException, InvalidKeySpecException
    {
        // Generate a random salt
        SecureRandom random = new SecureRandom();
        byte[] salt = new byte[SALT_BYTE_SIZE];
        random.nextBytes(salt);

        // Hash the password
        byte[] hash = pbkdf2(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE);
        // format iterations:salt:hash
        return PBKDF2_ITERATIONS + ":" + toHex(salt) + ":" +  toHex(hash);
View Full Code Here

        throws NoSuchAlgorithmException, InvalidKeySpecException
    {
        // Generate a random salt
        SecureRandom random = new SecureRandom();
        byte[] salt = new byte[SALT_BYTE_SIZE];
        random.nextBytes(salt);

        // Hash the password
        byte[] hash = pbkdf2(password, salt, PBKDF2_ITERATIONS, HASH_BYTE_SIZE);
        // format iterations:salt:hash
        return "sha1:" + PBKDF2_ITERATIONS + ":" + toBase64(salt) + ":" +  toBase64(hash);
View Full Code Here

            len = 1;
        }
        byte[] buff = new byte[len];
        SecureRandom sr = getSecureRandom();
        synchronized (sr) {
            sr.nextBytes(buff);
        }
        return buff;
    }

    /**
 
View Full Code Here

     */
    protected byte[] generateEphemeralKey(int keySize) throws TrustException {
        try {
            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            byte[] temp = new byte[keySize / 8];
            random.nextBytes(temp);
            return temp;
        } catch (Exception e) {
            throw new TrustException("Error in creating the ephemeral key", e);
        }
    }
View Full Code Here

                                          String algo,
                                          int keySize) throws TrustException {
        try {
            SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
            byte[] temp = new byte[keySize / 8];
            random.nextBytes(temp);
            return temp;
        } catch (Exception e) {
            throw new TrustException("Error in creating the ephemeral key", e);
        }
    }
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.