LibLogicalAccess  2.5.0
An Open Source RFID Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
logicalaccess::ISO24727Crypto Class Referenceabstract

#include <iso24727crypto.hpp>

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

Public Member Functions

 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 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")
 

Public Attributes

ByteVector k_enc_
 
ByteVector k_mac_
 

Protected Attributes

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

◆ ISO24727Crypto()

ISO24727Crypto::ISO24727Crypto ( const std::string &  cipher = "3des",
const std::string &  hash = "sha1" 
)
explicit

Member Function Documentation

◆ auth_pad()

ByteVector ISO24727Crypto::auth_pad ( const ByteVector data)
virtual

◆ compute_mac()

virtual ByteVector logicalaccess::ISO24727Crypto::compute_mac ( std::shared_ptr< openssl::SymmetricCipher cipher,
const ByteVector in,
const ByteVector k_mac,
const ByteVector iv = {},
const ByteVector scc = {} 
)
pure virtual

Implemented in logicalaccess::EPassCrypto.

◆ compute_session_keys()

virtual void logicalaccess::ISO24727Crypto::compute_session_keys ( const ByteVector k_icc,
const ByteVector random_icc 
)
pure virtual

Implemented in logicalaccess::EPassCrypto.

◆ createCipher()

std::shared_ptr< openssl::SymmetricCipher > ISO24727Crypto::createCipher ( ) const

◆ decrypt_rapdu() [1/2]

ByteVector ISO24727Crypto::decrypt_rapdu ( const ByteVector rapdu)

◆ decrypt_rapdu() [2/2]

ByteVector ISO24727Crypto::decrypt_rapdu ( std::shared_ptr< openssl::SymmetricCipher cipher,
const ByteVector rapdu,
const ByteVector ks_enc,
const ByteVector ks_mac,
const ByteVector ssc 
)

◆ encrypt_apdu() [1/2]

ByteVector ISO24727Crypto::encrypt_apdu ( const ByteVector apdu)

◆ encrypt_apdu() [2/2]

ByteVector ISO24727Crypto::encrypt_apdu ( std::shared_ptr< openssl::SymmetricCipher cipher,
const ByteVector apdu,
const ByteVector ks_enc,
const ByteVector ks_mac,
const ByteVector ssc 
)

◆ get_send_session_counter()

ByteVector ISO24727Crypto::get_send_session_counter ( ) const

◆ get_session_enc_key()

ByteVector ISO24727Crypto::get_session_enc_key ( ) const

◆ get_session_mac_key()

ByteVector ISO24727Crypto::get_session_mac_key ( ) const

◆ hash_data()

ByteVector ISO24727Crypto::hash_data ( const ByteVector data,
const std::string  hash_algo = "sha1" 
)
static

◆ increment_ssc()

ByteVector ISO24727Crypto::increment_ssc ( const ByteVector in)
static

Increment the Session Send Counter by one and return a new ByteVector.

◆ pad()

ByteVector ISO24727Crypto::pad ( const ByteVector in,
unsigned int  padlen = 8 
)
static

ISO 9797-1 padding method 2

◆ reset()

void ISO24727Crypto::reset ( )
virtual

◆ secureMode()

bool ISO24727Crypto::secureMode ( ) const

Are we currently already in a Secure Messaging session ?

◆ step1()

ByteVector ISO24727Crypto::step1 ( const ByteVector random_icc,
ByteVector  random_ifd = {},
ByteVector  random_k_ifd = {} 
)

Call after construction to feed the random from the card to the crypto helper.

The random_ifd and random_k_ifd array will be generated if left to they default, empty value. Specifying this parameter is useful for testing purpose or if you make use of a custom source of randomness.

Returns
Command data for Mutual Authenticate.

◆ step2()

bool ISO24727Crypto::step2 ( const ByteVector auth_response)

Process the response from the ICC.

If step2() completes successfully, the user is allowed to call the various get_*() method.

◆ unpad()

ByteVector ISO24727Crypto::unpad ( const ByteVector in)
static

Cancel the padding created by pad()

Member Data Documentation

◆ cipher_

std::string logicalaccess::ISO24727Crypto::cipher_
protected

◆ hash_

std::string logicalaccess::ISO24727Crypto::hash_
protected

◆ k_enc_

ByteVector logicalaccess::ISO24727Crypto::k_enc_

◆ k_mac_

ByteVector logicalaccess::ISO24727Crypto::k_mac_

◆ random_ifd_

ByteVector logicalaccess::ISO24727Crypto::random_ifd_
protected

Generated at step1 (or inputted at step1).

◆ random_k_ifd_

ByteVector logicalaccess::ISO24727Crypto::random_k_ifd_
protected

Generated at step1 (or inputted at step1).

◆ S_enc_

ByteVector logicalaccess::ISO24727Crypto::S_enc_
protected

◆ S_mac_

ByteVector logicalaccess::ISO24727Crypto::S_mac_
protected

◆ S_send_counter_

ByteVector logicalaccess::ISO24727Crypto::S_send_counter_
protected

◆ step2_success_

bool logicalaccess::ISO24727Crypto::step2_success_
protected

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