01: package org.bouncycastle.bcpg;
02:
03: import java.io.*;
04:
05: /**
06: * basic packet for a modification detection code packet.
07: */
08: public class ModDetectionCodePacket extends ContainedPacket {
09: private byte[] digest;
10:
11: ModDetectionCodePacket(BCPGInputStream in) throws IOException {
12: this .digest = new byte[20];
13: in.readFully(this .digest);
14: }
15:
16: public ModDetectionCodePacket(byte[] digest) throws IOException {
17: this .digest = new byte[digest.length];
18:
19: System.arraycopy(digest, 0, this .digest, 0, this .digest.length);
20: }
21:
22: public byte[] getDigest() {
23: byte[] tmp = new byte[digest.length];
24:
25: System.arraycopy(digest, 0, tmp, 0, tmp.length);
26:
27: return tmp;
28: }
29:
30: public void encode(BCPGOutputStream out) throws IOException {
31: out.writePacket(MOD_DETECTION_CODE, digest, false);
32: }
33: }
|