protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver, int keySize) { HashAlgorithm hashAlgo = ver.getHashAlgorithm(); byte pwHash[] = hashPassword(password, hashAlgo, ver.getSalt(), ver.getSpinCount()); byte[] blockKey = new byte[4]; LittleEndian.putInt(blockKey, 0, 0); byte[] finalHash = CryptoFunctions.generateKey(pwHash, hashAlgo, blockKey, hashAlgo.hashSize); byte x1[] = fillAndXor(finalHash, (byte) 0x36); byte x2[] = fillAndXor(finalHash, (byte) 0x5c); byte[] x3 = new byte[x1.length + x2.length]; System.arraycopy(x1, 0, x3, 0, x1.length); System.arraycopy(x2, 0, x3, x1.length, x2.length); byte[] key = Arrays.copyOf(x3, keySize); return new SecretKeySpec(key, ver.getCipherAlgorithm().jceId); }
protected static SecretKey generateSecretKey(String password, EncryptionVerifier ver, int keySize) { HashAlgorithm hashAlgo = ver.getHashAlgorithm(); byte pwHash[] = hashPassword(password, hashAlgo, ver.getSalt(), ver.getSpinCount()); byte[] blockKey = new byte[4]; LittleEndian.putInt(blockKey, 0, 0); byte[] finalHash = CryptoFunctions.generateKey(pwHash, hashAlgo, blockKey, hashAlgo.hashSize); byte x1[] = fillAndXor(finalHash, (byte) 0x36); byte x2[] = fillAndXor(finalHash, (byte) 0x5c); byte[] x3 = new byte[x1.length + x2.length]; System.arraycopy(x1, 0, x3, 0, x1.length); System.arraycopy(x2, 0, x3, x1.length, x2.length); byte[] key = Arrays.copyOf(x3, keySize); return new SecretKeySpec(key, ver.getCipherAlgorithm().jceId); }