Package org.bouncycastle.jcajce.io
Class MacOutputStream
java.lang.Object
java.io.OutputStream
org.bouncycastle.jcajce.io.MacOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
An output stream which calculates a MAC based on the data that is written to it.
-
Constructor Summary
ConstructorDescriptionMacOutputStream
(Mac mac) Base constructor - specify the MAC algorithm to use. -
Method Summary
Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream, write
-
Constructor Details
-
MacOutputStream
Base constructor - specify the MAC algorithm to use.- Parameters:
mac
- the MAC implementation to use as the basis of the stream.
-
-
Method Details
-
write
Write a single byte to the stream.- Specified by:
write
in classOutputStream
- Parameters:
b
- the byte value to write.- Throws:
IOException
- in case of failure.
-
write
Write a block of data of length len starting at offset off in the byte array bytes to the stream.- Overrides:
write
in classOutputStream
- Parameters:
bytes
- byte array holding the data.off
- offset into bytes that the data starts at.len
- the length of the data block to write.- Throws:
IOException
- in case of failure.
-
getMac
public byte[] getMac()Execute doFinal() and return the calculated MAC.- Returns:
- the MAC calculated from the output written to the stream.
-