diff --git a/briar-core/src/org/briarproject/crypto/AuthenticatedCipher.java b/briar-core/src/org/briarproject/crypto/AuthenticatedCipher.java index 3225b65e49d04b9dfa7179748719fb37ed013f4c..5ee21e3e4ca1047f67f40a2b427d1e37ae7005ce 100644 --- a/briar-core/src/org/briarproject/crypto/AuthenticatedCipher.java +++ b/briar-core/src/org/briarproject/crypto/AuthenticatedCipher.java @@ -1,19 +1,41 @@ package org.briarproject.crypto; -import java.security.GeneralSecurityException; - import org.briarproject.api.crypto.SecretKey; +import java.security.GeneralSecurityException; + interface AuthenticatedCipher { /** * Initializes this cipher for encryption or decryption with a key and an * initialisation vector (IV). + * + * @param encrypt whether we are encrypting or decrypting. + * @param key the key material to use. + * @param iv the IV. + * @throws GeneralSecurityException on invalid input. */ void init(boolean encrypt, SecretKey key, byte[] iv) throws GeneralSecurityException; - /** Encrypts or decrypts data in a single-part operation. */ + /** + * Encrypts or decrypts data in a single-part operation. + * + * @param input the input byte array. If encrypting, the plaintext to be + * encrypted. If decrypting, the ciphertext to be decrypted + * including the MAC. + * @param inputOff the offset into the input array where the data to be + * processed starts. + * @param len the number of bytes to be processed. If decrypting, includes + * the MAC length. + * @param output the output buffer the processed bytes go into. If + * encrypting, the ciphertext including the MAC. If + * decrypting, the plaintext. + * @param outputOff the offset into the output byte array the processed + * data starts at. + * @return the number of bytes processed. + * @throws GeneralSecurityException on invalid input. + */ int process(byte[] input, int inputOff, int len, byte[] output, int outputOff) throws GeneralSecurityException;