2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __smartcard_h__
18 #define __smartcard_h__
28 * @brief This file contains the smartcard api
35 #define SMARTCARD_ERROR_CLASS TIZEN_ERROR_SMARTCARD
38 * @brief Error codes reported by the smartcard API.
40 * @ingroup CAPI_NETWORK_SMARTCARD_SE_SERVICE_MODULE
43 SMARTCARD_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
44 SMARTCARD_ERROR_GENERAL = SMARTCARD_ERROR_CLASS | 0x01, /**< A general error occurred */
45 SMARTCARD_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
46 SMARTCARD_ERROR_NO_SUCH_ELEMENT = SMARTCARD_ERROR_CLASS | 0x02, /**< No such element error */
47 SMARTCARD_ERROR_ILLEGAL_STATE = SMARTCARD_ERROR_CLASS | 0x03, /**< Illegal state of execution error */
48 SMARTCARD_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid function parameter */
49 SMARTCARD_ERROR_ILLEGAL_REFERENCE = SMARTCARD_ERROR_CLASS | 0x04, /**< Illegal reference */
50 SMARTCARD_ERROR_OPERATION_NOT_SUPPORTED = SMARTCARD_ERROR_CLASS | 0x05, /**< Operation not supported from SE */
51 SMARTCARD_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
52 SMARTCARD_ERROR_CHANNEL_NOT_AVAILABLE = SMARTCARD_ERROR_CLASS | 0x06, /**< No channel available */
53 SMARTCARD_ERROR_NOT_INITIALIZED = SMARTCARD_ERROR_CLASS | 0x07, /**< Smartcard service not initialized */
54 SMARTCARD_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */
55 SMARTCARD_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
59 * @brief Enumerations for Smartcard reader event type
61 * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
64 SMARTCARD_READER_EVENT_TYPE_IO_ERROR = 0, /**< This event notifies the application that I/O error occurs on smartcard reader */
65 SMARTCARD_READER_EVENT_TYPE_INSERTED = 1, /**< This event notifies the application that smartcard reader is inserted */
66 SMARTCARD_READER_EVENT_TYPE_REMOVED = 2, /**< This event notifies the application that smartcard reader is removed */
67 } smartcard_reader_event_type_e;
70 * @brief Called when a smartcard reader event occurs.
72 * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
74 * @param [in] reader The reader handle
75 * @param [in] event_type The reader event type
76 * @param [in] user_data The user data passed from the callback registration function
78 * @see smartcard_reader_set_event_cb()
79 * @see smartcard_reader_unset_event_cb()
81 typedef void (*smartcard_reader_event_cb)(int reader, smartcard_reader_event_type_e event_type, void *user_data);
84 * @brief Initializes smartcard service
87 * @privilege %http://tizen.org/privilege/secureelement
88 * @ingroup CAPI_NETWORK_SMARTCARD_SE_SERVICE_MODULE
90 * @remarks This function must be called before proceeding any other smartcard function
92 * @return 0 on success, otherwise a negative error value.
93 * @retval #SMARTCARD_ERROR_NONE Successful
94 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
95 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
96 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
98 * @see smartcard_deinitialize()
100 SMARTCARD_API int smartcard_initialize(void);
103 * @brief Deinitializes smartcard service
104 * @details Releases all the resource of the smartcard service
107 * @privilege %http://tizen.org/privilege/secureelement
108 * @ingroup CAPI_NETWORK_SMARTCARD_SE_SERVICE_MODULE
110 * @return 0 on success, otherwise a negative error value.
111 * @retval #SMARTCARD_ERROR_NONE Successful
112 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
113 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
114 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
115 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
117 * @see smartcard_initialize()
119 SMARTCARD_API int smartcard_deinitialize(void);
122 * @brief Gets the version of SIMAlliance OpenMobileAPI specification
124 * @ingroup CAPI_NETWORK_SMARTCARD_SE_SERVICE_MODULE
126 * @remarks The @a version must be released using free().
128 * @param [out] version The version of SIMAlliance OpenMobileAPI specification
130 * @return 0 on success, otherwise a negative error value.
131 * @retval #SMARTCARD_ERROR_NONE Successful
132 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
133 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
134 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
135 * @retval #SMARTCARD_ERROR_OUT_OF_MEMORY Out of memory
138 SMARTCARD_API int smartcard_get_version(char **version);
141 * @brief Gets the list of available Secure Element readers.
143 * @ingroup CAPI_NETWORK_SMARTCARD_SE_SERVICE_MODULE
145 * @remarks readers must be released using free().
147 * @param [out] readers List of readers
148 * @param [out] length The number of readers
150 * @return 0 on success, otherwise a negative error value.
151 * @retval #SMARTCARD_ERROR_NONE Successful
152 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
153 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
154 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
155 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
158 SMARTCARD_API int smartcard_get_readers(int **readers, int *length);
161 * @brief Returns the name of the given reader.
163 * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
165 * @remarks reader_name must be released using free().
166 * @remarks If the reader is a SIM reader, then its name must be "SIM[Slot]"
167 * @remarks If the reader is a SD or micro SD reader, then its name must be "SD[slot]"
168 * @remarks If the reader is a embedded SE reader, then its name must be "eSE[slot]"
170 * @param [in] reader Handle to the reader
171 * @param [out] reader_name The name of reader
173 * @return 0 on success, otherwise a negative error value.
174 * @retval #SMARTCARD_ERROR_NONE Successful
175 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
176 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
177 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
178 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
180 * @see smartcard_get_readers()
182 SMARTCARD_API int smartcard_reader_get_name(int reader, char **reader_name);
185 * @brief Checks if a Secure Element is present in the given reader.
187 * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
189 * @param [in] reader Handle to the reader
190 * @param [out] is_present True or false depending whether a secure element is present in the
191 reader - undefined when an error is returned
193 * @return 0 on success, otherwise a negative error value.
194 * @retval #SMARTCARD_ERROR_NONE Successful
195 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
196 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
197 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
198 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
200 * @see smartcard_get_readers()
202 SMARTCARD_API int smartcard_reader_is_secure_element_present(int reader, bool *is_present);
205 * @brief Connects to a Secure Element in the given reader.
208 * @privilege %http://tizen.org/privilege/secureelement
209 * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
211 * @param [in] reader Handle to the reader
212 * @param [out] session Handle to the session created for the given reader
214 * @return 0 on success, otherwise a negative error value.
215 * @retval #SMARTCARD_ERROR_NONE Successful
216 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
217 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
218 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
219 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
220 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
221 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
223 * @see smartcard_get_readers()
225 SMARTCARD_API int smartcard_reader_open_session(int reader, int *session);
228 * @brief Closes all the sessions opened on the given reader.
229 * @details All the channels opened by all these sessions will be closed.
232 * @privilege %http://tizen.org/privilege/secureelement
233 * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
235 * @param [in] reader Handle to the reader
237 * @return 0 on success, otherwise a negative error value.
238 * @retval #SMARTCARD_ERROR_NONE Successful
239 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
240 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
241 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
242 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
243 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
244 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
246 * @see smartcard_get_readers()
248 SMARTCARD_API int smartcard_reader_close_sessions(int reader);
251 * @brief Sets a callback function for receiving reader event.
253 * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
255 * @param [in] cb The reader event callback
256 * @param [in] user_data The user data
258 * @return 0 on success, otherwise a negative error value.
259 * @retval #SMARTCARD_ERROR_NONE Successful
260 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
261 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
262 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
264 * @see smartcard_reader_unset_event_cb()
266 SMARTCARD_API int smartcard_reader_set_event_cb(smartcard_reader_event_cb cb, void *user_data);
269 * @brief Unsets the reader event callback function.
271 * @ingroup CAPI_NETWORK_SMARTCARD_READER_MODULE
273 * @return 0 on success, otherwise a negative error value.
274 * @retval #SMARTCARD_ERROR_NONE Successful
275 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
276 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
278 * @see smartcard_reader_set_event_cb()
280 SMARTCARD_API int smartcard_reader_unset_event_cb(void);
283 * @brief Gets the reader that provides the given session.
285 * @ingroup CAPI_NETWORK_SMARTCARD_SESSION_MODULE
287 * @param [in] session Handle to the session
288 * @param [out] reader Reader handle that provides the given session
290 * @return 0 on success, otherwise a negative error value.
291 * @retval #SMARTCARD_ERROR_NONE Successful
292 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
293 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
294 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
295 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
297 * @see smartcard_reader_open_session()
299 SMARTCARD_API int smartcard_session_get_reader(int session, int *reader);
302 * @brief Gets the Answer to Reset(ATR) of this Secure Element.
305 * @privilege %http://tizen.org/privilege/secureelement
306 * @ingroup CAPI_NETWORK_SMARTCARD_SESSION_MODULE
308 * @remarks atr must be released using free().
309 * @remarks If the Answer to Reset(ATR) for this Secure Element is not available the returned length is set to zero and return value is Success.
311 * @param [in] session Handle to the session
312 * @param [out] atr Byte array to retrieve the Answer to Reset(ATR)
313 * @param [out] length The length of atr
315 * @return 0 on success, otherwise a negative error value.
316 * @retval #SMARTCARD_ERROR_NONE Successful
317 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
318 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
319 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
320 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
321 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
323 * @see smartcard_reader_open_session()
325 SMARTCARD_API int smartcard_session_get_atr(int session, unsigned char **atr, int *length);
328 * @brief Closes the connection with the Secure Element.
329 * @details This will close any channels opened by this application with this Secure Element.
332 * @privilege %http://tizen.org/privilege/secureelement
333 * @ingroup CAPI_NETWORK_SMARTCARD_SESSION_MODULE
335 * @param [in] session handle to the session
337 * @return 0 on success, otherwise a negative error value.
338 * @retval #SMARTCARD_ERROR_NONE Successful
339 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
340 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
341 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
342 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
343 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
344 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
346 * @see smartcard_reader_open_session()
348 SMARTCARD_API int smartcard_session_close(int session);
351 * @brief Checks if the given session is closed.
353 * @ingroup CAPI_NETWORK_SMARTCARD_SESSION_MODULE
355 * @param [in] session Handle to the session
356 * @param [out] is_closed True or false depending on the session state
358 * @return 0 on success, otherwise a negative error value.
359 * @retval #SMARTCARD_ERROR_NONE Successful
360 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
361 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
362 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
363 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
365 * @see smartcard_reader_open_session()
367 SMARTCARD_API int smartcard_session_is_closed(int session, bool *is_closed);
370 * @brief Closes any channel opened on the given session.
373 * @privilege %http://tizen.org/privilege/secureelement
374 * @ingroup CAPI_NETWORK_SMARTCARD_SESSION_MODULE
376 * @param [in] session Handle to the session
378 * @return 0 on success, otherwise a negative error value.
379 * @retval #SMARTCARD_ERROR_NONE Successful
380 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
381 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
382 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
383 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
384 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
385 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
387 * @see smartcard_reader_open_session()
389 SMARTCARD_API int smartcard_session_close_channels(int session);
392 * @brief Gets an access to the basic channel, as defined in the ISO/IEC 7816-4 specification (the one that has number 0).
395 * @privilege %http://tizen.org/privilege/secureelement
396 * @ingroup CAPI_NETWORK_SMARTCARD_SESSION_MODULE
398 * @remarks ex) unsigned char aid[] = {0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35};
399 * @remarks If the Application ID(AID) is null, it means no Applet is to be selected on this channel and the default Applet is used.
400 * @remarks Opening of the basic channel to a specific applet is NOT allowed for UICC.
402 * @param [in] session Handle to the session
403 * @param [in] aid Byte array containing the Application ID(AID) to be selected on the given channel
404 * @param [in] aid_len Size of byte array or 0 when no SELECT should be executed
405 * @param [in] P2 P2 byte of the SELECT command if executed
406 * @param [out] channel Handle of the basic channel
408 * @return 0 on success, otherwise a negative error value.
409 * @retval #SMARTCARD_ERROR_NONE Successful
410 * @retval #SMARTCARD_ERROR_CHANNEL_NOT_AVAILABLE No channel available
411 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
412 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
413 * @retval #SMARTCARD_ERROR_NO_SUCH_ELEMENT No such element error
414 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
415 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
416 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
417 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
419 * @see smartcard_reader_open_session()
421 SMARTCARD_API int smartcard_session_open_basic_channel(int session, unsigned char *aid, int aid_len, unsigned char P2, int *channel);
424 * @brief Open a logical channel with the Secure Element, selecting the Applet represented by the given Application ID(AID).
427 * @privilege %http://tizen.org/privilege/secureelement
428 * @ingroup CAPI_NETWORK_SMARTCARD_SESSION_MODULE
430 * @remarks ex) unsigned char aid[] = {0xA0, 0x00, 0x00, 0x00, 0x63, 0x50, 0x4B, 0x43, 0x53, 0x2D, 0x31, 0x35};
431 * @remarks If the Application ID(AID) is null, it means no Applet is to be selected on this channel and the default Applet is used.
433 * @param [in] session Handle to the session
434 * @param [in] aid Byte array containing the Application ID(AID) to be selected on the given channel
435 * @param [in] aid_len Size of byte array or 0 when no SELECT should be executed
436 * @param [in] P2 P2 byte of the SELECT command if executed
437 * @param [out] channel Handle of the new logical channel
439 * @return 0 on success, otherwise a negative error value.
440 * @retval #SMARTCARD_ERROR_NONE Successful
441 * @retval #SMARTCARD_ERROR_CHANNEL_NOT_AVAILABLE No channel available
442 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
443 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
444 * @retval #SMARTCARD_ERROR_NO_SUCH_ELEMENT No such element error
445 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
446 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
447 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
448 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
450 * @see smartcard_reader_open_session()
452 SMARTCARD_API int smartcard_session_open_logical_channel(int session, unsigned char *aid, int aid_len, unsigned char P2, int *channel);
455 * @brief Closes the given channel to the Secure Element.
458 * @privilege %http://tizen.org/privilege/secureelement
459 * @ingroup CAPI_NETWORK_SMARTCARD_CHANNEL_MODULE
461 * @param [in] channel Handle to the channel
463 * @return 0 on success, otherwise a negative error value.
464 * @retval #SMARTCARD_ERROR_NONE Successful
465 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
466 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
467 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
468 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
469 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
470 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
472 * @see smartcard_session_open_basic_channel()
473 * @see smartcard_session_open_logical_channel()
475 SMARTCARD_API int smartcard_channel_close(int channel);
478 * @brief Checks if the given channel is the basic channel.
480 * @ingroup CAPI_NETWORK_SMARTCARD_CHANNEL_MODULE
482 * @param [in] channel Handle to the channel
483 * @param [out] is_basic_channel True or false depending on the channel type
485 * @return 0 on success, otherwise a negative error value.
486 * @retval #SMARTCARD_ERROR_NONE Successful
487 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
488 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
489 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
490 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
492 * @see smartcard_session_open_basic_channel()
493 * @see smartcard_session_open_logical_channel()
495 SMARTCARD_API int smartcard_channel_is_basic_channel(int channel, bool *is_basic_channel);
498 * @brief Checks if the given channel is closed.
500 * @ingroup CAPI_NETWORK_SMARTCARD_CHANNEL_MODULE
502 * @param [in] channel Handle to the channel
503 * @param [out] is_closed True or false depending on the channel state
505 * @return 0 on success, otherwise a negative error value.
506 * @retval #SMARTCARD_ERROR_NONE Successful
507 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
508 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
509 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
510 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
512 * @see smartcard_session_open_basic_channel()
513 * @see smartcard_session_open_logical_channel()
515 SMARTCARD_API int smartcard_channel_is_closed(int channel, bool *is_closed);
518 * @brief Gets the response to the select command.
520 * @ingroup CAPI_NETWORK_SMARTCARD_CHANNEL_MODULE
522 * @remarks select_resp must be released using free().
524 * @param [in] channel Handle to the channel
525 * @param [out] select_resp Byte array to retrieve the SELECT response
526 * @param [out] length The length of select_resp
528 * @return 0 on success, otherwise a negative error value.
529 * @retval #SMARTCARD_ERROR_NONE Successful
530 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
531 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
532 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
533 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
535 * @see smartcard_session_open_basic_channel()
536 * @see smartcard_session_open_logical_channel()
538 SMARTCARD_API int smartcard_channel_get_select_response(int channel, unsigned char **select_resp, int *length);
541 * @brief Gets the session that has opened the given channel.
543 * @ingroup CAPI_NETWORK_SMARTCARD_CHANNEL_MODULE
545 * @param [in] channel Handle to the channel
546 * @param [out] session Session handle of the given channel
548 * @return 0 on success, otherwise a negative error value.
549 * @retval #SMARTCARD_ERROR_NONE Successful
550 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
551 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
552 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
553 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
555 * @see smartcard_session_open_basic_channel()
556 * @see smartcard_session_open_logical_channel()
558 SMARTCARD_API int smartcard_channel_get_session(int channel, int *session);
561 * @brief Transmits an APDU command (as per ISO/IEC 7816-4) to the Secure Element.
564 * @privilege %http://tizen.org/privilege/secureelement
565 * @ingroup CAPI_NETWORK_SMARTCARD_CHANNEL_MODULE
567 * @remarks resp must be released using free().
568 * @remarks MANAGE_CHANNEL commands are not allowed.
569 * @remarks SELECT by DF Name (P1=04) are not allowed.
570 * @remarks bytes with channel numbers are de-masked.
572 * @param [in] channel Handle to the channel
573 * @param [in] cmd Command APDU to be send to the secure element
574 * @param [in] cmd_len Size of command APDU
575 * @param [out] resp Byte array for the response APDU plus status words
576 * @param [out] length The length of resp
578 * @return 0 on success, otherwise a negative error value.
579 * @retval #SMARTCARD_ERROR_NONE Successful
580 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
581 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
582 * @retval #SMARTCARD_ERROR_ILLEGAL_STATE Illegal state of execution error
583 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
584 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
585 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
586 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
588 * @see smartcard_session_open_basic_channel()
589 * @see smartcard_session_open_logical_channel()
591 SMARTCARD_API int smartcard_channel_transmit(int channel, unsigned char *cmd, int cmd_len, unsigned char **resp, int *length);
594 * @brief Helper function to retrieves the response APDU of the previous transmit() call
596 * @ingroup CAPI_NETWORK_SMARTCARD_CHANNEL_MODULE
598 * @remarks resp must be released using free().
600 * @param [in] channel Handle to the channel
601 * @param [out] resp Byte array for the response APDU plus status words
602 * @param [out] length The length of resp
604 * @return 0 on success, otherwise a negative error value.
605 * @retval #SMARTCARD_ERROR_NONE Successful
606 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
607 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
608 * @retval #SMARTCARD_ERROR_ILLEGAL_STATE Illegal state of execution error
609 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
610 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
612 * @see smartcard_session_open_basic_channel()
613 * @see smartcard_session_open_logical_channel()
615 SMARTCARD_API int smartcard_channel_transmit_retrieve_response(int channel, unsigned char **resp, int *length);
618 * @brief Performs a selection of the next Applet on the given channel that matches to the partial Application ID(AID)
621 * @privilege %http://tizen.org/privilege/secureelement
622 * @ingroup CAPI_NETWORK_SMARTCARD_CHANNEL_MODULE
624 * @param [in] channel Handle to the channel
625 * @param [out] is_success True or false depending whether another applet with the partial Application ID(AID)
626 could be selected on the given channel
628 * @return 0 on success, otherwise a negative error value.
629 * @retval #SMARTCARD_ERROR_NONE Successful
630 * @retval #SMARTCARD_ERROR_GENERAL A general error occurred
631 * @retval #SMARTCARD_ERROR_INVALID_PARAMETER Invalid function parameter
632 * @retval #SMARTCARD_ERROR_ILLEGAL_STATE Illegal state of execution error
633 * @retval #SMARTCARD_ERROR_OPERATION_NOT_SUPPORTED Operation not supported from SE
634 * @retval #SMARTCARD_ERROR_IO_ERROR I/O error
635 * @retval #SMARTCARD_ERROR_NOT_INITIALIZED Smartcard service not initialized
636 * @retval #SMARTCARD_ERROR_NOT_SUPPORTED Not supported
637 * @retval #SMARTCARD_ERROR_PERMISSION_DENIED Permission denied
639 * @see smartcard_session_open_basic_channel()
640 * @see smartcard_session_open_logical_channel()
642 SMARTCARD_API int smartcard_channel_select_next(int channel, bool *is_success);