Top Description Fields Constructors Methods
org.bouncycastle.bcpg

public Class OnePassSignaturePacket

extends ContainedPacket
Class Inheritance
Imports
org.bouncycastle.util.Arrays, org.bouncycastle.util.io.Streams, java.io.ByteArrayOutputStream, .IOException

One-Pass-Signature packet. OPS packets are used to enable verification of signed messages in one-pass by providing necessary metadata about the signed data up front, so the consumer can start processing the signed data without needing to process the signature packet at the end of the data stream first. There are two versions of this packet currently defined. Version 3 OPS packets are used with SignaturePackets of version 3 and 4. Version 6 OPS packets are used with SignaturePackets of version 6. It is not clear to me, which version of the OPS packet is intended to be used with version 5 signatures.
See Also
Definition of version 3 OPS packets in RFC4880, Definition of version 3 and 6 OPS packets in RFC9580, Definition of version 3 and 6 OPS packets in librepgp

Field Summary

Modifier and TypeField and Description
private final byte[]
private final int
private final int
private final int
private final long
private final byte[]
private final int
private final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
pack-priv
OnePassSignaturePacket(BCPGInputStream
OpenPGP packet input stream
in
)

Parse a OnePassSignaturePacket from an OpenPGP packet input stream.

pack-priv
OnePassSignaturePacket(BCPGInputStream in, boolean newPacketFormat)

public
OnePassSignaturePacket(int
signature type
sigType
,
int
hash algorithm tag
hashAlgorithm
,
int
public key algorithm tag
keyAlgorithm
,
long
id of the signing key
keyID
,
boolean
if false, there is another OPS packet after this one, which applies to the same data. it true, the corresponding signature is calculated also over succeeding additional OPS packets.
isNested
)

Create a version 3 OnePassSignaturePacket.

public
OnePassSignaturePacket(int
signature type
sigType
,
int
hash algorithm tag
hashAlgorithm
,
int
public key algorithm tag
keyAlgorithm
,
byte[]
random salt. The length of this array depends on the hash algorithm in use.
salt
,
byte[]
32 octet fingerprint of the (v6) signing key
fingerprint
,
boolean
if false, there is another OPS packet after this one, which applies to the same data. it true, the corresponding signature is calculated also over succeeding additional OPS packets.
isNested
)

Create a version 6 OnePassSignaturePacket.

Method Summary

Modifier and TypeMethod and Description
public void
encode(BCPGOutputStream
OpenPGP packet output stream
out
)

Implements abstract org.bouncycastle.bcpg.ContainedPacket.encode.

Encode the contents of this packet into the given packet output stream.

public byte[]

Returns:

32 bytes issuer fingerprint
getFingerprint
()

Return the version 6 fingerprint of the issuer.

public int

Returns:

hash algorithm tag
getHashAlgorithm
()

Return the algorithm ID of the hash algorithm.

public int

Returns:

public key algorithm tag
getKeyAlgorithm
()

Return the ID of the public key encryption algorithm.

public long

Returns:

key id
getKeyID
()

Return the key-id of the signing key.

public byte[]

Returns:

salt
getSalt
()

Return the salt used in the signature.

public int

Returns:

the signature type
getSignatureType
()

Return the signature type.

public int

Returns:

version
getVersion
()

Return the packet version.

public boolean

Returns:

true if encapsulating, false otherwise
isContaining
()

Return true, if the signature contains any signatures that follow.

Inherited from org.bouncycastle.bcpg.ContainedPacket:
getEncodedgetEncoded

Field Detail

fingerprintback to summary
private final byte[] fingerprint
hashAlgorithmback to summary
private final int hashAlgorithm
isContainingback to summary
private final int isContaining
keyAlgorithmback to summary
private final int keyAlgorithm
keyIDback to summary
private final long keyID
saltback to summary
private final byte[] salt
sigTypeback to summary
private final int sigType
versionback to summary
private final int version
VERSION_3back to summary
public static final int VERSION_3
VERSION_6back to summary
public static final int VERSION_6

Constructor Detail

OnePassSignaturePacketback to summary
pack-priv OnePassSignaturePacket(BCPGInputStream in) throws IOException

Parse a OnePassSignaturePacket from an OpenPGP packet input stream.

Parameters
in:BCPGInputStream

OpenPGP packet input stream

Exceptions
IOException:
when the end of stream is prematurely reached, or when the packet is malformed
OnePassSignaturePacketback to summary
pack-priv OnePassSignaturePacket(BCPGInputStream in, boolean newPacketFormat) throws IOException
OnePassSignaturePacketback to summary
public OnePassSignaturePacket(int sigType, int hashAlgorithm, int keyAlgorithm, long keyID, boolean isNested)

Create a version 3 OnePassSignaturePacket. Version 3 OPS packets are used with version 3 and version 4 SignaturePackets. To create an OPS packet for use with a version 6 SignaturePacket, see OnePassSignaturePacket#OnePassSignaturePacket(int, int, int, byte[], byte[], boolean).

Parameters
sigType:int

signature type

hashAlgorithm:int

hash algorithm tag

keyAlgorithm:int

public key algorithm tag

keyID:long

id of the signing key

isNested:boolean

if false, there is another OPS packet after this one, which applies to the same data. it true, the corresponding signature is calculated also over succeeding additional OPS packets.

OnePassSignaturePacketback to summary
public OnePassSignaturePacket(int sigType, int hashAlgorithm, int keyAlgorithm, byte[] salt, byte[] fingerprint, boolean isNested)

Create a version 6 OnePassSignaturePacket.

Parameters
sigType:int

signature type

hashAlgorithm:int

hash algorithm tag

keyAlgorithm:int

public key algorithm tag

salt:byte[]

random salt. The length of this array depends on the hash algorithm in use.

fingerprint:byte[]

32 octet fingerprint of the (v6) signing key

isNested:boolean

if false, there is another OPS packet after this one, which applies to the same data. it true, the corresponding signature is calculated also over succeeding additional OPS packets.

Method Detail

encodeback to summary
public void encode(BCPGOutputStream out) throws IOException

Implements abstract org.bouncycastle.bcpg.ContainedPacket.encode.

Encode the contents of this packet into the given packet output stream.

Parameters
out:BCPGOutputStream

OpenPGP packet output stream

getFingerprintback to summary
public byte[] getFingerprint()

Return the version 6 fingerprint of the issuer. Only for version 6 packets.

Returns:byte[]

32 bytes issuer fingerprint

getHashAlgorithmback to summary
public int getHashAlgorithm()

Return the algorithm ID of the hash algorithm.

Returns:int

hash algorithm tag

getKeyAlgorithmback to summary
public int getKeyAlgorithm()

Return the ID of the public key encryption algorithm.

Returns:int

public key algorithm tag

getKeyIDback to summary
public long getKeyID()

Return the key-id of the signing key.

Returns:long

key id

getSaltback to summary
public byte[] getSalt()

Return the salt used in the signature. Only for version 6 packets.

Returns:byte[]

salt

getSignatureTypeback to summary
public int getSignatureType()

Return the signature type.

Returns:int

the signature type

getVersionback to summary
public int getVersion()

Return the packet version.

Returns:int

version

isContainingback to summary
public boolean isContaining()

Return true, if the signature contains any signatures that follow. A bracketing OPS is followed by additional OPS packets and is calculated over all the data between itself and its corresponding signature (it is an attestation for encapsulated signatures).

Returns:boolean

true if encapsulating, false otherwise