protected int getKeySizeInBytes() { return encryptionInfo.getHeader().getKeySize()/8; }
protected int getKeySizeInBytes() { return getEncryptionInfo().getHeader().getKeySize()/8; }
protected int getKeySizeInBytes() { return getEncryptionInfo().getHeader().getKeySize() / 8; }
protected static Cipher initCipherForBlock(Cipher cipher, int block, EncryptionInfo encryptionInfo, SecretKey skey, int encryptMode) throws GeneralSecurityException { EncryptionVerifier ver = encryptionInfo.getVerifier(); HashAlgorithm hashAlgo = ver.getHashAlgorithm(); byte blockKey[] = new byte[4]; LittleEndian.putUInt(blockKey, 0, block); MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo); hashAlg.update(skey.getEncoded()); byte encKey[] = hashAlg.digest(blockKey); EncryptionHeader header = encryptionInfo.getHeader(); int keyBits = header.getKeySize(); encKey = CryptoFunctions.getBlock0(encKey, keyBits / 8); if (keyBits == 40) { encKey = CryptoFunctions.getBlock0(encKey, 16); } SecretKey key = new SecretKeySpec(encKey, skey.getAlgorithm()); if (cipher == null) { cipher = CryptoFunctions.getCipher(key, header.getCipherAlgorithm(), null, null, encryptMode); } else { cipher.init(encryptMode, key); } return cipher; }
/** * Return the length of the encryption key, in bits */ public int getKeyLength() { return ei.getHeader().getKeySize(); }
protected int getKeySizeInBytes() { return encryptionInfo.getHeader().getKeySize()/8; }
protected int getKeySizeInBytes() { return getEncryptionInfo().getHeader().getKeySize()/8; }
private byte[] generateKey(int block) throws NoSuchAlgorithmException { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); sha1.update(passwordHash); byte[] blockValue = new byte[4]; LittleEndian.putInt(blockValue, 0, block); byte[] finalHash = sha1.digest(blockValue); int requiredKeyLength = info.getHeader().getKeySize()/8; byte[] buff = new byte[64]; Arrays.fill(buff, (byte) 0x36); for (int i=0; i<finalHash.length; i++) { buff[i] = (byte) (buff[i] ^ finalHash[i]); } sha1.reset(); byte[] x1 = sha1.digest(buff); Arrays.fill(buff, (byte) 0x5c); for (int i=0; i<finalHash.length; i++) { buff[i] = (byte) (buff[i] ^ finalHash[i]); } sha1.reset(); byte[] x2 = sha1.digest(buff); 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); return truncateOrPad(x3, requiredKeyLength); }
private byte[] generateKey(int block) throws NoSuchAlgorithmException { MessageDigest sha1 = MessageDigest.getInstance("SHA-1"); sha1.update(passwordHash); byte[] blockValue = new byte[4]; LittleEndian.putInt(blockValue, 0, block); byte[] finalHash = sha1.digest(blockValue); int requiredKeyLength = info.getHeader().getKeySize()/8; byte[] buff = new byte[64]; Arrays.fill(buff, (byte) 0x36); for (int i=0; i<finalHash.length; i++) { buff[i] = (byte) (buff[i] ^ finalHash[i]); } sha1.reset(); byte[] x1 = sha1.digest(buff); Arrays.fill(buff, (byte) 0x5c); for (int i=0; i<finalHash.length; i++) { buff[i] = (byte) (buff[i] ^ finalHash[i]); } sha1.reset(); byte[] x2 = sha1.digest(buff); 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); return truncateOrPad(x3, requiredKeyLength); }
protected int getKeySizeInBytes() { return getEncryptionInfo().getHeader().getKeySize() / 8; }
protected static Cipher initCipherForBlock(Cipher cipher, int block, EncryptionInfo encryptionInfo, SecretKey skey, int encryptMode) throws GeneralSecurityException { EncryptionVerifier ver = encryptionInfo.getVerifier(); HashAlgorithm hashAlgo = ver.getHashAlgorithm(); byte blockKey[] = new byte[4]; LittleEndian.putUInt(blockKey, 0, block); MessageDigest hashAlg = CryptoFunctions.getMessageDigest(hashAlgo); hashAlg.update(skey.getEncoded()); byte encKey[] = hashAlg.digest(blockKey); EncryptionHeader header = encryptionInfo.getHeader(); int keyBits = header.getKeySize(); encKey = CryptoFunctions.getBlock0(encKey, keyBits / 8); if (keyBits == 40) { encKey = CryptoFunctions.getBlock0(encKey, 16); } SecretKey key = new SecretKeySpec(encKey, skey.getAlgorithm()); if (cipher == null) { cipher = CryptoFunctions.getCipher(key, header.getCipherAlgorithm(), null, null, encryptMode); } else { cipher.init(encryptMode, key); } return cipher; }
cipher = getCipher(algorithm, mode, skey, iv); byte[] inter = cipher.doFinal(verifier.getEncryptedKey()); byte[] keyspec = new byte[_info.getHeader().getKeySize() / 8]; System.arraycopy(inter, 0, keyspec, 0, keyspec.length); _secretKey = new SecretKeySpec(keyspec, "AES");
cipher = getCipher(algorithm, mode, skey, iv); byte[] inter = cipher.doFinal(verifier.getEncryptedKey()); byte[] keyspec = new byte[_info.getHeader().getKeySize() / 8]; System.arraycopy(inter, 0, keyspec, 0, keyspec.length); _secretKey = new SecretKeySpec(keyspec, "AES");