ID Chip Reader
secure_message.h File Reference

Secure messaging implementation for communication with a smart card. More...

Go to the source code of this file.

Macros

#define ACCESS_SECURE_MESSAGE_H_
 

Functions

int ProtectedSelectAPDU (unsigned char cmdData[2], unsigned char *sendSequenceCounter, unsigned char encryptSessionKey[16], unsigned char macSessionKey[16])
 Sends a protected SELECT APDU command to the smart card. More...
 
int ProtectedReadBinaryAPDU (unsigned char cmdHeader[4], unsigned char resLen, unsigned char *responseBuf, unsigned char *sendSequenceCounter, unsigned char encryptSessionKey[16], unsigned char macSessionKey[16])
 Sends a protected READ BINARY APDU command to the smart card. More...
 

Detailed Description

Secure messaging implementation for communication with a smart card.

Author
Khoa Nguyen

This file provides the interface for secure messaging between an application and a smart card. It implements protected APDU commands for SELECT and READ BINARY operations, using encryption and MAC calculation to ensure confidentiality and integrity of the communication.

Macro Definition Documentation

◆ ACCESS_SECURE_MESSAGE_H_

#define ACCESS_SECURE_MESSAGE_H_

Function Documentation

◆ ProtectedReadBinaryAPDU()

int ProtectedReadBinaryAPDU ( unsigned char  cmdHeader[4],
unsigned char  resLen,
unsigned char *  responseBuf,
unsigned char *  sendSequenceCounter,
unsigned char  encryptSessionKey[16],
unsigned char  macSessionKey[16] 
)

Sends a protected READ BINARY APDU command to the smart card.

This function sends a protected READ BINARY APDU command to the smart card using encryption and MAC calculation to ensure confidentiality and integrity of the communication. The response data will be decrypted and stored in the provided buffer.

Parameters
cmdHeaderPointer to a 4-byte array representing the command header for the READ BINARY operation.
resLenLength of expected response data in bytes.
responseBufPointer to a buffer where the decrypted response data will be stored.
sendSequenceCounterPointer to an 8-byte array representing the current Send Sequence Counter (SSC).
encryptSessionKeyPointer to a 16-byte array containing the encryption session key (KS_Enc).
macSessionKeyPointer to a 16-byte array containing the MAC session key (KS_MAC).
Returns
APP_SUCCESS if successful; otherwise, an error code indicating failure reason.

◆ ProtectedSelectAPDU()

int ProtectedSelectAPDU ( unsigned char  cmdData[2],
unsigned char *  sendSequenceCounter,
unsigned char  encryptSessionKey[16],
unsigned char  macSessionKey[16] 
)

Sends a protected SELECT APDU command to the smart card.

This function sends a protected SELECT APDU command to the smart card using encryption and MAC calculation to ensure confidentiality and integrity of the communication.

Parameters
cmdDataFile identifier (2 bytes) to be selected by this command.
sendSequenceCounterPointer to an 8-byte array representing the current Send Sequence Counter (SSC).
encryptSessionKeyPointer to a 16-byte array containing the encryption session key (KS_Enc).
macSessionKeyPointer to a 16-byte array containing the MAC session key (KS_MAC).
Returns
APP_SUCCESS if successful; otherwise, an error code indicating failure reason.