Package org.bouncycastle.bcpg
Class SignaturePacket
- java.lang.Object
-
- org.bouncycastle.bcpg.Packet
-
- org.bouncycastle.bcpg.ContainedPacket
-
- org.bouncycastle.bcpg.SignaturePacket
-
- All Implemented Interfaces:
PacketTags
,PublicKeyAlgorithmTags
,org.bouncycastle.util.Encodable
public class SignaturePacket extends ContainedPacket implements PublicKeyAlgorithmTags
generic signature packet
-
-
Field Summary
Fields Modifier and Type Field Description static int
VERSION_2
static int
VERSION_3
static int
VERSION_4
static int
VERSION_5
static int
VERSION_6
-
Fields inherited from interface org.bouncycastle.bcpg.PacketTags
AEAD_ENC_DATA, COMPRESSED_DATA, EXPERIMENTAL_1, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, LITERAL_DATA, MARKER, MOD_DETECTION_CODE, ONE_PASS_SIGNATURE, PADDING, PUBLIC_KEY, PUBLIC_KEY_ENC_SESSION, PUBLIC_SUBKEY, RESERVED, SECRET_KEY, SECRET_SUBKEY, SIGNATURE, SYM_ENC_INTEGRITY_PRO, SYMMETRIC_KEY_ENC, SYMMETRIC_KEY_ENC_SESSION, TRUST, USER_ATTRIBUTE, USER_ID
-
Fields inherited from interface org.bouncycastle.bcpg.PublicKeyAlgorithmTags
AEDH, AEDSA, DIFFIE_HELLMAN, DSA, EC, ECDH, ECDSA, Ed25519, Ed448, EDDSA, EDDSA_LEGACY, ELGAMAL_ENCRYPT, ELGAMAL_GENERAL, EXPERIMENTAL_1, EXPERIMENTAL_10, EXPERIMENTAL_11, EXPERIMENTAL_2, EXPERIMENTAL_3, EXPERIMENTAL_4, EXPERIMENTAL_5, EXPERIMENTAL_6, EXPERIMENTAL_7, EXPERIMENTAL_8, EXPERIMENTAL_9, RSA_ENCRYPT, RSA_GENERAL, RSA_SIGN, X25519, X448
-
-
Constructor Summary
Constructors Constructor Description SignaturePacket(int version, int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, long creationTime, byte[] fingerPrint, MPInteger[] signature)
Generate a version 2/3 signature packet.SignaturePacket(int version, int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, SignatureSubpacket[] hashedData, SignatureSubpacket[] unhashedData, byte[] fingerPrint, byte[] signatureEncoding, byte[] salt)
SignaturePacket(int version, int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, SignatureSubpacket[] hashedData, SignatureSubpacket[] unhashedData, byte[] fingerPrint, MPInteger[] signature)
SignaturePacket(int version, int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, SignatureSubpacket[] hashedData, SignatureSubpacket[] unhashedData, byte[] fingerPrint, MPInteger[] signature, byte[] salt)
SignaturePacket(int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, SignatureSubpacket[] hashedData, SignatureSubpacket[] unhashedData, byte[] fingerPrint, MPInteger[] signature)
Generate a version 4 signature packet.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
encode(BCPGOutputStream out)
static SignaturePacket
fromByteArray(byte[] data)
long
getCreationTime()
Return the creation time of the signature in milli-seconds.byte[]
getFingerPrint()
Return the signature's fingerprint.int
getHashAlgorithm()
return the hashAlgorithm tagSignatureSubpacket[]
getHashedSubPackets()
int
getKeyAlgorithm()
return the encryption algorithm taglong
getKeyID()
return the keyIDbyte[]
getSalt()
Return the signature's salt.MPInteger[]
getSignature()
return the signature as a set of integers - note this is normalised to be the ASN.1 encoding of what appears in the signature packet.byte[]
getSignatureBytes()
Return the byte encoding of the signature section.byte[]
getSignatureTrailer()
return the signature trailer that must be included with the data to reconstruct the signatureint
getSignatureType()
return the signature type.SignatureSubpacket[]
getUnhashedSubPackets()
int
getVersion()
get the version number-
Methods inherited from class org.bouncycastle.bcpg.ContainedPacket
getEncoded, getEncoded
-
Methods inherited from class org.bouncycastle.bcpg.Packet
getPacketTag, hasNewPacketFormat, isCritical
-
-
-
-
Field Detail
-
VERSION_2
public static final int VERSION_2
- See Also:
- Constant Field Values
-
VERSION_3
public static final int VERSION_3
- See Also:
- Constant Field Values
-
VERSION_4
public static final int VERSION_4
- See Also:
- Constant Field Values
-
VERSION_5
public static final int VERSION_5
- See Also:
- Constant Field Values
-
VERSION_6
public static final int VERSION_6
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SignaturePacket
public SignaturePacket(int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, SignatureSubpacket[] hashedData, SignatureSubpacket[] unhashedData, byte[] fingerPrint, MPInteger[] signature)
Generate a version 4 signature packet.- Parameters:
signatureType
-keyAlgorithm
-hashAlgorithm
-hashedData
-unhashedData
-fingerPrint
-signature
-
-
SignaturePacket
public SignaturePacket(int version, int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, long creationTime, byte[] fingerPrint, MPInteger[] signature)
Generate a version 2/3 signature packet.- Parameters:
signatureType
-keyAlgorithm
-hashAlgorithm
-fingerPrint
-signature
-
-
SignaturePacket
public SignaturePacket(int version, int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, SignatureSubpacket[] hashedData, SignatureSubpacket[] unhashedData, byte[] fingerPrint, MPInteger[] signature)
-
SignaturePacket
public SignaturePacket(int version, int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, SignatureSubpacket[] hashedData, SignatureSubpacket[] unhashedData, byte[] fingerPrint, byte[] signatureEncoding, byte[] salt)
-
SignaturePacket
public SignaturePacket(int version, int signatureType, long keyID, int keyAlgorithm, int hashAlgorithm, SignatureSubpacket[] hashedData, SignatureSubpacket[] unhashedData, byte[] fingerPrint, MPInteger[] signature, byte[] salt)
-
-
Method Detail
-
getVersion
public int getVersion()
get the version number
-
getSignatureType
public int getSignatureType()
return the signature type.
-
getKeyID
public long getKeyID()
return the keyID- Returns:
- the keyID that created the signature.
-
getFingerPrint
public byte[] getFingerPrint()
Return the signature's fingerprint.- Returns:
- fingerprint (digest prefix) of the signature
-
getSalt
public byte[] getSalt()
Return the signature's salt. Only for v6 signatures.- Returns:
- salt
-
getSignatureTrailer
public byte[] getSignatureTrailer()
return the signature trailer that must be included with the data to reconstruct the signature- Returns:
- byte[]
-
getKeyAlgorithm
public int getKeyAlgorithm()
return the encryption algorithm tag
-
getHashAlgorithm
public int getHashAlgorithm()
return the hashAlgorithm tag
-
getSignature
public MPInteger[] getSignature()
return the signature as a set of integers - note this is normalised to be the ASN.1 encoding of what appears in the signature packet. Note, that Ed25519 and Ed448 returns null, as the raw signature is stored in signatureEncoding only. For those, usegetSignatureBytes()
instead.
-
getSignatureBytes
public byte[] getSignatureBytes()
Return the byte encoding of the signature section.- Returns:
- uninterpreted signature bytes.
-
getHashedSubPackets
public SignatureSubpacket[] getHashedSubPackets()
-
getUnhashedSubPackets
public SignatureSubpacket[] getUnhashedSubPackets()
-
getCreationTime
public long getCreationTime()
Return the creation time of the signature in milli-seconds.- Returns:
- the creation time in millis
-
encode
public void encode(BCPGOutputStream out) throws java.io.IOException
- Specified by:
encode
in classContainedPacket
- Throws:
java.io.IOException
-
fromByteArray
public static SignaturePacket fromByteArray(byte[] data) throws java.io.IOException
- Throws:
java.io.IOException
-
-