Skip to content

Commit d8bf6e0

Browse files
committed
Expose version, fingerprint and salt in PGPOnePassSignature
1 parent d97ecd5 commit d8bf6e0

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

pg/src/main/java/org/bouncycastle/bcpg/OnePassSignaturePacket.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.bouncycastle.bcpg;
22

3+
import org.bouncycastle.util.Arrays;
34
import org.bouncycastle.util.io.Streams;
45

56
import java.io.ByteArrayOutputStream;
@@ -213,7 +214,7 @@ public long getKeyID()
213214
* @return 32 bytes issuer fingerprint
214215
*/
215216
public byte[] getFingerprint() {
216-
return fingerprint;
217+
return Arrays.clone(fingerprint);
217218
}
218219

219220
/**
@@ -222,7 +223,7 @@ public byte[] getFingerprint() {
222223
* @return salt
223224
*/
224225
public byte[] getSalt() {
225-
return salt;
226+
return Arrays.clone(salt);
226227
}
227228

228229
/**

pg/src/main/java/org/bouncycastle/openpgp/PGPOnePassSignature.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,44 @@ public boolean verify(
8888
return verifier.verify(pgpSig.getSignature());
8989
}
9090

91+
/**
92+
* Return the packet version.
93+
*
94+
* @return packet version
95+
*/
96+
public int getVersion() {
97+
return sigPack.getVersion();
98+
}
99+
100+
/**
101+
* Return the key-ID of the issuer signing key.
102+
* For {@link OnePassSignaturePacket#VERSION_6} packets, the key-ID is derived from the fingerprint.
103+
*
104+
* @return key-ID
105+
*/
91106
public long getKeyID()
92107
{
93108
return sigPack.getKeyID();
94109
}
95110

111+
/**
112+
* Return the issuer key fingerprint.
113+
* Only for {@link OnePassSignaturePacket#VERSION_6} packets.
114+
* @return fingerprint
115+
*/
116+
public byte[] getFingerprint() {
117+
return sigPack.getFingerprint();
118+
}
119+
120+
/**
121+
* Return the salt used in the corresponding signature.
122+
* Only for {@link OnePassSignaturePacket#VERSION_6} packets.
123+
* @return salt
124+
*/
125+
public byte[] getSalt() {
126+
return sigPack.getSalt();
127+
}
128+
96129
public int getSignatureType()
97130
{
98131
return sigPack.getSignatureType();

0 commit comments

Comments
 (0)