2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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.
18 using System.Runtime.InteropServices;
20 internal static partial class Interop
22 internal static partial class Smartcard
24 //capi-network-smartcard-0.0.6-2.1.armv7l.rpm
26 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_initialize")]
27 internal static extern int Initialize();
28 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_deinitialize")]
29 internal static extern int Deinitialize();
30 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_get_readers")]
31 internal static extern int GetReaders(out IntPtr readers, out int len);
33 internal static class Reader
35 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_get_name")]
36 internal static extern int ReaderGetName(int reader, out IntPtr readerName);
37 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_is_secure_element_present")]
38 internal static extern int ReaderIsSecureElementPresent(int reader, out bool present);
39 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_open_session")]
40 internal static extern int ReaderOpenSession(int reader, out int session);
41 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_reader_close_sessions")]
42 internal static extern int ReaderCloseSessions(int reader);
45 internal static class Session
47 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_get_reader")]
48 internal static extern int SessionGetReader(int session, out int reader);
49 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_get_atr")]
50 internal static extern int SessionGetAtr(int session, out IntPtr atr, out int len);
51 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_close")]
52 internal static extern int SessionClose(int session);
53 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_is_closed")]
54 internal static extern int SessionIsClosed(int session, out bool closed);
55 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_close_channels")]
56 internal static extern int SessionCloseChannels(int session);
57 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_open_basic_channel")]
58 internal static extern int SessionOpenBasicChannel(int session, byte[] aid, int aidLen, byte p2, out int channel);
59 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_session_open_logical_channel")]
60 internal static extern int SessionOpenLogicalChannel(int session, byte[] aid, int aidLen, byte p2, out int channel);
63 internal static class Channel
65 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_close")]
66 internal static extern int ChannelClose(int channel);
67 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_is_basic_channel")]
68 internal static extern int ChannelIsBasicChannel(int channel, out bool basicChannel);
69 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_is_closed")]
70 internal static extern int ChannelIsClosed(int channel, out bool closed);
71 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_get_select_response")]
72 internal static extern int ChannelGetSelectResponse(int channel, out IntPtr selectResp, out int len);
73 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_get_session")]
74 internal static extern int ChannelGetSession(int channel, out int session);
75 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_transmit")]
76 internal static extern int ChannelTransmit(int channel, byte[] cmd, int cmdLen, out IntPtr resp, out int len);
77 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_transmit_retrieve_response")]
78 internal static extern int ChannelTransmitRetrieveResponse(int channel, out IntPtr name, out int len);
79 [DllImport(Libraries.Smartcard, EntryPoint = "smartcard_channel_select_next")]
80 internal static extern int ChannelSelectNext(int channel, out bool success);