01: package org.bouncycastle.bcpg.sig;
02:
03: import org.bouncycastle.bcpg.SignatureSubpacket;
04: import org.bouncycastle.bcpg.SignatureSubpacketTags;
05:
06: /**
07: * packet giving signature creation time.
08: */
09: public class IssuerKeyID extends SignatureSubpacket {
10: protected static byte[] keyIDToBytes(long keyId) {
11: byte[] data = new byte[8];
12:
13: data[0] = (byte) (keyId >> 56);
14: data[1] = (byte) (keyId >> 48);
15: data[2] = (byte) (keyId >> 40);
16: data[3] = (byte) (keyId >> 32);
17: data[4] = (byte) (keyId >> 24);
18: data[5] = (byte) (keyId >> 16);
19: data[6] = (byte) (keyId >> 8);
20: data[7] = (byte) keyId;
21:
22: return data;
23: }
24:
25: public IssuerKeyID(boolean critical, byte[] data) {
26: super (SignatureSubpacketTags.ISSUER_KEY_ID, critical, data);
27: }
28:
29: public IssuerKeyID(boolean critical, long keyID) {
30: super (SignatureSubpacketTags.ISSUER_KEY_ID, critical,
31: keyIDToBytes(keyID));
32: }
33:
34: public long getKeyID() {
35: long keyID = ((long) (data[0] & 0xff) << 56)
36: | ((long) (data[1] & 0xff) << 48)
37: | ((long) (data[2] & 0xff) << 40)
38: | ((long) (data[3] & 0xff) << 32)
39: | ((long) (data[4] & 0xff) << 24)
40: | ((data[5] & 0xff) << 16) | ((data[6] & 0xff) << 8)
41: | (data[7] & 0xff);
42:
43: return keyID;
44: }
45: }
|