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

public Class X931Signer

extends Object
implements Signer
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.Signer
Imports
java.math.BigInteger, org.bouncycastle.crypto.AsymmetricBlockCipher, .CipherParameters, .CryptoException, .Digest, .Signer, org.bouncycastle.crypto.params.RSAKeyParameters, org.bouncycastle.util.Arrays, .BigIntegers

X9.31-1998 - signing using a hash.

The message digest hash, H, is encapsulated to form a byte string as follows

EB = 06 || PS || 0xBA || H || TRAILER
where PS is a string of bytes all of value 0xBB of length such that |EB|=|n|, and TRAILER is the ISO/IEC 10118 part number† for the digest. The byte string, EB, is converted to an integer value, the message representative, f.

Field Summary

Modifier and TypeField and Description
private byte[]
private AsymmetricBlockCipher
private Digest
private int
private RSAKeyParameters
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_SHA224

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
X931Signer(AsymmetricBlockCipher
base cipher to use for signature creation/verification
cipher
,
Digest
digest to use.
digest
,
boolean
whether or not the trailer is implicit or gives the hash.
implicit
)

Generate a signer with either implicit or explicit trailers for X9.31

public
X931Signer(AsymmetricBlockCipher
cipher to use.
cipher
,
Digest
digest to sign with.
digest
)

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

private void
createSignatureBlock(int trailer)

public byte[]
generateSignature()

Implements org.bouncycastle.crypto.Signer.generateSignature.

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

public void
init(boolean
true if for signing, false otherwise
forSigning
,
CipherParameters
necessary parameters.
param
)

Implements org.bouncycastle.crypto.Signer.init.

Initialise the signer for signing or verification.

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 boolean
verifySignature(byte[] signature)

Implements org.bouncycastle.crypto.Signer.verifySignature.

return true if the signature represents a X9.31 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
keyBitsback to summary
private int keyBits
kParamback to summary
private RSAKeyParameters kParam
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_SHA224back to summary
public static final int TRAILER_SHA224

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

X931Signerback to summary
public X931Signer(AsymmetricBlockCipher cipher, Digest digest, boolean implicit)

Generate a signer with either implicit or explicit trailers for X9.31

Parameters
cipher:AsymmetricBlockCipher

base cipher to use for signature creation/verification

digest:Digest

digest to use.

implicit:boolean

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

X931Signerback to summary
public X931Signer(AsymmetricBlockCipher cipher, Digest digest)

Constructor for a signer with an explicit digest trailer.

Parameters
cipher:AsymmetricBlockCipher

cipher to use.

digest:Digest

digest to sign with.

Method Detail

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

clear possible sensitive data

createSignatureBlockback to summary
private void createSignatureBlock(int trailer)
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.

initback to summary
public void init(boolean forSigning, CipherParameters param)

Implements org.bouncycastle.crypto.Signer.init.

Doc from org.bouncycastle.crypto.Signer.init.

Initialise the signer for signing or verification.

Parameters
forSigning:boolean

true if for signing, false otherwise

param:CipherParameters

necessary parameters.

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

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

Implements org.bouncycastle.crypto.Signer.verifySignature.

return true if the signature represents a X9.31 signature for the passed in message.