LibLogicalAccess  2.5.0
An Open Source RFID Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
logicalaccess::EPassCrypto Class Reference

#include <epasscrypto.hpp>

Inheritance diagram for logicalaccess::EPassCrypto:
logicalaccess::ISO24727Crypto

Public Member Functions

 EPassCrypto ()
 
 EPassCrypto (const std::string &mrz)
 
void reset (const std::string &mrz)
 
void compute_session_keys (const ByteVector &k_icc, const ByteVector &random_icc) override
 
ByteVector compute_enc_key (const ByteVector &seed, const std::string hash_algo="sha1", unsigned char keylen=16)
 
ByteVector compute_mac_key (const ByteVector &seed, const std::string hash_algo="sha1", unsigned char keylen=16)
 
ByteVector compute_mac (std::shared_ptr< openssl::SymmetricCipher > cipher, const ByteVector &in, const ByteVector &k_mac, const ByteVector &iv={}, const ByteVector &ssc={}) override
 
- Public Member Functions inherited from logicalaccess::ISO24727Crypto
 ISO24727Crypto (const std::string &cipher="3des", const std::string &hash="sha1")
 
ByteVector step1 (const ByteVector &random_icc, ByteVector random_ifd={}, ByteVector random_k_ifd={})
 
bool step2 (const ByteVector &auth_response)
 
bool secureMode () const
 
ByteVector encrypt_apdu (const ByteVector &apdu)
 
ByteVector decrypt_rapdu (const ByteVector &rapdu)
 
ByteVector encrypt_apdu (std::shared_ptr< openssl::SymmetricCipher > cipher, const ByteVector &apdu, const ByteVector &ks_enc, const ByteVector &ks_mac, const ByteVector &ssc)
 
ByteVector decrypt_rapdu (std::shared_ptr< openssl::SymmetricCipher > cipher, const ByteVector &rapdu, const ByteVector &ks_enc, const ByteVector &ks_mac, const ByteVector &ssc)
 
ByteVector get_session_enc_key () const
 
ByteVector get_session_mac_key () const
 
ByteVector get_send_session_counter () const
 
virtual ByteVector auth_pad (const ByteVector &data)
 
virtual void compute_session_keys (const ByteVector &k_icc, const ByteVector &random_icc)=0
 
virtual ByteVector compute_mac (std::shared_ptr< openssl::SymmetricCipher > cipher, const ByteVector &in, const ByteVector &k_mac, const ByteVector &iv={}, const ByteVector &scc={})=0
 
virtual void reset ()
 
std::shared_ptr< openssl::SymmetricCiphercreateCipher () const
 

Static Public Member Functions

static ByteVector adjust_key_parity (const ByteVector &key)
 
- Static Public Member Functions inherited from logicalaccess::ISO24727Crypto
static ByteVector pad (const ByteVector &in, unsigned int padlen=8)
 
static ByteVector unpad (const ByteVector &in)
 
static ByteVector increment_ssc (const ByteVector &in)
 
static ByteVector hash_data (const ByteVector &data, const std::string hash_algo="sha1")
 

Additional Inherited Members

- Public Attributes inherited from logicalaccess::ISO24727Crypto
ByteVector k_enc_
 
ByteVector k_mac_
 
- Protected Attributes inherited from logicalaccess::ISO24727Crypto
std::string cipher_
 
std::string hash_
 
ByteVector random_ifd_
 
ByteVector random_k_ifd_
 
bool step2_success_
 
ByteVector S_enc_
 
ByteVector S_mac_
 
ByteVector S_send_counter_
 

Constructor & Destructor Documentation

◆ EPassCrypto() [1/2]

EPassCrypto::EPassCrypto ( )
explicit

◆ EPassCrypto() [2/2]

EPassCrypto::EPassCrypto ( const std::string &  mrz)
explicit

Member Function Documentation

◆ adjust_key_parity()

ByteVector EPassCrypto::adjust_key_parity ( const ByteVector key)
static

◆ compute_enc_key()

ByteVector EPassCrypto::compute_enc_key ( const ByteVector seed,
const std::string  hash_algo = "sha1",
unsigned char  keylen = 16 
)

◆ compute_mac()

ByteVector EPassCrypto::compute_mac ( std::shared_ptr< openssl::SymmetricCipher cipher,
const ByteVector in,
const ByteVector k_mac,
const ByteVector iv = {},
const ByteVector ssc = {} 
)
overridevirtual

ISO 9797-1 MAC Algorithm 3

Perform MAC computation on the block in.

The computation requires k_mac, a 16bytes key that will be split in two during the computation.

Unless the MAC computation is for the Mutual Authenticate command, SSC (Send Session Counter) is required, otherwise the MAC will be rejected.

Warning
No padding is performed.

Implements logicalaccess::ISO24727Crypto.

◆ compute_mac_key()

ByteVector EPassCrypto::compute_mac_key ( const ByteVector seed,
const std::string  hash_algo = "sha1",
unsigned char  keylen = 16 
)

◆ compute_session_keys()

void EPassCrypto::compute_session_keys ( const ByteVector k_icc,
const ByteVector random_icc 
)
overridevirtual

◆ reset()

void EPassCrypto::reset ( const std::string &  mrz)

The documentation for this class was generated from the following files: