Top Description Fields Constructors Methods
org.bouncycastle.crypto.signers

public Class ISO9796d2PSSSigner

extends Object
implements SignerWithRecovery
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.SignerWithRecovery, org.bouncycastle.crypto.Signer
Imports
java.security.SecureRandom, org.bouncycastle.crypto.AsymmetricBlockCipher, .CipherParameters, .CryptoException, .CryptoServicesRegistrar, .Digest, .InvalidCipherTextException, .SignerWithRecovery, org.bouncycastle.crypto.params.ParametersWithRandom, .ParametersWithSalt, .RSAKeyParameters, org.bouncycastle.util.Arrays

ISO9796-2 - mechanism using a hash function with recovery (scheme 2 and 3).

Note

the usual length for the salt is the length of the hash function used in bytes.

Field Summary

Modifier and TypeField and Description
private byte[]
private AsymmetricBlockCipher
private Digest
private boolean
private int
private int
private byte[]
private int
private byte[]
private int
private byte[]
private int
private SecureRandom
private byte[]
private int
private byte[]
private int
public static final int
TRAILER_IMPLICIT

Deprecated use ISOTrailers
public static final int
TRAILER_RIPEMD128

Deprecated use ISOTrailers
public static final int
TRAILER_RIPEMD160

Deprecated use ISOTrailers
public static final int
TRAILER_SHA1

Deprecated use ISOTrailers
public static final int
TRAILER_SHA256

Deprecated use ISOTrailers
public static final int
TRAILER_SHA384

Deprecated use ISOTrailers
public static final int
TRAILER_SHA512

Deprecated use ISOTrailers
public static final int
TRAILER_WHIRLPOOL

Deprecated use ISOTrailers

Constructor Summary

AccessConstructor and Description
public
ISO9796d2PSSSigner(AsymmetricBlockCipher
base cipher to use for signature creation/verification
cipher
,
Digest
digest to use.
digest
,
int
length of salt in bytes.
saltLength
,
boolean
whether or not the trailer is implicit or gives the hash.
implicit
)

Generate a signer with either implicit or explicit trailers for ISO9796-2, scheme 2 or 3.

public
ISO9796d2PSSSigner(AsymmetricBlockCipher
cipher to use.
cipher
,
Digest
digest to sign with.
digest
,
int
length of salt in bytes.
saltLength
)

Constructor for a signer with an explicit digest trailer.

Method Summary

Modifier and TypeMethod and Description
private void
clearBlock(byte[] block)

clear possible sensitive data

public byte[]
generateSignature()

Implements org.bouncycastle.crypto.Signer.generateSignature.

generate a signature for the loaded message using the key we were initialised with.

public byte[]

Returns:

the full/partial recoveredMessage message.
getRecoveredMessage
()

Implements org.bouncycastle.crypto.SignerWithRecovery.getRecoveredMessage.

Return a reference to the recoveredMessage message, either as it was added to a just generated signature, or extracted from a verified one.

public boolean

Returns:

true on full message recovery, false otherwise, or if not sure.
hasFullMessage
()

Implements org.bouncycastle.crypto.SignerWithRecovery.hasFullMessage.

Return true if the full message was recoveredMessage.

public void
init(boolean
true if for signing, false if for verification.
forSigning
,
CipherParameters
parameters for signature generation/verification. If the parameters are for generation they should be a ParametersWithRandom, a ParametersWithSalt, or just an RSAKeyParameters object. If RSAKeyParameters are passed in a SecureRandom will be created.
param
)

Implements org.bouncycastle.crypto.Signer.init.

Initialise the signer.

private boolean
isSameAs(byte[] a, byte[] b)

compare two byte arrays - constant time

private void
ItoOSP(int i, byte[] sp)

int to octet string.

private void
LtoOSP(long l, byte[] sp)

long to octet string.

private byte[]
maskGeneratorFunction1(byte[] Z, int zOff, int zLen, int length)

mask generator function, as described in PKCS1v2.

public void
reset()

Implements org.bouncycastle.crypto.Signer.reset.

reset the internal state

public void
update(byte b)

Implements org.bouncycastle.crypto.Signer.update.

update the internal digest with the byte b

public void
update(byte[] in, int off, int len)

Implements org.bouncycastle.crypto.Signer.update.

update the internal digest with the byte array in

public void
updateWithRecoveredMessage(byte[]
the signature that we are in the process of verifying.
signature
)

Implements org.bouncycastle.crypto.SignerWithRecovery.updateWithRecoveredMessage.

Perform an update with the recovered message before adding any other data.

public boolean
verifySignature(byte[] signature)

Implements org.bouncycastle.crypto.Signer.verifySignature.

return true if the signature represents a ISO9796-2 signature for the passed in message.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockback to summary
private byte[] block
cipherback to summary
private AsymmetricBlockCipher cipher
digestback to summary
private Digest digest
fullMessageback to summary
private boolean fullMessage
hLenback to summary
private int hLen
keyBitsback to summary
private int keyBits
mBufback to summary
private byte[] mBuf
messageLengthback to summary
private int messageLength
preBlockback to summary
private byte[] preBlock
preMStartback to summary
private int preMStart
preSigback to summary
private byte[] preSig
preTLengthback to summary
private int preTLength
randomback to summary
private SecureRandom random
recoveredMessageback to summary
private byte[] recoveredMessage
saltLengthback to summary
private int saltLength
standardSaltback to summary
private byte[] standardSalt
trailerback to summary
private int trailer
TRAILER_IMPLICITback to summary
public static final int TRAILER_IMPLICIT

