<p>To use the SE service:</p>
<ol><li>
+<p>To use the functions and data types of the Smartcard API (in <a href="../../../../org.tizen.native.mobile.apireference/group__CAPI__NETWORK__SMARTCARD__MODULE.html">mobile</a> and <a href="../../../../org.tizen.native.wearable.apireference/group__CAPI__NETWORK__SMARTCARD__MODULE.html">wearable</a> applications), include the <span style="font-family: Courier New,Courier,monospace"><smartcard.h></span> header file in your application:</p>
+<pre class="prettyprint">
+#include <smartcard.h>
+</pre></li>
+<p>The <span style="font-family: Courier New,Courier,monospace;">http://tizen.org/privilege/secureelement</span> privilege is required for the Smartcard API. Add the privilege to the <span style="font-family: Courier New,Courier,monospace;">tizen-manifest.xml</span> file.</p>
+
+<pre class="prettyprint">
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns="http://tizen.org/ns/packages" api-version="2.3.1" package="org.tizen.basicuiapplication" version="1.0.0">
+ <profile name="wearable" />
+ <ui-application appid="org.tizen.basicuiapplication" exec="basicuiapplication" type="capp" multiple="false" taskmanage="true" nodisplay="false">
+ <icon>basicuiapplication.png</icon>
+ <label>basicuiapplication</label>
+ </ui-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/secureelement</privilege>
+ </privileges>
+</manifest>
+</pre>
+
<p>Initialize the smart card service for use:</p>
<pre class="prettyprint">
int ret;
ret = smartcard_initialize();
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard initialize success");
+ TC_PRT("smartcard initialize successful");
else
TC_PRT("smartcard initialize failed");
</pre>
ret = smartcard_deinitialize();
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard deinitialize success");
+ TC_PRT("smartcard deinitialize successful");
else
TC_PRT("smartcard deinitialize failed");
</pre>
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_get_readers is success");
- TC_PRT("reader handle : %d", phReaders[0]);
+ TC_PRT("smartcard_get_readers successful");
TC_PRT("readers length : %d", pLength);
+ if (pLength > 0) {
+ TC_PRT("reader handle : %d", phReaders[0]);
+ }
}
else
{
TC_PRT("smartcard_get_readers failed : %d", ret);
}
+
+if(phReaders != NULL)
+ free(phReaders);
</pre></li>
</ol>
<p>Retrieve the name of the reader with the <span style="font-family: Courier New,Courier,monospace;">smartcard_reader_get_name()</span> function:</p>
<pre class="prettyprint">
int ret;
+int reader = phReaders[0]; //get reader using smartcard_get_readers()
char * pReader = NULL;
ret = smartcard_reader_get_name(reader, &pReader);
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_reader_get_name success");
+ TC_PRT("smartcard_reader_get_name successful");
TC_PRT("reader name : %s", pReader);
}
else
ret = smartcard_reader_is_secure_element_present(reader, &is_present);
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_reader_is_secure_element_present is success");
+ TC_PRT("smartcard_reader_is_secure_element_present successful");
TC_PRT("reader secure element present : %d", is_present);
}
else
ret = smartcard_reader_close_sessions(reader);
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_reader_close_sessions success");
+ TC_PRT("smartcard_reader_close_sessions successful");
}
else
{
ret = smartcard_reader_get_name(reader, &pReader);
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_session_get_reader success");
+ TC_PRT("smartcard_session_get_reader successful");
TC_PRT("reader name : %s", pReader);
}
else
</pre></li>
<li>Retrieve the answer to reset (ATR) of the SE:
<pre class="prettyprint">
+int i;
int ret;
unsigned char *pAtr;
int pLength;
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_session_get_atr success : %d", pLength);
+ TC_PRT("smartcard_session_get_atr successful : %d", pLength);
for (i = 0; i < pLength; i++)
TC_PRT("%x ", (int)pAtr[i]);
}
ret = smartcard_session_open_basic_channel(session, aid, 4, 0x00, &channel);
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard_session_open_basic_channel is success : %d", channel);
+ TC_PRT("smartcard_session_open_basic_channel successful : %d", channel);
else
TC_PRT("smartcard_session_open_basic_channel failed");
ret = smartcard_session_open_logical_channel(session, aid, 12, 0x04, &channel);
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard_session_open_basic_channel is success : %d", (channel);
+ TC_PRT("smartcard_session_open_logical_channel successful : %d", (channel);
else
- TC_PRT("smartcard_session_open_basic_channel failed : %d", ret);
+ TC_PRT("smartcard_session_open_logical_channel failed : %d", ret);
</pre>
</li>
<li>Close all channels opened for a specific session:
ret = smartcard_session_close_channels(session);
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard_session_close_channels is success");
+ TC_PRT("smartcard_session_close_channels successful");
else
TC_PRT("smartcard_session_close_channels failed");
</pre>
ret = smartcard_session_close(session);
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard_session_close is success");
+ TC_PRT("smartcard_session_close successful");
else
TC_PRT("smartcard_session_close failed");
ret = smartcard_session_is_closed(session, &is_closed);
if (ret == SMARTCARD_ERROR_NONE && is_closed == true)
- TC_PRT("smartcard_session_is_closed is success");
+ TC_PRT("smartcard_session_is_closed successful");
else
TC_PRT("smartcard_session_is_closed failed");
</pre>
ret = smartcard_channel_get_session(channel, &session_handle);
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard_channel_get_session is success: %d", session_handle);
+ TC_PRT("smartcard_channel_get_session successful: %d", session_handle);
else
TC_PRT("smartcard_channel_get_session failed");
}
ret = smartcard_channel_is_basic_channel(channel, &is_basic);
if (ret == SMARTCARD_ERROR_NONE && is_basic == false)
- TC_PRT("smartcard_channel_is_basic_channel is success");
+ TC_PRT("smartcard_channel_is_basic_channel successful");
else
TC_PRT("smartcard_channel_is_basic_channel failed");
</pre></li>
bool is_next = true;
ret = smartcard_channel_select_next(channel, &is_next);
if (ret == SMARTCARD_ERROR_NONE && is_next == false)
- TC_PRT("smartcard_channel_select_next is success");
+ TC_PRT("smartcard_channel_select_next successful");
else
TC_PRT("smartcard_channel_select_next failed");
}
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_channel_get_select_response is success");
+ TC_PRT("smartcard_channel_get_select_response successful");
for (i = 0; i < pLength; i++)
g_print("%x ", (int)pSelectResponse[i]);
}
ret = smartcard_channel_is_closed(channel, &is_close);
if (ret == SMARTCARD_ERROR_NONE && is_close == true)
- TC_PRT("smartcard_channel_is_closed is success");
+ TC_PRT("smartcard_channel_is_closed successful");
else
TC_PRT("smartcard_channel_is_closed failed");
</pre>
ret = smartcard_channel_close(channel);
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard_channel_close is success");
+ TC_PRT("smartcard_channel_close successful");
else
TC_PRT("smartcard_channel_close failed : %d", ret);
</pre>
<li>Transmit an APDU command (as per ISO/IEC 7816-4) to the SE:
<pre class="prettyprint">
+int i;
+int ret;
+int resp_len;
+unsigned char *response = NULL;
+unsigned char command[] = {0x00, 0x01, 0x02, 0x03};
+
ret = smartcard_channel_transmit(channel, command, 4, &response, &resp_len);
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_channel_transmit is success");
+ TC_PRT("smartcard_channel_transmit successful");
TC_PRT("response is ");
for (i = 0; i < resp_len; i++)
TC_PRT("%x ", (int)response[i]);
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_channel_transmit_get_response is success");
+ TC_PRT("smartcard_channel_transmit_get_response successful");
TC_PRT("response is ");
for (i = 0; i < pLength; i++)
TC_PRT("%x ", (int)ptransmitResponse[i]);
ret = smartcard_initialize();
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard initialize success");
+ TC_PRT("smartcard initialize successful");
else
TC_PRT("smartcard initialize failed");</pre>
</li>
ret = smartcard_channel_transmit(channel, command, 4, &response, &resp_len);
if (ret == SMARTCARD_ERROR_NONE)
{
- TC_PRT("smartcard_channel_transmit is success");
+ TC_PRT("smartcard_channel_transmit successful");
TC_PRT("response is ");
for (i = 0; i < resp_len; i++)
TC_PRT("%x ", (int)response[i]);
ret = smartcard_deinitialize();
if (ret == SMARTCARD_ERROR_NONE)
- TC_PRT("smartcard deinitialize success");
+ TC_PRT("smartcard deinitialize successful");
else
TC_PRT("smartcard deinitialize failed");
</pre>
</script>
</body>
-</html>
\ No newline at end of file
+</html>