01: package org.bouncycastle.crypto.io;
02:
03: import java.io.FilterOutputStream;
04: import java.io.IOException;
05: import java.io.OutputStream;
06:
07: import org.bouncycastle.crypto.Mac;
08:
09: public class MacOutputStream extends FilterOutputStream {
10: protected Mac mac;
11:
12: public MacOutputStream(OutputStream stream, Mac mac) {
13: super (stream);
14: this .mac = mac;
15: }
16:
17: public void write(int b) throws IOException {
18: mac.update((byte) b);
19: out.write(b);
20: }
21:
22: public void write(byte[] b, int off, int len) throws IOException {
23: mac.update(b, off, len);
24: out.write(b, off, len);
25: }
26:
27: public Mac getMac() {
28: return mac;
29: }
30: }
|