blob: 59d73160d520ff6063089c714cb50e04b46a4425 (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
package org.spongycastle.bcpg;
import java.io.*;
/**
* generic signature object
*/
public class OnePassSignaturePacket
extends ContainedPacket
{
private int version;
private int sigType;
private int hashAlgorithm;
private int keyAlgorithm;
private long keyID;
private int nested;
OnePassSignaturePacket(
BCPGInputStream in)
throws IOException
{
version = in.read();
sigType = in.read();
hashAlgorithm = in.read();
keyAlgorithm = in.read();
keyID |= (long)in.read() << 56;
keyID |= (long)in.read() << 48;
keyID |= (long)in.read() << 40;
keyID |= (long)in.read() << 32;
keyID |= (long)in.read() << 24;
keyID |= (long)in.read() << 16;
keyID |= (long)in.read() << 8;
keyID |= in.read();
nested = in.read();
}
public OnePassSignaturePacket(
int sigType,
int hashAlgorithm,
int keyAlgorithm,
long keyID,
boolean isNested)
{
this.version = 3;
this.sigType = sigType;
this.hashAlgorithm = hashAlgorithm;
this.keyAlgorithm = keyAlgorithm;
this.keyID = keyID;
this.nested = (isNested) ? 0 : 1;
}
/**
* Return the signature type.
* @return the signature type
*/
public int getSignatureType()
{
return sigType;
}
/**
* return the encryption algorithm tag
*/
public int getKeyAlgorithm()
{
return keyAlgorithm;
}
/**
* return the hashAlgorithm tag
*/
public int getHashAlgorithm()
{
return hashAlgorithm;
}
/**
* @return long
*/
public long getKeyID()
{
return keyID;
}
/**
*
*/
public void encode(
BCPGOutputStream out)
throws IOException
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
BCPGOutputStream pOut = new BCPGOutputStream(bOut);
pOut.write(version);
pOut.write(sigType);
pOut.write(hashAlgorithm);
pOut.write(keyAlgorithm);
pOut.write((byte)(keyID >> 56));
pOut.write((byte)(keyID >> 48));
pOut.write((byte)(keyID >> 40));
pOut.write((byte)(keyID >> 32));
pOut.write((byte)(keyID >> 24));
pOut.write((byte)(keyID >> 16));
pOut.write((byte)(keyID >> 8));
pOut.write((byte)(keyID));
pOut.write(nested);
out.writePacket(ONE_PASS_SIGNATURE, bOut.toByteArray(), true);
}
}
|