File: smart_card_provider_private.idl

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (268 lines) | stat: -rw-r--r-- 8,780 bytes parent folder | download | duplicates (6)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Use this API to give the browser access to a winscard.h[1] compatible
// PC/SC[2] implementation, which will be the backend of the browser's
// Web Smart Card API[3].
//
// [1] https://pcsclite.apdu.fr/api/winscard_8h.html
// [2] https://en.wikipedia.org/wiki/PC/SC
// [3] https://github.com/WICG/web-smart-card/blob/main/README.md#web-idl
//
// TODO(crbug.com/40247152): Add API for the remaining SCard* functions.
[platforms=("chromeos"),
 implemented_in="chrome/browser/chromeos/extensions/smart_card_provider_private/smart_card_provider_private_api.h"]
namespace smartCardProviderPrivate {

  // PC/SC error codes we can expect to hit (thus a non-exhaustive list).
  // UNKNOWN means an SCARD error code that is not mapped in this enum (and
  // thus should probably be added here).
  enum ResultCode {
    SUCCESS,
    REMOVED_CARD,
    RESET_CARD,
    UNPOWERED_CARD,
    UNRESPONSIVE_CARD,
    UNSUPPORTED_CARD,
    READER_UNAVAILABLE,
    SHARING_VIOLATION,
    NOT_TRANSACTED,
    NO_SMARTCARD,
    PROTO_MISMATCH,
    SYSTEM_CANCELLED,
    NOT_READY,
    CANCELLED,
    INSUFFICIENT_BUFFER,
    INVALID_HANDLE,
    INVALID_PARAMETER,
    INVALID_VALUE,
    NO_MEMORY,
    TIMEOUT,
    UNKNOWN_READER,
    UNSUPPORTED_FEATURE,
    NO_READERS_AVAILABLE,
    SERVICE_STOPPED,
    NO_SERVICE,
    COMM_ERROR,
    INTERNAL_ERROR,
    UNKNOWN_ERROR,
    SERVER_TOO_BUSY,
    UNEXPECTED,
    SHUTDOWN,
    UNKNOWN
  };

  // Maps to the SCARD_SHARE_* values defined in the winscard.h API.
  enum ShareMode {
    SHARED,
    EXCLUSIVE,
    DIRECT
  };

  // What the reader should do with the card inserted in it.
  enum Disposition {
    // SCARD_LEAVE_CARD - Do nothing.
    LEAVE_CARD,
    // SCARD_RESET_CARD - Reset the card (warm reset).
    RESET_CARD,
    // SCARD_UNPOWER_CARD - Power down the card (cold reset).
    UNPOWER_CARD,
    // SCARD_EJECT_CARD - Eject the card.
    EJECT_CARD
  };

  enum ConnectionState {
    // SCARD_ABSENT
    ABSENT,
    // SCARD_PRESENT
    PRESENT,
    // SCARD_SWALLOWED
    SWALLOWED,
    // SCARD_POWERED
    POWERED,
    // SCARD_NEGOTIABLE
    NEGOTIABLE,
    // SCARD_SPECIFIC
    SPECIFIC
  };

  // Maps to the SCARD_STATE_* flags defined in the winscard.h API.
  dictionary ReaderStateFlags {
    boolean? unaware;
    boolean? ignore;
    boolean? changed;
    boolean? unknown;
    boolean? unavailable;
    boolean? empty;
    boolean? present;
    boolean? exclusive;
    boolean? inuse;
    boolean? mute;
    boolean? unpowered;
  };

  // Maps to the SCARD_PROTOCOL_* flags defined in the winscard.h API.
  dictionary Protocols {
    boolean? t0;
    boolean? t1;
    boolean? raw;
  };

  // Maps to the SCARD_PROTOCOL_* values defined in the winscard.h API.
  enum Protocol {
    UNDEFINED,
    T0,
    T1,
    RAW
  };

  dictionary ReaderStateIn {
    DOMString reader;
    ReaderStateFlags currentState;
    // Number of card insertion and removal events that happened in this reader,
    // as known by the application.
    long currentCount;
  };

  dictionary ReaderStateOut {
    DOMString reader;
    ReaderStateFlags eventState;
    // The actual number of card insertion and removal events that happened in
    // this reader.
    // Set to zero if not supported.
    long eventCount;
    ArrayBuffer atr;
  };

  dictionary Timeout {
    // If absent, it means "infinite" or "never timeout"
    long? milliseconds;
  };

