public final class CipherUtil extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
decrypt(org.bouncycastle.crypto.modes.AEADBlockCipher cipher,
SecretKey key,
byte[] data)
Decrypts data using an AEAD cipher.
|
static void |
decrypt(org.bouncycastle.crypto.modes.AEADBlockCipher cipher,
SecretKey key,
InputStream input,
OutputStream output)
Decrypts data using an AEAD cipher.
|
static byte[] |
decrypt(org.bouncycastle.crypto.BlockCipher cipher,
SecretKey key,
byte[] data)
Decrypts data using the given block cipher with PKCS5 padding.
|
static void |
decrypt(org.bouncycastle.crypto.BlockCipher cipher,
SecretKey key,
InputStream input,
OutputStream output)
Decrypts data using the given block cipher with PKCS5 padding.
|
static byte[] |
encrypt(org.bouncycastle.crypto.modes.AEADBlockCipher cipher,
SecretKey key,
Nonce nonce,
byte[] data)
Encrypts data using an AEAD cipher.
|
static void |
encrypt(org.bouncycastle.crypto.modes.AEADBlockCipher cipher,
SecretKey key,
Nonce nonce,
InputStream input,
OutputStream output)
Encrypts data using an AEAD cipher.
|
static byte[] |
encrypt(org.bouncycastle.crypto.BlockCipher cipher,
SecretKey key,
Nonce nonce,
byte[] data)
Encrypts data using the given block cipher with PKCS5 padding.
|
static void |
encrypt(org.bouncycastle.crypto.BlockCipher cipher,
SecretKey key,
Nonce nonce,
InputStream input,
OutputStream output)
Encrypts data using the given block cipher with PKCS5 padding.
|
public static byte[] encrypt(org.bouncycastle.crypto.modes.AEADBlockCipher cipher, SecretKey key, Nonce nonce, byte[] data) throws CryptoException
CiphertextHeader
is prepended to the resulting ciphertext and used as
AAD (Additional Authenticated Data) passed to the AEAD cipher.cipher
- AEAD cipher.key
- Encryption key.nonce
- Nonce generator.data
- Plaintext data to be encrypted.CiphertextHeader
and encrypted data that completely fills the returned
byte array.CryptoException
- on encryption errors.public static void encrypt(org.bouncycastle.crypto.modes.AEADBlockCipher cipher, SecretKey key, Nonce nonce, InputStream input, OutputStream output) throws CryptoException, StreamException
CiphertextHeader
is prepended to the resulting ciphertext and used as
AAD (Additional Authenticated Data) passed to the AEAD cipher.cipher
- AEAD cipher.key
- Encryption key.nonce
- Nonce generator.input
- Input stream containing plaintext data.output
- Output stream that receives a CiphertextHeader
followed by ciphertext data produced by the
AEAD cipher in encryption mode.CryptoException
- on encryption errors.StreamException
- on IO errors.public static byte[] decrypt(org.bouncycastle.crypto.modes.AEADBlockCipher cipher, SecretKey key, byte[] data) throws CryptoException, EncodingException
cipher
- AEAD cipher.key
- Encryption key.data
- Ciphertext data containing a prepended CiphertextHeader
. The header is treated as AAD input
to the cipher that is verified during decryption.CryptoException
- on encryption errors.EncodingException
- on decoding cyphertext header.public static void decrypt(org.bouncycastle.crypto.modes.AEADBlockCipher cipher, SecretKey key, InputStream input, OutputStream output) throws CryptoException, EncodingException, StreamException
cipher
- AEAD cipher.key
- Encryption key.input
- Input stream containing a CiphertextHeader
followed by ciphertext data. The header is
treated as AAD input to the cipher that is verified during decryption.output
- Output stream that receives plaintext produced by block cipher in decryption mode.CryptoException
- on encryption errors.EncodingException
- on decoding cyphertext header.StreamException
- on IO errors.public static byte[] encrypt(org.bouncycastle.crypto.BlockCipher cipher, SecretKey key, Nonce nonce, byte[] data) throws CryptoException
CiphertextHeader
is prepended to the
resulting ciphertext.cipher
- Block cipher.key
- Encryption key.nonce
- IV generator. Callers must take care to ensure that the length of generated IVs is equal to the
cipher block size.data
- Plaintext data to be encrypted.CiphertextHeader
and encrypted data that completely fills the returned
byte array.CryptoException
- on encryption errors.public static void encrypt(org.bouncycastle.crypto.BlockCipher cipher, SecretKey key, Nonce nonce, InputStream input, OutputStream output) throws CryptoException, StreamException
CiphertextHeader
is prepended to the
resulting ciphertext.cipher
- Block cipher.key
- Encryption key.nonce
- IV generator. Callers must take care to ensure that the length of generated IVs is equal to the
cipher block size.input
- Input stream containing plaintext data.output
- Output stream that receives ciphertext produced by block cipher in encryption mode.CryptoException
- on encryption errors.StreamException
- on IO errors.public static byte[] decrypt(org.bouncycastle.crypto.BlockCipher cipher, SecretKey key, byte[] data) throws CryptoException, EncodingException
cipher
- Block cipher.key
- Encryption key.data
- Ciphertext data containing a prepended CiphertextHeader
.CryptoException
- on encryption errors.EncodingException
- on decoding cyphertext header.public static void decrypt(org.bouncycastle.crypto.BlockCipher cipher, SecretKey key, InputStream input, OutputStream output) throws CryptoException, EncodingException, StreamException
cipher
- Block cipher.key
- Encryption key.input
- Input stream containing a CiphertextHeader
followed by ciphertext data.output
- Output stream that receives plaintext produced by block cipher in decryption mode.CryptoException
- on encryption errors.EncodingException
- on decoding cyphertext header.StreamException
- on IO errors.Copyright © 2003-2015 Virginia Tech. All Rights Reserved.