Deprecated

use ISOTrailers

TRAILER_RIPEMD128back to summary
public static final int TRAILER_RIPEMD128

Deprecated

use ISOTrailers

TRAILER_RIPEMD160back to summary
public static final int TRAILER_RIPEMD160

Deprecated

use ISOTrailers

TRAILER_SHA1back to summary
public static final int TRAILER_SHA1

Deprecated

use ISOTrailers

TRAILER_SHA256back to summary
public static final int TRAILER_SHA256

Deprecated

use ISOTrailers

TRAILER_SHA384back to summary
public static final int TRAILER_SHA384

Deprecated

use ISOTrailers

TRAILER_SHA512back to summary
public static final int TRAILER_SHA512

Deprecated

use ISOTrailers

TRAILER_WHIRLPOOLback to summary
public static final int TRAILER_WHIRLPOOL

Deprecated

use ISOTrailers

Constructor Detail

ISO9796d2PSSSignerback to summary
public ISO9796d2PSSSigner(AsymmetricBlockCipher cipher, Digest digest, int saltLength, boolean implicit)

Generate a signer with either implicit or explicit trailers for ISO9796-2, scheme 2 or 3.

Parameters
cipher:AsymmetricBlockCipher

base cipher to use for signature creation/verification

digest:Digest

digest to use.

saltLength:int

length of salt in bytes.

implicit:boolean

whether or not the trailer is implicit or gives the hash.

ISO9796d2PSSSignerback to summary
public ISO9796d2PSSSigner(AsymmetricBlockCipher cipher, Digest digest, int saltLength)

Constructor for a signer with an explicit digest trailer.

Parameters
cipher:AsymmetricBlockCipher

cipher to use.

digest:Digest

digest to sign with.

saltLength:int

length of salt in bytes.

Method Detail

clearBlockback to summary
private void clearBlock(byte[] block)

clear possible sensitive data

generateSignatureback to summary
public byte[] generateSignature() throws CryptoException

Implements org.bouncycastle.crypto.Signer.generateSignature.

generate a signature for the loaded message using the key we were initialised with.

getRecoveredMessageback to summary
public byte[] getRecoveredMessage()

Implements org.bouncycastle.crypto.SignerWithRecovery.getRecoveredMessage.

Return a reference to the recoveredMessage message, either as it was added to a just generated signature, or extracted from a verified one.

Returns:byte[]

the full/partial recoveredMessage message.

See Also
org.bouncycastle.crypto.SignerWithRecovery#getRecoveredMessage()
hasFullMessageback to summary
public boolean hasFullMessage()

Implements org.bouncycastle.crypto.SignerWithRecovery.hasFullMessage.

Return true if the full message was recoveredMessage.

Returns:boolean

true on full message recovery, false otherwise, or if not sure.

See Also
org.bouncycastle.crypto.SignerWithRecovery#hasFullMessage()
initback to summary
public void init(boolean forSigning, CipherParameters param)

Implements org.bouncycastle.crypto.Signer.init.

Initialise the signer.

Parameters
forSigning:boolean

true if for signing, false if for verification.

param:CipherParameters

parameters for signature generation/verification. If the parameters are for generation they should be a ParametersWithRandom, a ParametersWithSalt, or just an RSAKeyParameters object. If RSAKeyParameters are passed in a SecureRandom will be created.

Exceptions
IllegalArgumentException:
if wrong parameter type or a fixed salt is passed in which is the wrong length.
isSameAsback to summary
private boolean isSameAs(byte[] a, byte[] b)

compare two byte arrays - constant time

ItoOSPback to summary
private void ItoOSP(int i, byte[] sp)

int to octet string.

LtoOSPback to summary
private void LtoOSP(long l, byte[] sp)

long to octet string.

maskGeneratorFunction1back to summary
private byte[] maskGeneratorFunction1(byte[] Z, int zOff, int zLen, int length)

mask generator function, as described in PKCS1v2.

resetback to summary
public void reset()

Implements org.bouncycastle.crypto.Signer.reset.

reset the internal state

updateback to summary
public void update(byte b)

Implements org.bouncycastle.crypto.Signer.update.

update the internal digest with the byte b

updateback to summary
public void update(byte[] in, int off, int len)

Implements org.bouncycastle.crypto.Signer.update.

update the internal digest with the byte array in

updateWithRecoveredMessageback to summary
public void updateWithRecoveredMessage(byte[] signature) throws InvalidCipherTextException

Implements org.bouncycastle.crypto.SignerWithRecovery.updateWithRecoveredMessage.

Doc from org.bouncycastle.crypto.SignerWithRecovery.updateWithRecoveredMessage.

Perform an update with the recovered message before adding any other data. This must be the first update method called, and calling it will result in the signer assuming that further calls to update will include message content past what is recoverable.

Parameters
signature:byte[]

the signature that we are in the process of verifying.

verifySignatureback to summary
public boolean verifySignature(byte[] signature)

Implements org.bouncycastle.crypto.Signer.verifySignature.

return true if the signature represents a ISO9796-2 signature for the passed in message.