blob: 9219d9df4583a8f0a8a1433213122affca2331b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
package org.bouncycastle.crypto.digests;
import java.io.ByteArrayOutputStream;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.util.Arrays;
public class NullDigest
implements Digest
{
private OpenByteArrayOutputStream bOut = new OpenByteArrayOutputStream();
public String getAlgorithmName()
{
return "NULL";
}
public int getDigestSize()
{
return bOut.size();
}
public void update(byte in)
{
bOut.write(in);
}
public void update(byte[] in, int inOff, int len)
{
bOut.write(in, inOff, len);
}
public int doFinal(byte[] out, int outOff)
{
int size = bOut.size();
bOut.copy(out, outOff);
reset();
return size;
}
public void reset()
{
bOut.reset();
}
private static class OpenByteArrayOutputStream
extends ByteArrayOutputStream
{
public void reset()
{
super.reset();
Arrays.clear(buf);
}
void copy(byte[] out, int outOff)
{
System.arraycopy(buf, 0, out, outOff, this.size());
}
}
}
|