Digital Authentication Framework 6.0.1.33
|
Base class for simple keys. More...
#include <basic_key.h>
Public Member Functions | |
BasicKey (BasicError &err) | |
Constructor. | |
DAMetaData & | getInfo () |
get metadata object describing this key | |
virtual bool | encrypt (DAMessage &msg) |
Encrypt the given message Returns success = true. | |
virtual bool | decrypt (DAMessage &msg) |
Decrypt the given message Returns success = true. | |
virtual bool | sign (DAMessage &msg) |
Sign the given message Returns success = true. | |
virtual bool | verify (DAMessage &msg) |
Verify the given message Returns success = true. | |
virtual bool | setData (const DAData &data) |
Set key data. | |
virtual bool | getData (DAData &out) |
Retrieve key data. | |
virtual bool | generateMaterial () |
Generates or regenerates key material. | |
virtual std::vector< DAMechanism > | getMechanisms () |
Return a vector of mechanisms supported by this key. | |
void | setSerial (const std::string &serial) |
Set serial number to be returned by metadata. | |
Protected Member Functions | |
bool | _notImpl () |
Stub for not-implemented methods: sets a NOT_IMPLEMENTED error and returns false. | |
Protected Attributes | |
BasicError & | m_error |
Reference to object where this key can report errors. | |
BasicMetaData | m_meta |
Metadata for this key. Subclasses can set fields within this data. |
Base class for simple keys.
This contains boiler-plate code for implementing error and DAMetaData handling for keys. Note it is not usable directly, as it provides no working operations.
BasicKey::BasicKey | ( | BasicError & | err | ) | [inline] |
Constructor.
err | reference to the BasicError object for the DASession which contains this key. |
virtual bool BasicKey::generateMaterial | ( | ) | [inline, virtual] |
Generates or regenerates key material.
For class-1 keys, this is called during the 'change passphrase' sequence to roll over a key. This should replace the key's current value with new, random data. This method may return a NOT_IMPLEMENTED error, in which case the DAF logic will call setData().
Returns success = true, false if error
Implements DAKey.
virtual bool BasicKey::getData | ( | DAData & | data | ) | [inline, virtual] |
Retrieve key data.
This is only called for class-0 and class-1 keys. Keys capable of cryptographic operation should not implement this.
Returns success = true
Implements DAKey.
Reimplemented in BasicReadonlyKey.
DAMetaData& BasicKey::getInfo | ( | ) | [inline, virtual] |
get metadata object describing this key
Implements DAKey.
virtual bool BasicKey::setData | ( | const DAData & | data | ) | [inline, virtual] |
Set key data.
For class-1 keys, this is called during the 'change 'passphrase' sequence, if generateMaterial() returns a NOT_IMPLEMENTED error. The data to be stored will be 32 bytes (STORAGE_MESSAGE_SIZE) bytes long. If the key cannot store messages of this size, it must implement the generateMaterial() method.
Returns success = true
Implements DAKey.