Class desfire::crypto_3k3des_base
Defined in File crypto.hpp
Inheritance Relationships
Base Type
public desfire::crypto_with_cmac
(Class desfire::crypto_with_cmac)
Derived Type
public desfire::esp32::crypto_3k3des
(Class desfire::esp32::crypto_3k3des)
Class Documentation
-
class crypto_3k3des_base : public desfire::crypto_with_cmac
Base class for a 3K3DES 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_3k3des
Public Functions
-
crypto_3k3des_base()
-
inline virtual desfire::cipher_type cipher_type() const final
- Returns:
-
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.
-
virtual void setup_with_key(range<std::uint8_t const*> key) override
Sets the key to be used from now onwards in this cryptographic implementation.
This method should do all the setup needed for further operations, i.e. setting the key in the internal cryptographic primitives, resetting or setting initialization vectors, deriving CMAC keys where needed. This method should be called by init_session as soon as it has derived the key from the random data.
- Parameters:
key – Range of bytes containing the key to use for the following operations. This is specified as a range on raw bytes for convenience, as the underlying cryptographic functions are likely low level.
-
crypto_3k3des_base()