1package org.bouncycastle.crypto.io;
2
3import java.io.FilterOutputStream;
4import java.io.IOException;
5import java.io.OutputStream;
6
7import org.bouncycastle.crypto.Mac;
8
9public class MacOutputStream
10    extends FilterOutputStream
11{
12    protected Mac mac;
13
14    public MacOutputStream(
15        OutputStream stream,
16        Mac          mac)
17    {
18        super(stream);
19        this.mac = mac;
20    }
21
22    public void write(int b)
23        throws IOException
24    {
25        mac.update((byte)b);
26        out.write(b);
27    }
28
29    public void write(
30        byte[] b,
31        int off,
32        int len)
33        throws IOException
34    {
35        mac.update(b, off, len);
36        out.write(b, off, len);
37    }
38
39    public Mac getMac()
40    {
41        return mac;
42    }
43}
44
45