01: package org.bouncycastle.bcpg;
02:
03: import java.io.*;
04:
05: /**
06: * basic packet for an experimental packet.
07: */
08: public class ExperimentalPacket extends ContainedPacket implements
09: PublicKeyAlgorithmTags {
10: private int tag;
11: private byte[] contents;
12:
13: /**
14: *
15: * @param in
16: * @throws IOException
17: */
18: ExperimentalPacket(int tag, BCPGInputStream in) throws IOException {
19: this .tag = tag;
20:
21: if (in.available() != 0) {
22: ByteArrayOutputStream bOut = new ByteArrayOutputStream(in
23: .available());
24:
25: int b;
26: while ((b = in.read()) >= 0) {
27: bOut.write(b);
28: }
29:
30: contents = bOut.toByteArray();
31: } else {
32: contents = new byte[0];
33: }
34: }
35:
36: public int getTag() {
37: return tag;
38: }
39:
40: public byte[] getContents() {
41: byte[] tmp = new byte[contents.length];
42:
43: System.arraycopy(contents, 0, tmp, 0, tmp.length);
44:
45: return tmp;
46: }
47:
48: public void encode(BCPGOutputStream out) throws IOException {
49: out.writePacket(tag, contents, true);
50: }
51: }
|