Class desfire::protocol_legacy
Defined in File protocol.hpp
Inheritance Relationships
Base Type
public desfire::protocol
(Class desfire::protocol)
Class Documentation
-
class protocol_legacy : public desfire::protocol
Mode of operation of DES, 2K3DES legacy ciphers.
Public Types
-
using block_t = mlab::tagged_array<block_tag, block_size>
One cipher data block.
Public Functions
-
explicit protocol_legacy(std::unique_ptr<crypto> crypto)
Creates a new protocol using crypto as a underlying crypto primitive.
- Parameters:
crypto – Cryptographic primitive wrapper.
-
virtual void prepare_tx(bin_data &data, std::size_t offset, comm_mode mode) override
See protocol::prepare_tx for a generic description. This implementation does the following:
comm_mode::plain : does nothing.
comm_mode::maced : calculates a 32-bit MAC on
data
starting atoffset
, and appends it todata
.comm_mode::ciphered : calculates a 16-bit CRC on
data
starting atoffset
, and appends it todata
. It then proceeds as in:comm_mode::ciphered_no_crc : pads
data
with zeroes (ignoring everything beforeoffset
for the purpose of padding and length computation) to the next multiple of block_size, and runs a crypto_operation::encrypt ondata
, starting atoffset
.
-
virtual bool confirm_rx(bin_data &data, comm_mode mode) override
See protocol::confirm_rx for a generic description. This implementation does the following:
comm_mode::plain : does nothing.
comm_mode::maced : expects a sequence in the form
[message] [32-bit MAC] [status]
. Extracts the MAC, and compares it to the MAC computed on the message. If the comparison succeeds, removes the MAC from the sequence (keeping the status byte at the end) and returns positively.comm_mode::ciphered : runs a crypto_operation::decrypt on
data
(excluding the last status byte). It then expects that the plaintext is a sequence[message] [16-bit CRC] [padding] [status]
. It searches for the last sequence of 2 bytes that is a CRC on the previous data, and is following only by padding zeroes. If it finds any, and the CRC checks out, it removes the CRC and the padding, returning the message and the status byte.comm_mode::ciphered_no_crc : runs a crypto_operation::decrypt on
data
(excluding the last status byte).
-
virtual void init_session(bin_data const &random_data) override
Sets up the session symmetric key used for further communication. This is the first operation that follows a successful authentication. This method calls crypto::init_session with
random_data
.- Parameters:
random_data – Random data obtained via key exchange
-
virtual bool is_legacy() const override
As the name says, it is legacy.
-
using block_t = mlab::tagged_array<block_tag, block_size>