Digital Authentication Framework 6.0.1.33
|
Encapsulates a message and various (optional) crypto parameters. More...
#include <DigitalAuthenticationFramework.h>
Public Member Functions | |
DAMessage () | |
Constructor Creates an empty message with all zero-length entries. | |
bool | getMechanism (DAMechanism &mech) const |
Return cryptographic mechanism identifier. | |
bool | getIV (DAData &iv) const |
Return IV. | |
bool | getPlaintext (DAData &data) const |
Get the original plaintext/signed message. | |
bool | getCiphertext (DAData &data) const |
Get the final encrypted message or signature. | |
DADigestType | getDigestType () const |
Gets digest (hash) type used for signature. | |
void | setMechanism (const DAMechanism &mech) |
Set Crypto Algorithm. | |
bool | setMechanismForRSAPkcs1Signature () |
Set mechanism appropriately for RSA-SSA-PKCS1 signatures. | |
bool | setMechanismForDSA () |
Set mechanism appropriately for DSA algorithm. | |
bool | setMechanismForECDSA () |
Set mechanism appropriately for ECDSA algorithm. | |
void | setIV (const DAData &iv) |
Set IV. | |
void | setPlaintext (const DAData &data) |
Set plaintext buffer. | |
void | setCiphertext (const DAData &data) |
Set ciphertext buffer. | |
void | setDigestType (DADigestType dtype) |
Set digest type. | |
void | unsetMechanism () |
Remove Crypto Algorithm. | |
void | unsetIV () |
Remove IV. | |
void | unsetPlaintext () |
Remove plaintext. | |
void | unsetCiphertext () |
Remove ciphertext. | |
void | unsetDigestType () |
Unset digestType. | |
bool | applyDefaultDigest () |
Ensure a DAMessage contains a message hash for signature. | |
bool | getPkcs1SignatureData (DAData &msg) |
Create a byte string suitable for RSA PKCS#1 signature. | |
Static Public Member Functions | |
static DADigestType | getDigestFromMech (const DAMechanism &mech) |
Get hash type associated with a mechanism. | |
Protected Types | |
enum | { HAVE_PLAINTEXT = 1, HAVE_CIPHERTEXT = 2, HAVE_IV = 4, HAVE_MECH = 8 } |
Protected Attributes | |
DAData | m_plaintext |
Plaintext bytes. | |
DAData | m_ciphertext |
Ciphertext bytes. | |
DAData | m_iv |
IV bytes. | |
DAMechanism | m_mech |
Mechanism (OID) | |
unsigned | m_flags |
Flags (HAVE_PLAINTEXT etc) | |
DADigestType | m_digestType |
Digest used for signed message. |
Encapsulates a message and various (optional) crypto parameters.
Keys operate on Messages.
anonymous enum [protected] |
bool DAMessage::applyDefaultDigest | ( | ) |
Ensure a DAMessage contains a message hash for signature.
If the digest type (see getDigestType()) is not DA_DIGEST_NONE, leaves the message unchanged, and returns true.
Otherwise, if the mechanism (see getMechanism()) has already been set, applies the hash algorithm appropriate to that mechanism. The message's plaintext field is replaced by the hash, and the digest type is set accordingly. This method will return true if the operation succeeded, and false if the mechanism was not recognised.
If the mechanism was not set, a default hash algorithm is chosen (in this release, SHA-256). The plaintext is replaced by its hash, and the digest type field is set (to DA_DIGEST_SHA256). The method then returns true.
static DADigestType DAMessage::getDigestFromMech | ( | const DAMechanism & | mech | ) | [static] |
Get hash type associated with a mechanism.
mech | Specifier for an (asymmetric) signature mechanism |
DADigestType DAMessage::getDigestType | ( | ) | const [inline] |
Gets digest (hash) type used for signature.
bool DAMessage::getMechanism | ( | DAMechanism & | mech | ) | const [inline] |
Return cryptographic mechanism identifier.
This is, in most cases, a value chosen from class CommonMech. It is set by the DAKey::sign() and DAKey::encrypt() methods, and must be set by the called before DAKey::verify() and DAKey::decrypt().
bool DAMessage::getPkcs1SignatureData | ( | DAData & | msg | ) |
Create a byte string suitable for RSA PKCS#1 signature.
msg | Byte-block returned. 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. |
bool DAMessage::setMechanismForDSA | ( | ) |
Set mechanism appropriately for DSA algorithm.
Chooses a suitable DAMechanism (see common_mechs.h) for the hash algorithm identified by the m_digestType field, and sets it as the m_mech field.
bool DAMessage::setMechanismForECDSA | ( | ) |
Set mechanism appropriately for ECDSA algorithm.
Chooses a suitable DAMechanism (see common_mechs.h) for the hash algorithm identified by the m_digestType field, and sets it as the m_mech field.
bool DAMessage::setMechanismForRSAPkcs1Signature | ( | ) |
Set mechanism appropriately for RSA-SSA-PKCS1 signatures.
Chooses a suitable DAMechanism (see common_mechs.h) for the hash algorithm identified by the m_digestType field, and sets it as the m_mech field.