public class AEADOutputStream
extends java.io.FilterOutputStream
| Modifier and Type | Field and Description |
|---|---|
static int |
AES_OVERHEAD |
| Constructor and Description |
|---|
AEADOutputStream(java.io.OutputStream os,
byte[] key,
byte[] nonce,
org.bouncycastle.crypto.BlockCipher hashCipher,
org.bouncycastle.crypto.BlockCipher mainCipher)
Create an encrypting, authenticating OutputStream.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static AEADOutputStream |
createAES(java.io.OutputStream os,
byte[] key,
java.security.SecureRandom random) |
java.lang.String |
toString() |
void |
write(byte[] buf) |
void |
write(byte[] buf,
int offset,
int length) |
void |
write(int b) |
public static final int AES_OVERHEAD
public AEADOutputStream(java.io.OutputStream os,
byte[] key,
byte[] nonce,
org.bouncycastle.crypto.BlockCipher hashCipher,
org.bouncycastle.crypto.BlockCipher mainCipher)
throws java.io.IOException
os - The underlying OutputStream.key - The encryption key.nonce - The nonce. This serves the function of an IV. As a nonce, this MUST be unique.
We will write it to the stream so the other side can pick it up, like an IV. Should
generally be generated from a SecureRandom. The top bit must be 0, i.e. nonce[0] &= 0x7F.mainCipher - The BlockCipher for encrypting data. E.g. AES; not a block mode. This will
be used for encrypting a fairly large amount of data so could be any of the 3 BC AES impl's.hashCipher - The BlockCipher for the final hash. E.g. AES, not a block mode. This will
not be used very much so should be e.g. an AESLightEngine.java.io.IOExceptionpublic void write(int b)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void write(byte[] buf)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void write(byte[] buf,
int offset,
int length)
throws java.io.IOException
write in class java.io.FilterOutputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.FilterOutputStreamjava.io.IOExceptionpublic static AEADOutputStream createAES(java.io.OutputStream os, byte[] key, java.security.SecureRandom random) throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object