private Cipher getCipher(SecretKey key) { EncryptionHeader em = getEncryptionInfo().getHeader(); ChainingMode cm = em.getChainingMode(); assert(cm == ChainingMode.ecb); return CryptoFunctions.getCipher(key, em.getCipherAlgorithm(), cm, null, Cipher.DECRYPT_MODE); }
@Override public EncryptionInfo clone() throws CloneNotSupportedException { EncryptionInfo other = (EncryptionInfo)super.clone(); other.header = header.clone(); other.verifier = verifier.clone(); other.decryptor = decryptor.clone(); other.decryptor.setEncryptionInfo(other); other.encryptor = encryptor.clone(); other.encryptor.setEncryptionInfo(other); return other; } }
@Override public StandardEncryptionHeader clone() throws CloneNotSupportedException { return (StandardEncryptionHeader)super.clone(); } }
private Cipher getCipher(SecretKey key, String padding) { EncryptionVerifier ver = getEncryptionInfo().getVerifier(); return CryptoFunctions.getCipher(key, ver.getCipherAlgorithm(), ver.getChainingMode(), null, Cipher.ENCRYPT_MODE, padding); }
public FilePassRecord(EncryptionMode encryptionMode) { encryptionType = (encryptionMode == EncryptionMode.xor) ? ENCRYPTION_XOR : ENCRYPTION_OTHER; encryptionInfo = new EncryptionInfo(encryptionMode); }
protected int getKeySizeInBytes() { return encryptionInfo.getHeader().getKeySize()/8; }
@SuppressWarnings("unused") protected int getBlockSizeInBytes() { return encryptionInfo.getHeader().getBlockSize(); }
@Override public StandardDecryptor clone() throws CloneNotSupportedException { return (StandardDecryptor)super.clone(); } }
@Override public CryptoAPIEncryptor clone() throws CloneNotSupportedException { return (CryptoAPIEncryptor)super.clone(); }
@Override protected final void setEncryptedKey(byte[] encryptedKey) { super.setEncryptedKey(encryptedKey); } }
@Override protected void setEncryptedVerifier(byte encryptedVerifier[]) { super.setEncryptedVerifier(encryptedVerifier); }
/** * Returns a new byte array with a truncated to the given size. * If the hash has less then size bytes, it will be filled with 0x36-bytes * * @param hash the to be truncated/filled hash byte array * @param size the size of the returned byte array * @return the padded hash */ private static byte[] getBlock36(byte[] hash, int size) { return getBlockX(hash, size, (byte)0x36); }
/** * @return the absolute position in the stream */ public long getPosition() { return ccis.getPos(); }
@Override public void write(byte[] b) throws IOException { write(b, 0, b.length); }
@Override public int read() throws IOException { byte[] b = { 0 }; // FIXME: compare against -1 or 1? (bug 59893) return (read(b) == 1) ? -1 : b[0]; }
@Override public XOREncryptionHeader clone() throws CloneNotSupportedException { return (XOREncryptionHeader)super.clone(); } }
@Override public AgileDecryptor clone() throws CloneNotSupportedException { return (AgileDecryptor)super.clone(); } }
@Override public BinaryRC4Encryptor clone() throws CloneNotSupportedException { return (BinaryRC4Encryptor)super.clone(); }
/** * Returns a new byte array with a truncated to the given size. * If the hash has less then size bytes, it will be filled with 0-bytes * * @param hash the to be truncated/filled hash byte array * @param size the size of the returned byte array * @return the padded hash */ public static byte[] getBlock0(byte[] hash, int size) { return getBlockX(hash, size, (byte)0); }
@Override public BinaryRC4EncryptionHeader clone() throws CloneNotSupportedException { return (BinaryRC4EncryptionHeader)super.clone(); }