Class desfire::crypto_aes_base

Inheritance Relationships

Base Type

Derived Type

Class Documentation

class crypto_aes_base : public desfire::crypto_with_cmac

Base class for a AES128 cryptographic implementation. Inherit from this.

Compared to crypto_with_cmac, this class fixes the cipher_type and provides the implementation of the session key derivation function init_session (which then calls setup_primitives_with_key). Subclasses should then implement only setup_primitives_with_key and do_crypto.

Subclassed by desfire::esp32::crypto_aes

Public Functions

crypto_aes_base()
inline virtual desfire::cipher_type cipher_type() const final
Returns:

desfire::cipher_type::aes128

virtual void init_session(range<std::uint8_t const*> random_data) final

Begins a new session by deriving the session key from random_data and calling setup_with_key.

This method should do the appropriate operations to derive a session key from the data random_data which was obtained as a consequence of the key exchange protocol between the two parties. These usually consist in byte shift and rearrangement.

Note

Implementations of this method must then call manually setup_with_key in order to complete the session initialization process.

Parameters:

random_data – Range of bytes containing the random data exchanged by the two parties. This has to be used to derive the session key. This is specified as a range on raw bytes for convenience, as the underlying cryptographic functions are likely low level.