-
Notifications
You must be signed in to change notification settings - Fork 0
/
smCom.c
74 lines (70 loc) · 2.47 KB
/
smCom.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @file smCom.c
* @author NXP Semiconductors
* @version 1.0
* @par License
* Copyright 2016 NXP
*
* This software is owned or controlled by NXP and may only be used
* strictly in accordance with the applicable license terms. By expressly
* accepting such terms or by downloading, installing, activating and/or
* otherwise using the software, you are agreeing that you have read, and
* that you agree to comply with and are bound by, such license terms. If
* you do not agree to be bound by the applicable license terms, then you
* may not retain, install, activate or otherwise use the software.
*
* @par Description
* Implements installable communication layer to exchange APDU's between Host and Secure Module.
* Allows the top half of the Host Library to be independent of the actual interconnect
* between Host and Secure Module
*/
#include <stdio.h>
#include "smCom.h"
static ApduTransceiveFunction_t pSmCom_Transceive = NULL;
static ApduTransceiveRawFunction_t pSmCom_TransceiveRaw = NULL;
/**
* Install interconnect and protocol specific implementation of APDU transfer functions.
*
*/
void smCom_Init(ApduTransceiveFunction_t pTransceive, ApduTransceiveRawFunction_t pTransceiveRaw)
{
pSmCom_Transceive = pTransceive;
pSmCom_TransceiveRaw = pTransceiveRaw;
}
/**
* Exchanges APDU without interpreting the message exchanged
*
* @param[in,out] pApdu apdu_t datastructure
*
* @retval ::SMCOM_OK Operation successful
* @retval ::SMCOM_SND_FAILED Send Failed
* @retval ::SMCOM_RCV_FAILED Receive Failed
*/
U32 smCom_Transceive(apdu_t * pApdu)
{
if (pSmCom_Transceive != NULL)
{
return pSmCom_Transceive(pApdu);
}
return SMCOM_NO_PRIOR_INIT;
}
/**
* Exchanges APDU without interpreting the message exchanged
*
* @param[in] pTx Command to be sent to secure module
* @param[in] txLen Length of command to be sent
* @param[in,out] pRx IN: Buffer to contain response; OUT: Response received from secure module
* @param[in,out] pRxLen IN: [TBD]; OUT: Length of response received
*
* @retval ::SMCOM_OK Operation successful
* @retval ::SMCOM_SND_FAILED Send Failed
* @retval ::SMCOM_RCV_FAILED Receive Failed
*/
U32 smCom_TransceiveRaw(U8 * pTx, U16 txLen, U8 * pRx, U32 * pRxLen)
{
if (pSmCom_TransceiveRaw != NULL)
{
return pSmCom_TransceiveRaw(pTx, txLen, pRx, pRxLen);
}
return SMCOM_NO_PRIOR_INIT;
}