public class PGPOnePassSignature
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected byte |
lastb |
protected java.io.OutputStream |
legacyTextSigOut
Verification only: a second stream fed the pre-1.87 canonical text form, in which a bare CR
was hashed as CR LF, or null if no such fallback is wanted.
|
protected boolean |
sawBareCR
Set once the text-mode input has contained a CR not followed by LF, the only input on which
the current and the legacy canonical text forms differ.
|
protected java.io.OutputStream |
sigOut |
protected int |
sigType |
protected int |
version |
| Constructor and Description |
|---|
PGPOnePassSignature(BCPGInputStream pIn) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
blockUpdate(byte[] block,
int off,
int len) |
void |
encode(java.io.OutputStream outStream) |
protected void |
getAttributesHash(PGPUserAttributeSubpacketVector userAttributes) |
byte[] |
getEncoded() |
byte[] |
getFingerprint()
Return the issuer key fingerprint.
|
int |
getHashAlgorithm() |
int |
getKeyAlgorithm() |
long |
getKeyID()
Return the key-ID of the issuer signing key.
|
KeyIdentifier |
getKeyIdentifier()
Return a
KeyIdentifier identifying this PGPOnePassSignature. |
byte[] |
getSalt()
Return the salt used in the corresponding signature.
|
int |
getSignatureType() |
int |
getVersion()
Return the packet version.
|
void |
init(PGPContentVerifierBuilderProvider verifierBuilderProvider,
PGPPublicKey pubKey)
Initialise the signature object for verification.
|
boolean |
isContaining()
Return true, if the signature contains any signatures that follow.
|
protected static boolean |
isLegacyTextFormAllowed()
Return true if a text signature should also be checked against the pre-1.87 canonical text
form (see
update(byte)). |
protected boolean |
isLegacyTextFormDifferent()
Return true if the text-mode data hashed so far is one the legacy canonical text form
hashes differently - that is, it holds a bare CR, a trailing CR included.
|
protected void |
resetTextState()
Reset the text canonicalisation state for a new signature calculation.
|
void |
update(byte b)
Update the signature with a byte of the signed data.
|
void |
update(byte[] b) |
void |
update(byte[] b,
int off,
int len) |
protected void |
updateWithIdData(int header,
byte[] idBytes) |
protected void |
updateWithPublicKey(PGPPublicKey key) |
boolean |
verify(PGPSignature pgpSig)
Verify the calculated signature against the passed in PGPSignature.
|
protected boolean |
verifyLegacyTextForm(PGPContentVerifier legacyVerifier,
byte[] trailer,
byte[] signature)
Second chance for a text signature that did not verify over the current canonical form:
check it over the legacy form, if a legacy hash was kept and the data is one on which the two
forms differ (on any other data they are the same bytes, so the answer cannot change).
|
protected byte lastb
protected java.io.OutputStream sigOut
protected int sigType
protected final int version
protected java.io.OutputStream legacyTextSigOut
update(byte).protected boolean sawBareCR
public PGPOnePassSignature(BCPGInputStream pIn) throws java.io.IOException, PGPException
java.io.IOExceptionPGPExceptionpublic void init(PGPContentVerifierBuilderProvider verifierBuilderProvider, PGPPublicKey pubKey) throws PGPException
verifierBuilderProvider - provider for a content verifier builder for the signature type of interest.pubKey - the public key to use for verificationPGPException - if there's an issue with creating the verifier.public boolean verify(PGPSignature pgpSig) throws PGPException
pgpSig - PGPExceptionpublic int getVersion()
public long getKeyID()
OnePassSignaturePacket.VERSION_6 packets, the key-ID is derived from the fingerprint.public byte[] getFingerprint()
OnePassSignaturePacket.VERSION_6 packets.public KeyIdentifier getKeyIdentifier()
KeyIdentifier identifying this PGPOnePassSignature.public byte[] getSalt()
OnePassSignaturePacket.VERSION_6 packets.public int getSignatureType()
public int getHashAlgorithm()
public int getKeyAlgorithm()
public boolean isContaining()
public byte[] getEncoded()
throws java.io.IOException
java.io.IOExceptionpublic void encode(java.io.OutputStream outStream)
throws java.io.IOException
java.io.IOExceptionprotected void resetTextState()
public void update(byte b)
For a text signature (type 0x01) the data is hashed in canonical text form, as RFC 9580
sec. 5.2.1.2 describes: a LF not preceded by a CR is hashed as CR LF, and every other byte,
a CR not followed by a LF included, is hashed unaltered. A bare CR is therefore not a line
ending, which is what GnuPG, GopenPGP, OpenPGP.js, rpgpie, RNP and PGPy do (github #2553).
Releases before 1.87 hashed a bare CR as CR LF; when verifying, that form is also accepted
unless Properties.OPENPGP_TEXT_SIG_ALLOW_LEGACY_CR is set to
false.
protected boolean isLegacyTextFormDifferent()
protected static boolean isLegacyTextFormAllowed()
update(byte)).protected boolean verifyLegacyTextForm(PGPContentVerifier legacyVerifier, byte[] trailer, byte[] signature) throws PGPException
PGPExceptionpublic void update(byte[] b)
public void update(byte[] b,
int off,
int len)
protected void blockUpdate(byte[] block,
int off,
int len)
protected void updateWithIdData(int header,
byte[] idBytes)
protected void updateWithPublicKey(PGPPublicKey key) throws PGPException
PGPExceptionprotected void getAttributesHash(PGPUserAttributeSubpacketVector userAttributes) throws PGPException
PGPException