  interface Events {
    // Browser requested a SCardEstablishContext call.
    // Extension must report the result to the browser by calling
    // reportEstablishContextResult.
    [maxListeners=1] static void onEstablishContextRequested(long requestId);

    // Browser requested a SCardReleaseContext call.
    // Extension must report the result to the browser by calling
    // reportReleaseContextResult.
    [maxListeners=1] static void onReleaseContextRequested(long requestId,
        long scardContext);

    // Browser requested a SCardListReaders call.
    // Extension must report the result to the browser by calling
    // reportListReadersResult.
    [maxListeners=1] static void onListReadersRequested(long requestId,
        long scardContext);

    // Browser requested a SCardGetStatusChange call.
    // Extension must report the result to the browser by calling
    // reportGetStatusChangeResult.
    [maxListeners=1] static void onGetStatusChangeRequested(long requestId,
        long scardContext,
        Timeout timeout,
        ReaderStateIn[] readerStates);

    // Browser requested a SCardCancel call.
    // Extension must report the result to the browser by calling
    // reportPlainResult.
    [maxListeners=1] static void onCancelRequested(long requestId,
        long scardContext);

    // Browser requested a SCardConnect call.
    // Extension must report the result to the browser by calling
    // reportConnectResult.
    [maxListeners=1] static void onConnectRequested(long requestId,
        long scardContext,
        DOMString reader,
        ShareMode shareMode,
        Protocols preferredProtocols);

    // Browser requested a SCardDisconnect call.
    // Extension must report the result to the browser by calling
    // reportPlainResult.
    [maxListeners=1] static void onDisconnectRequested(long requestId,
        long scardHandle, Disposition disposition);

    // Browser requested a SCardTransmit call.
    // Extension must report the result to the browser by calling
    // reportDataResult.
    [maxListeners=1] static void onTransmitRequested(long requestId,
        long scardHandle, Protocol protocol, ArrayBuffer data);

    // Browser requested a SCardControl call.
    // Extension must report the result to the browser by calling
    // reportDataResult.
    [maxListeners=1] static void onControlRequested(long requestId,
        long scardHandle, long controlCode, ArrayBuffer data);

    // Browser requested a SCardGetAttrib call.
    // Extension must report the result to the browser by calling
    // reportDataResult.
    [maxListeners=1] static void onGetAttribRequested(long requestId,
        long scardHandle, long attribId);

    // Browser requested a SCardSetAttrib call.
    // Extension must report the result to the browser by calling
    // reportPlainResult.
    [maxListeners=1] static void onSetAttribRequested(long requestId,
        long scardHandle, long attribId, ArrayBuffer data);

    // Browser requested a SCardStatus call.
    // Extension must report the result to the browser by calling
    // reportStatusResult.
    [maxListeners=1] static void onStatusRequested(long requestId,
        long scardHandle);

    // Browser requested a SCardBeginTransaction call.
    // Extension must report the result to the browser by calling
    // reportPlainResult.
    [maxListeners=1] static void onBeginTransactionRequested(long requestId,
        long scardHandle);

    // Browser requested a SCardEndTransaction call.
    // Extension must report the result to the browser by calling
    // reportPlainResult.
    [maxListeners=1] static void onEndTransactionRequested(long requestId,
        long scardHandle, Disposition disposition);
  };

  interface Functions {
      // Reports the result of a SCardEstablishContext call.
      static void reportEstablishContextResult(long requestId,
          long scardContext, ResultCode resultCode);

      // Reports the result of a SCardReleaseContext call.
      static void reportReleaseContextResult(long requestId,
          ResultCode resultCode);

      // Reports the result of a SCardListReaders call.
      static void reportListReadersResult(long requestId,
          DOMString[] readers, ResultCode resultCode);

      // Reports the result of a SCardGetStatusChange call.
      static void reportGetStatusChangeResult(long requestId,
          ReaderStateOut[] readerStates, ResultCode resultCode);

      // Reports the result of a call which doesn't send back any other
      // information.
      static void reportPlainResult(long requestId,
          ResultCode resultCode);

      // Reports the result of a SCardConnect call.
      static void reportConnectResult(long requestId, long scardHandle,
          Protocol activeProtocol, ResultCode resultCode);

      // Reports the result of a call that sends back data on success.
      static void reportDataResult(long requestId, ArrayBuffer data,
          ResultCode resultCode);

      // Reports the result of a SCardStatus call.
      static void reportStatusResult(long requestId, DOMString readerName,
          ConnectionState state, Protocol protocol, ArrayBuffer atr,
          ResultCode resultCode);
  };
};