Digital Authentication Framework  6.0.1.37
Public Member Functions | Static Public Member Functions | List of all members
com.good.daf.DAMessage Class Reference

This type contains the inputs and outputs of a cryptographic transform. More...

Public Member Functions

 DAMessage ()
 Basic constructor. More...
 
DAMechanism getMechanism ()
 
DADigestType getDigestType ()
 
byte[] getIV ()
 
byte[] getPlaintext ()
 
byte[] getCiphertext ()
 
void setMechanism (DAMechanism newMech)
 Sets the mechanism. More...
 
void setDigestType (DADigestType newDigest)
 Sets the digest type. More...
 
void setIV (byte[] newIV)
 Sets the IV. More...
 
void setPlaintext (byte[] newPt)
 Sets the plaintext. More...
 
void setCiphertext (byte[] newCt)
 Sets the ciphertext. More...
 
boolean setMechanismForRSAPkcs1Signature ()
 Set mechanism appropriately for RSA PKCS#1 signatures. More...
 
boolean setMechanismForDSA ()
 Set mechanism appropriately for DSA algorithm. More...
 
boolean setMechanismForECDSA ()
 Set mechanism appropriately for ECDSA algorithm. More...
 
boolean applyDefaultDigest ()
 Ensure the DAMessage contains a pre-hashed message. More...
 
byte[] getPkcs1SignatureData ()
 Create a byte string suitable for RSA PKCS#1 signature. More...
 
String toString ()
 Stringifies the message contents. More...
 

Static Public Member Functions

static DAMessage build (byte[] plain, byte[] cipher, byte[] iv, byte[] mechoid, int digest)
 This is a one-shot constructor from a set of byte strings. More...
 

Detailed Description

This type contains the inputs and outputs of a cryptographic transform.

An instance of this type can contain a mechanism, digest type, iv, plaintext and ciphertext. All items are optional. A new instance of this class starts with none present and a digest type of 'none'.

Constructor & Destructor Documentation

com.good.daf.DAMessage.DAMessage ( )

Basic constructor.

The instance starts without any mechanism, iv, plaintext or ciphertext.

Member Function Documentation

boolean com.good.daf.DAMessage.applyDefaultDigest ( )

Ensure the DAMessage contains a pre-hashed message.

If the digest type is already set, does nothing and returns false. Otherwise, applies a default hash algorithm (SHA-256 in the current release) to the plaintext field, and sets the digest type accordingly. Returns true if the DAMessage was changed.

static DAMessage com.good.daf.DAMessage.build ( byte[]  plain,
byte[]  cipher,
byte[]  iv,
byte[]  mechoid,
int  digest 
)
static

This is a one-shot constructor from a set of byte strings.

This constructor is mainly for the benefit of JNI calling code.

Parameters
plainplaintext, may be null
cipherciphertext, may be null
iviv, may be null
mechoidmechanism encoded OID, may be null
digestdigest type ordinal (in DADigestType enumeration)
Returns
a DAMessage
byte [] com.good.daf.DAMessage.getCiphertext ( )
Returns
ciphertext, or null if no ciphertext is present
DADigestType com.good.daf.DAMessage.getDigestType ( )
Returns
digest type
byte [] com.good.daf.DAMessage.getIV ( )
Returns
iv, or null if no iv is present
DAMechanism com.good.daf.DAMessage.getMechanism ( )
Returns
mechanism, or null if no mechanism is present
byte [] com.good.daf.DAMessage.getPkcs1SignatureData ( )

Create a byte string suitable for RSA PKCS#1 signature.

Returns
null if the DAMessage is invalid/unsuitable
This is the DER encoding of a SEQUENCE containing the OID of the hash function followed by the hash value. See e.g. RFC 3447 section 9.2. This function will also apply a default hash function if the message doesn't have a digest type set.
byte [] com.good.daf.DAMessage.getPlaintext ( )
Returns
plaintext, or null if no plaintext is present
void com.good.daf.DAMessage.setCiphertext ( byte[]  newCt)

Sets the ciphertext.

Parameters
newCtnew ciphertext value, may be null to unset ciphertext
void com.good.daf.DAMessage.setDigestType ( DADigestType  newDigest)

Sets the digest type.

Parameters
newDigestnew digest type, may be null to reset to default (none)
void com.good.daf.DAMessage.setIV ( byte[]  newIV)

Sets the IV.

Parameters
newIVnew IV value, may be null to unset IV
void com.good.daf.DAMessage.setMechanism ( DAMechanism  newMech)

Sets the mechanism.

Parameters
newMechnew mechanism value, may be null to unset mechanism
boolean com.good.daf.DAMessage.setMechanismForDSA ( )

Set mechanism appropriately for DSA algorithm.

Chooses a suitable DAMechanism (see DAMechanism.Preset) for the hash algorithm identified by the digest type field, and sets it as the mechanism field.

Returns
false if unhandled digest in digest type field.
boolean com.good.daf.DAMessage.setMechanismForECDSA ( )

Set mechanism appropriately for ECDSA algorithm.

Chooses a suitable DAMechanism (see DAMechanism.Preset) for the hash algorithm identified by the digest type field, and sets it as the mechanism field.

Returns
false if invalid mechanism in digest type field.
boolean com.good.daf.DAMessage.setMechanismForRSAPkcs1Signature ( )

Set mechanism appropriately for RSA PKCS#1 signatures.

Choose a suitable DAMechanism (see DAMechanism.Preset) for the hash algorithm identified by the digest type field, and sets it as the mechanism field.

Returns
false if unhandled digest in digest type field.
void com.good.daf.DAMessage.setPlaintext ( byte[]  newPt)

Sets the plaintext.

Parameters
newPtnew plaintext value, may be null to unset plaintext
String com.good.daf.DAMessage.toString ( )

Stringifies the message contents.

Note that this can contain sensitive plaintext content.


The documentation for this class was generated from the following file: