Package java.security

Examples of java.security.SecureRandom.nextBytes()


                SecureRandom rnd = new SecureRandom();
                Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");

                // make a random 256-bit file encryption key
                encryptionKey = new byte[32];
                rnd.nextBytes(encryptionKey);
               
                // Algorithm 8a: Compute U
                byte[] userPasswordBytes = truncate127(userPassword.getBytes("UTF-8"));
                byte[] userValidationSalt = new byte[8];
                byte[] userKeySalt = new byte[8];
View Full Code Here


               
                // Algorithm 8a: Compute U
                byte[] userPasswordBytes = truncate127(userPassword.getBytes("UTF-8"));
                byte[] userValidationSalt = new byte[8];
                byte[] userKeySalt = new byte[8];
                rnd.nextBytes(userValidationSalt);
                rnd.nextBytes(userKeySalt);
                byte[] hashU = computeHash2B(concat(userPasswordBytes, userValidationSalt),
                        userPasswordBytes, null);
                byte[] u = concat(hashU, userValidationSalt, userKeySalt);
               
View Full Code Here

                // Algorithm 8a: Compute U
                byte[] userPasswordBytes = truncate127(userPassword.getBytes("UTF-8"));
                byte[] userValidationSalt = new byte[8];
                byte[] userKeySalt = new byte[8];
                rnd.nextBytes(userValidationSalt);
                rnd.nextBytes(userKeySalt);
                byte[] hashU = computeHash2B(concat(userPasswordBytes, userValidationSalt),
                        userPasswordBytes, null);
                byte[] u = concat(hashU, userValidationSalt, userKeySalt);
               
                // Algorithm 8b: Compute UE
View Full Code Here

               
                // Algorithm 9a: Compute O
                byte[] ownerPasswordBytes = truncate127(ownerPassword.getBytes("UTF-8"));
                byte[] ownerValidationSalt = new byte[8];
                byte[] ownerKeySalt = new byte[8];
                rnd.nextBytes(ownerValidationSalt);
                rnd.nextBytes(ownerKeySalt);
                byte[] hashO = computeHash2B(concat(ownerPasswordBytes, ownerValidationSalt, u),
                        ownerPasswordBytes, u);
                byte[] o = concat(hashO, ownerValidationSalt, ownerKeySalt);
               
View Full Code Here

                // Algorithm 9a: Compute O
                byte[] ownerPasswordBytes = truncate127(ownerPassword.getBytes("UTF-8"));
                byte[] ownerValidationSalt = new byte[8];
                byte[] ownerKeySalt = new byte[8];
                rnd.nextBytes(ownerValidationSalt);
                rnd.nextBytes(ownerKeySalt);
                byte[] hashO = computeHash2B(concat(ownerPasswordBytes, ownerValidationSalt, u),
                        ownerPasswordBytes, u);
                byte[] o = concat(hashO, ownerValidationSalt, ownerKeySalt);
               
                // Algorithm 9b: Compute OE
View Full Code Here

            {

                // Hm, we have no IV but we want to wrap ?!?
                // well, then we have to create our own IV.
                this.iv = new byte[8];
                sr.nextBytes(iv);

                this.paramPlusIV = new ParametersWithIV(this.param, this.iv);
            }
        }
        else if (param instanceof ParametersWithIV)
View Full Code Here

        this.hashLength = digest.getDigestLength();

        // Create a new secret only valid within this NonceManager instance.
        Random rand = new SecureRandom();
        byte[] secretBytes = new byte[32];
        rand.nextBytes(secretBytes);
        secret = FlexBase64.encodeString(digest.digest(secretBytes), false);
    }

    private MessageDigest getDigest(final String hashAlg) {
        try {
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

            }
        } 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

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.