Samsung Internal API reference  2.0
tee_internal_se_api.h
1 /*
2  *
3  * Copyright (C) 2012-2019, Samsung Electronics Co., Ltd.
4  *
5  */
6 
7 #ifndef __TEE_INTERNAL_SE_H__
8 #define __TEE_INTERNAL_SE_H__
9 
10 #include <tee_internal_api.h>
11 #include <stdbool.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /************************************ Types **********************************/
18 
19 /* Also, added "gpd.tee.se.version" */
20 #define TEE_SE_API_1_1 (0x01010000)
21 
25 enum tee_secure_element_function_id {
26  ID_TEE_SE_Service_Open = 0x0101,
27  ID_TEE_SE_Service_Close = 0x0102,
28  ID_TEE_SE_Service_Get_Readers = 0x0103,
29  ID_TEE_SE_Reader_Get_Properties = 0x0201,
30  ID_TEE_SE_Reader_Get_Name = 0x0202,
31  ID_TEE_SE_Reader_Open_Session = 0x0203,
32  ID_TEE_SE_Reader_Close_Sessions = 0x0204,
33  ID_TEE_SE_Session_Get_ATR = 0x0301,
34  ID_TEE_SE_Session_Is_Closed = 0x0302,
35  ID_TEE_SE_Session_Close = 0x0303,
36  ID_TEE_SE_Session_Close_Channels = 0x0304,
37  ID_TEE_SE_Session_Open_Basic_Channel = 0x0305,
38  ID_TEE_SE_Session_Open_Logical_Channel = 0x0306,
39  ID_TEE_SE_Channel_Close = 0x0401,
40  ID_TEE_SE_Channel_Select_Next = 0x0402,
41  ID_TEE_SE_Channel_Get_Select_Response = 0x0403,
42  ID_TEE_SE_Channel_Transmit = 0x0404,
43  ID_TEE_SE_Channel_Get_Response_Length = 0x0405,
44  ID_TEE_SE_Secure_Channel_Open = 0x0601,
45  ID_TEE_SE_Secure_Channel_Get_Security_Level = 0x0602,
46  ID_TEE_SE_Secure_Channel_Close = 0x0603
47 };
50 /* Handles */
51 typedef struct __TEE_SEServiceHandle *TEE_SEServiceHandle;
52 typedef struct __TEE_SEReaderHandle *TEE_SEReaderHandle;
53 typedef struct __TEE_SESessionHandle *TEE_SESessionHandle;
54 typedef struct __TEE_SEChannelHandle *TEE_SEChannelHandle;
55 
56 /*****************************************************************************/
57 
58 /******************************* User TA Lib API *****************************/
59 
60 /*****************************************************************************
61 * *
62 * SEService Class *
63 * *
64 * The service level is the entry point to the API, *
65 * allowing one to gain access to the TEE SE API. *
66 * *
67 *****************************************************************************/
68 
99 DSO_EXPORT TEE_Result TEE_SEServiceOpen(TEE_SEServiceHandle *seServiceHandle);
100 
119 DSO_EXPORT void TEE_SEServiceClose(TEE_SEServiceHandle seServiceHandle);
120 
149 DSO_EXPORT TEE_Result
150 TEE_SEServiceGetReaders(TEE_SEServiceHandle seServiceHandle,
151  TEE_SEReaderHandle *seReaderHandleList,
152  uint32_t *seReaderHandleListLen);
153 
154 /*****************************************************************************
155 * *
156 * SEReader Class *
157 * *
158 * The reader level allows an application to choose a reader *
159 * once enumerated by the service level. Sessions are opened *
160 * on a Secure Element inserted in a reader. *
161 * *
162 *****************************************************************************/
163 
166 typedef struct __TEE_SEReaderProperties {
167  bool sePresent;
168  bool teeOnly;
172 
193 DSO_EXPORT void
194 TEE_SEReaderGetProperties(TEE_SEReaderHandle seReaderHandle,
195  TEE_SEReaderProperties *readerProperties);
196 
225 DSO_EXPORT TEE_Result TEE_SEReaderGetName(TEE_SEReaderHandle seReaderHandle,
226  char *readerName,
227  uint32_t *readerNameLen);
228 
261 DSO_EXPORT TEE_Result
262 TEE_SEReaderOpenSession(TEE_SEReaderHandle seReaderHandle,
263  TEE_SESessionHandle *seSessionHandle);
264 
279 DSO_EXPORT void
280 TEE_SEReaderCloseSessions(TEE_SEReaderHandle seReaderHandle);
281 
282 /*****************************************************************************
283 * *
284 * SESession Class *
285 * *
286 * The session level is used to retrieve the ATR and *
287 * to open channels to SE applications. *
288 * *
289 *****************************************************************************/
290 
293 typedef struct __TEE_SEAID {
294  uint8_t *buffer;
295  uint32_t bufferLen;
296 } TEE_SEAID;
297 
323 DSO_EXPORT TEE_Result TEE_SESessionGetATR(TEE_SESessionHandle seSessionHandle,
324  void *atr,
325  uint32_t *atrLen);
326 
346 DSO_EXPORT TEE_Result
347 TEE_SESessionIsClosed(TEE_SESessionHandle seSessionHandle);
348 
362 DSO_EXPORT void TEE_SESessionClose(TEE_SESessionHandle seSessionHandle);
363 
377 DSO_EXPORT void
378 TEE_SESessionCloseChannels(TEE_SESessionHandle seSessionHandle);
379 
419 DSO_EXPORT TEE_Result
420 TEE_SESessionOpenBasicChannel(TEE_SESessionHandle seSessionHandle,
421  TEE_SEAID *seAID,
422  TEE_SEChannelHandle *seChannelHandle);
423 
464 DSO_EXPORT TEE_Result
465 TEE_SESessionOpenLogicalChannel(TEE_SESessionHandle seSessionHandle,
466  TEE_SEAID *seAID,
467  TEE_SEChannelHandle *seChannelHandle);
468 
469 /*****************************************************************************
470 * *
471 * SEChannel Class *
472 * *
473 * The channel level is used by applications to exchange *
474 * APDUs with the SE application. *
475 * *
476 *****************************************************************************/
477 
492 DSO_EXPORT void TEE_SEChannelClose(TEE_SEChannelHandle seChannelHandle);
493 
543 DSO_EXPORT TEE_Result
544 TEE_SEChannelSelectNext(TEE_SEChannelHandle seChannelHandle);
545 
576 DSO_EXPORT TEE_Result
577 TEE_SEChannelGetSelectResponse(TEE_SEChannelHandle seChannelHandle,
578  void *response, uint32_t *responseLen);
579 
633 DSO_EXPORT TEE_Result
634 TEE_SEChannelTransmit(TEE_SEChannelHandle seChannelHandle,
635  void *command,
636  uint32_t commandLen,
637  void *response,
638  uint32_t *responseLen);
639 
672 DSO_EXPORT TEE_Result
673 TEE_SEChannelGetResponseLength(TEE_SEChannelHandle seChannelHandle,
674  uint32_t *responseLen);
675 
676 /*****************************************************************************
677 * *
678 * Secure Channel (SCP) *
679 * *
680 *****************************************************************************/
681 
682 typedef enum {
683  TEE_SC_TYPE_SCP02 = 0x00,
684  TEE_SC_TYPE_SCP03 = 0x01,
685  TEE_SC_TYPE_SCP11a = 0x02,
686  TEE_SC_TYPE_SCP11b = 0x03,
690 } TEES_SC_SecureChannelType;
691 
694 typedef struct __TEE_SC_OID {
695  uint8_t *buffer;
696  uint32_t bufferLen;
697 } TEE_SC_OID;
698 
699 /* Warning: in TEESE API doc enum from p.6.2.2.3 and p.6.2.4
700  * has not members C_ENC and R_ENC, but T.6-3 and T.6-5 has,
701  * so added additional constants */
702 typedef enum {
703  TEE_SC_NO_SECURE_MESSAGING = 0x00,
704  TEE_AUTHENTICATE = 0x80,
706  TEE_SC_C_MAC = 0x01,
708  TEE_SC_C_ENC = 0x02,
710  TEE_SC_R_MAC = 0x10,
712  TEE_SC_R_ENC = 0x20,
714  TEE_SC_CR_MAC = 0x11,
716  TEE_SC_C_ENC_MAC = 0x03,
718  TEE_SC_R_ENC_MAC = 0x30,
720  TEE_SC_CR_ENC_MAC = 0x33,
722 } TEE_SC_SecurityLevel;
723 
726 typedef struct __TEE_SC_CardKeyRef {
727  uint8_t scKeyID;
728  uint8_t scKeyVersion;
730 
731 typedef enum {
732  TEE_SC_BASE_KEY = 0,
733  TEE_SC_KEY_SET = 1,
735 } TEE_SC_KeyType;
736 
739 typedef struct __TEE_SC_KeySetRef {
740  TEE_ObjectHandle scKeyEncHandle;
742  TEE_ObjectHandle scKeyMacHandle;
744 
747 typedef struct __TEE_SC_DeviceKeyRef {
748  TEE_SC_KeyType scKeyType;
749  union {
750  TEE_ObjectHandle scBaseKeyHandle;
751  TEE_SC_KeySetRef scKeySetRef;
753  };
755 
756 
759 typedef struct __TEE_SC_Params {
760  uint8_t scType;
762  TEE_SC_SecurityLevel scSecurityLevel;
765 } TEE_SC_Params;
766 
820 DSO_EXPORT TEE_Result
821 TEE_SESecureChannelOpen(TEE_SEChannelHandle seChannelHandle,
822  TEE_SC_Params *scParams);
823 
843 DSO_EXPORT int
844 TEE_SESecureChannelGetSecurityLevel(TEE_SEChannelHandle seChannelHandle);
845 
863 DSO_EXPORT void TEE_SESecureChannelClose(TEE_SEChannelHandle seChannelHandle);
864 
865 /*****************************************************************************/
866 
867 #ifdef __cplusplus
868 }
869 #endif
870 
871 #endif /* __TEE_INTERNAL_SE_H__ */
Definition: tee_internal_se_api.h:726
TEE_SC_OID scOID
Definition: tee_internal_se_api.h:761
bool teeOnly
Definition: tee_internal_se_api.h:168
TEE_ObjectHandle scKeyMacHandle
Definition: tee_internal_se_api.h:742
uint8_t scType
Definition: tee_internal_se_api.h:760
TEE_SC_SecurityLevel scSecurityLevel
Definition: tee_internal_se_api.h:762
uint8_t * buffer
Definition: tee_internal_se_api.h:695
uint8_t scKeyID
Definition: tee_internal_se_api.h:727
bool selectResponseEnable
Definition: tee_internal_se_api.h:169
TEE_SC_KeyType scKeyType
Definition: tee_internal_se_api.h:748
uint8_t scKeyVersion
Definition: tee_internal_se_api.h:728
TEE_SC_CardKeyRef scCardKeyRef
Definition: tee_internal_se_api.h:763
Definition: tee_internal_se_api.h:747
bool sePresent
Definition: tee_internal_se_api.h:167
Definition: tee_internal_se_api.h:293
Definition: tee_internal_se_api.h:759
Definition: tee_internal_se_api.h:739
Definition: tee_internal_se_api.h:166
TEE_SC_DeviceKeyRef scDeviceKeyRef
Definition: tee_internal_se_api.h:764
uint32_t bufferLen
Definition: tee_internal_se_api.h:295
Definition: tee_internal_se_api.h:694
uint8_t * buffer
Definition: tee_internal_se_api.h:294
uint32_t bufferLen
Definition: tee_internal_se_api.h:696
TEE_ObjectHandle scKeyEncHandle
Definition: tee_internal_se_api.h:740