-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.html
654 lines (499 loc) · 43.4 KB
/
api.html
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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>6. API — LEIA 0.2.2 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="http://wavedrom.com/skins/default.js"></script>
<script src="http://wavedrom.com/wavedrom.min.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="7. Publications" href="publi.html" />
<link rel="prev" title="5. Firmware Doc" href="c/test.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> LEIA
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Table of Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="target.html">1. About the LEIA project</a></li>
<li class="toctree-l1"><a class="reference internal" href="installation.html">2. Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">3. Quickstart</a></li>
<li class="toctree-l1"><a class="reference internal" href="hard.html">4. Hardware</a></li>
<li class="toctree-l1"><a class="reference internal" href="c/test.html">5. Firmware</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">6. Python API</a></li>
<li class="toctree-l1"><a class="reference internal" href="publi.html">7. Publications</a></li>
<li class="toctree-l1"><a class="reference internal" href="roadmap.html">8. Roadmap</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">LEIA</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home"></a> »</li>
<li><span class="section-number">6. </span>API</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/api.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<style>
/* CSS overrides for sphinx_rtd_theme */
/* 24px margin */
.nbinput.nblast.container,
.nboutput.nblast.container {
margin-bottom: 19px; /* padding has already 5px */
}
/* ... except between code cells! */
.nblast.container + .nbinput.container {
margin-top: -19px;
}
.admonition > p:before {
margin-right: 4px; /* make room for the exclamation icon */
}
/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */
.math {
text-align: unset;
}
</style>
<div class="section" id="api">
<span id="id1"></span><h1><span class="section-number">6. </span>API<a class="headerlink" href="#api" title="Permalink to this headline">¶</a></h1>
<span class="target" id="module-smartleia"></span><p>Here is detailed the python API of the <cite>smartleia</cite> package.</p>
<dl class="py class">
<dt id="smartleia.TriggerPoints">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">TriggerPoints</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#TriggerPoints"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.TriggerPoints" title="Permalink to this definition">¶</a></dt>
<dd><p>Class utility to reference the trigger points available.</p>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_GET_ATR_PRE">
<code class="sig-name descname"><span class="pre">TRIG_GET_ATR_PRE</span></code><em class="property"> <span class="pre">=</span> <span class="pre">1</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_GET_ATR_PRE" title="Permalink to this definition">¶</a></dt>
<dd><p>Point before getting the ATR.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_GET_ATR_POST">
<code class="sig-name descname"><span class="pre">TRIG_GET_ATR_POST</span></code><em class="property"> <span class="pre">=</span> <span class="pre">2</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_GET_ATR_POST" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just after the ATR has been received.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_PRE_SEND_APDU_SHORT_T0">
<code class="sig-name descname"><span class="pre">TRIG_PRE_SEND_APDU_SHORT_T0</span></code><em class="property"> <span class="pre">=</span> <span class="pre">4</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_PRE_SEND_APDU_SHORT_T0" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just before sending a simple APDU in T=0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_PRE_SEND_APDU_FRAGMENTED_T0">
<code class="sig-name descname"><span class="pre">TRIG_PRE_SEND_APDU_FRAGMENTED_T0</span></code><em class="property"> <span class="pre">=</span> <span class="pre">8</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_PRE_SEND_APDU_FRAGMENTED_T0" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just before sending a fragmented APDU in T=0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_PRE_SEND_APDU_T1">
<code class="sig-name descname"><span class="pre">TRIG_PRE_SEND_APDU_T1</span></code><em class="property"> <span class="pre">=</span> <span class="pre">16</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_PRE_SEND_APDU_T1" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just before sending an APDU in T=1.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_PRE_SEND_APDU">
<code class="sig-name descname"><span class="pre">TRIG_PRE_SEND_APDU</span></code><em class="property"> <span class="pre">=</span> <span class="pre">28</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_PRE_SEND_APDU" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just before sending an APDU</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_POST_RESP_T0">
<code class="sig-name descname"><span class="pre">TRIG_POST_RESP_T0</span></code><em class="property"> <span class="pre">=</span> <span class="pre">64</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_POST_RESP_T0" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just before receiving a RESP in T=0.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_POST_RESP_T1">
<code class="sig-name descname"><span class="pre">TRIG_POST_RESP_T1</span></code><em class="property"> <span class="pre">=</span> <span class="pre">128</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_POST_RESP_T1" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just before receiving a RESP in T=1.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_POST_RESP">
<code class="sig-name descname"><span class="pre">TRIG_POST_RESP</span></code><em class="property"> <span class="pre">=</span> <span class="pre">192</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_POST_RESP" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just before receiving a RESP</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_IRQ_PUTC">
<code class="sig-name descname"><span class="pre">TRIG_IRQ_PUTC</span></code><em class="property"> <span class="pre">=</span> <span class="pre">256</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_IRQ_PUTC" title="Permalink to this definition">¶</a></dt>
<dd><p>Point just after sending a byte through the ISO7816 interface.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.TriggerPoints.TRIG_IRQ_GETC">
<code class="sig-name descname"><span class="pre">TRIG_IRQ_GETC</span></code><em class="property"> <span class="pre">=</span> <span class="pre">512</span></em><a class="headerlink" href="#smartleia.TriggerPoints.TRIG_IRQ_GETC" title="Permalink to this definition">¶</a></dt>
<dd><p>Point juster afted a byte has been received through the ISO7816 interface.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="smartleia.T">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">T</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#T"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.T" title="Permalink to this definition">¶</a></dt>
<dd><p>ISO7816 protocol selection.</p>
<dl class="py attribute">
<dt id="smartleia.T.AUTO">
<code class="sig-name descname"><span class="pre">AUTO</span></code><em class="property"> <span class="pre">=</span> <span class="pre">-1</span></em><a class="headerlink" href="#smartleia.T.AUTO" title="Permalink to this definition">¶</a></dt>
<dd><p>The protocol is negotiated.</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.T.T0">
<code class="sig-name descname"><span class="pre">T0</span></code><em class="property"> <span class="pre">=</span> <span class="pre">0</span></em><a class="headerlink" href="#smartleia.T.T0" title="Permalink to this definition">¶</a></dt>
<dd><p>The protocol is T=0</p>
</dd></dl>
<dl class="py attribute">
<dt id="smartleia.T.T1">
<code class="sig-name descname"><span class="pre">T1</span></code><em class="property"> <span class="pre">=</span> <span class="pre">1</span></em><a class="headerlink" href="#smartleia.T.T1" title="Permalink to this definition">¶</a></dt>
<dd><p>The protocol is T=1</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt id="smartleia.Triggers">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">Triggers</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#Triggers"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.Triggers" title="Permalink to this definition">¶</a></dt>
<dd><p>An enumeration.</p>
</dd></dl>
<dl class="py class">
<dt id="smartleia.TriggerStrategy">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">TriggerStrategy</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">delay</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">single</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">point_list</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#TriggerStrategy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.TriggerStrategy" title="Permalink to this definition">¶</a></dt>
<dd><dl class="field-list simple">
<dt class="field-odd">Variables</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>delay</strong> (<em>int</em>) – the delay between event detection and effective trig on GPIO in milliseconds.</p></li>
<li><p><strong>point_list</strong> (<em>list</em><em>[</em><em>int</em><em>]</em>) – the list of events to match.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="smartleia.create_APDU_from_bytes">
<code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">create_APDU_from_bytes</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">_bytes</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#create_APDU_from_bytes"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.create_APDU_from_bytes" title="Permalink to this definition">¶</a></dt>
<dd><p>Create an <a class="reference internal" href="#smartleia.APDU" title="smartleia.APDU"><code class="xref py py-class docutils literal notranslate"><span class="pre">APDU</span></code></a> instance from a list of bytes.</p>
<p class="rubric">Example</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">create_APDU_from_bytes</span><span class="p">([</span><span class="mh">0x00</span><span class="p">,</span><span class="mh">0x01</span><span class="p">,</span><span class="mh">0x02</span><span class="p">,</span><span class="mh">0x03</span><span class="p">,</span><span class="mh">0x04</span><span class="p">,</span><span class="mh">0x05</span><span class="p">,</span><span class="mh">0x06</span><span class="p">,</span><span class="mh">0x07</span><span class="p">,</span><span class="mh">0x08</span><span class="p">,</span><span class="mh">0x09</span><span class="p">])</span>
<span class="go">APDU(cla=0x00, ins=0x01, p1=0x02, p2=0x03, lc=0x04, data=[0x05, 0x06, 0x07, 0x08], le=0x09, send_le=1)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#smartleia.APDU" title="smartleia.APDU"><code class="xref py py-class docutils literal notranslate"><span class="pre">APDU</span></code></a></p>
</dd>
</dl>
</dd></dl>
<dl class="py class">
<dt id="smartleia.APDU">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">APDU</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cla</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ins</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p1</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">p2</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lc</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">le</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">send_le</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#APDU"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.APDU" title="Permalink to this definition">¶</a></dt>
<dd><p>Object for representing an APDU.</p>
<dl class="field-list simple">
<dt class="field-odd">Variables</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cla</strong> (<em>ctypes.c_uint8</em>) – the <cite>CLA</cite> field of the APDU.</p></li>
<li><p><strong>ins</strong> (<em>ctypes.c_uint8</em>) – the <cite>INS</cite> field of the APDU.</p></li>
<li><p><strong>p1</strong> (<em>ctypes.c_uint8</em>) – the <cite>P1</cite> field of the APDU.</p></li>
<li><p><strong>p2</strong> (<em>ctypes.c_uint8</em>) – the <cite>P2</cite> field of the APDU.</p></li>
<li><p><strong>lc</strong> (<em>ctypes.c_uint16</em>) – the <cite>Lc</cite> field of the APDU.</p></li>
<li><p><strong>le</strong> (<em>ctypes.c_uint32</em>) – the <cite>Le</cite> field of the APDU.</p></li>
<li><p><strong>send_le</strong> (<em>ctypes.c_uint8</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>data</strong> (<em>list</em><em>[</em><em>int</em><em>]</em>) – the <cite>data</cite> field of the APDU.</p></li>
</ul>
</dd>
</dl>
<p>Create an APDU structure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cla</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – the <cite>CLA</cite> field of the APDU.</p></li>
<li><p><strong>ins</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – the <cite>INS</cite> field of the APDU.</p></li>
<li><p><strong>p1</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – the <cite>P1</cite> field of the APDU.</p></li>
<li><p><strong>p2</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – the <cite>P2</cite> field of the APDU.</p></li>
<li><p><strong>lc</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – the <cite>Lc</cite> (data length) field of the APDU.</p></li>
<li><p><strong>le</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – the <cite>Le</cite> (expected length) field of the APDU.</p></li>
<li><p><strong>send_le</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – TODO.</p></li>
<li><p><strong>data</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">List</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]]) – the list of bytes to send.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py class">
<dt id="smartleia.RESP">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">RESP</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sw1</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">sw2</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">data</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">delta_t</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">delta_t_answer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#RESP"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.RESP" title="Permalink to this definition">¶</a></dt>
<dd><p>This class is used to represent an RESP.</p>
<dl class="field-list simple">
<dt class="field-odd">Variables</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>sw1</strong> (<em>ctypes.c_uint8</em>) – The value of <cite>SW1</cite> field.</p></li>
<li><p><strong>sw2</strong> (<em>ctypes.c_uint8</em>) – The value of <cite>SW2</cite> field.</p></li>
<li><p><strong>le</strong> (<em>ctypes.c_uint32</em>) – The length of the data.</p></li>
<li><p><strong>data</strong> (<em>list</em><em>[</em><em>byte</em><em>]</em>) – The value of the <cite>data</cite> field.</p></li>
</ul>
</dd>
</dl>
<p>Create an RESP structure.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>le</strong> (<em>int</em>) – the <cite>Le</cite> field of the RESP.</p></li>
<li><p><strong>sw1</strong> (<em>int</em>) – the <cite>SW1</cite> field of the RESP.</p></li>
<li><p><strong>sw2</strong> (<em>int</em>) – the <cite>SW2</cite> field of the RESP.</p></li>
<li><p><strong>delta_t</strong> (<em>int</em>) – total time for the APDU.</p></li>
<li><p><strong>delta_t_answer</strong> (<em>int</em>) – answer time for the APDU.</p></li>
<li><p><strong>data</strong> (<em>list</em><em>[</em><em>int</em><em>]</em>) – the list of bytes received.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py class">
<dt id="smartleia.ATR">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">ATR</span></code><a class="reference internal" href="_modules/smartleia.html#ATR"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.ATR" title="Permalink to this definition">¶</a></dt>
<dd><p>This class is used to represent an ATR.</p>
<dl class="field-list simple">
<dt class="field-odd">Variables</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>ts</strong> (<em>ctypes.c_uint8</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>t0</strong> (<em>ctypes.c_uint8</em>) – Description of <cite>attr2</cite>.</p></li>
<li><p><strong>ta</strong> (<em>ctypes.c_uint8</em><em>[</em><em>4</em><em>]</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>tb</strong> (<em>ctypes.c_uint8</em><em>[</em><em>4</em><em>]</em>) – Description of <cite>attr2</cite>.</p></li>
<li><p><strong>tc</strong> (<em>ctypes.c_uint8</em><em>[</em><em>4</em><em>]</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>td</strong> (<em>ctypes.c_uint8</em><em>[</em><em>4</em><em>]</em>) – Description of <cite>attr2</cite>.</p></li>
<li><p><strong>h</strong> (<em>ctypes.c_uint8</em><em>[</em><em>16</em><em>]</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>t_mask</strong> (<em>ctypes.c_uint8</em><em>[</em><em>4</em><em>]</em>) – Description of <cite>attr2</cite>.</p></li>
<li><p><strong>h_num</strong> (<em>ctypes.c_uint8</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>tck</strong> (<em>ctypes.c_uint8</em>) – Description of <cite>attr2</cite>.</p></li>
<li><p><strong>tck_present</strong> (<em>ctypes.c_uint8</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>D_i_curr</strong> (<em>ctypes.c_uint32</em>) – Description of <cite>attr2</cite>.</p></li>
<li><p><strong>F_i_curr</strong> (<em>ctypes.c_uint32</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>f_max_curr</strong> (<em>ctypes.c_uint32</em>) – Description of <cite>attr2</cite>.</p></li>
<li><p><strong>T_protocol_curr</strong> (<em>ctypes.c_uint8</em>) – Description of <cite>attr1</cite>.</p></li>
<li><p><strong>ifsc</strong> (<em>ctypes.c_uint8</em>) – Description of <cite>attr2</cite>.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py class">
<dt id="smartleia.LEIA">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">smartleia.</span></code><code class="sig-name descname"><span class="pre">LEIA</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">device</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">serial_factory</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">auto_open</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA" title="Permalink to this definition">¶</a></dt>
<dd><p>This class connects to a LEIA board and provides an access to all the device functionnality.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>device</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code>) – the serial port to use with LEIA (like /dev/ttyUSB0).</p>
</dd>
<dt class="field-even">Raises</dt>
<dd class="field-even"><p><strong>Exception</strong> – if no serial port is provided.</p>
</dd>
</dl>
<dl class="py method">
<dt id="smartleia.LEIA.reset">
<code class="sig-name descname"><span class="pre">reset</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.reset"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Reset LEIA.</p>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.open">
<code class="sig-name descname"><span class="pre">open</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.open"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.open" title="Permalink to this definition">¶</a></dt>
<dd><p>Open LEIA.</p>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.configure_smartcard">
<code class="sig-name descname"><span class="pre">configure_smartcard</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">protocol_to_use</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ETU_to_use</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">freq_to_use</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">negotiate_pts</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">negotiate_baudrate</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.configure_smartcard"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.configure_smartcard" title="Permalink to this definition">¶</a></dt>
<dd><p>Configure a smartcard connection.</p>
<p>Method to configure a smartcard.
By default, the smartcard reader will negociate with the smartcard the mode (T=0 or T=1), the ETU and
the frequence to use.
It is possible to:</p>
<ul class="simple">
<li><p>force a mode (by setting protocol_to_use to 0 for T=0, and to 1 for T=1)</p></li>
<li><p>force an ETU (by setting the ETU_to_use parameter)</p></li>
<li><p>force a frequence (by setting the freq_to_use parameter)</p></li>
</ul>
<p class="rubric">Example</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">leia</span><span class="o">.</span><span class="n">configure_smartcard</span><span class="p">(</span><span class="n">T</span><span class="o">.</span><span class="n">T0</span><span class="p">,</span> <span class="n">ETU_to_use</span><span class="o">=</span><span class="mi">372</span><span class="p">)</span>
</pre></div>
</div>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>protocol_to_use</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<a class="reference internal" href="#smartleia.T" title="smartleia.T"><code class="xref py py-class docutils literal notranslate"><span class="pre">T</span></code></a>]) – The protocol to use (0: T=0, 1: T=1).</p></li>
<li><p><strong>ETU_to_use</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – The ETU value to force. If None, will be negociated (or default will be used).</p></li>
<li><p><strong>freq_to_use</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]) – The ISO7816 clock frequency to use. If None, will be negociated (or default will be used).</p></li>
<li><p><strong>negotiate_pts</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>]) – if LEIA can try to negotiate the PTS.</p></li>
<li><p><strong>negotiate_baudrate</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Optional</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code>]) – if LEIA can negotiate the baudrate. There is not impact if <cite>ETU_to_use</cite> and <cite>freq_to_use</cite> are set.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.get_trigger_strategy">
<code class="sig-name descname"><span class="pre">get_trigger_strategy</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">SID</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.get_trigger_strategy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.get_trigger_strategy" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the strategy N°SID.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>SID</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – The trigger strategy’s ID to get.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The trigger strategy N°SID.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#smartleia.TriggerStrategy" title="smartleia.TriggerStrategy">TriggerStrategy</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.set_trigger_strategy">
<code class="sig-name descname"><span class="pre">set_trigger_strategy</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">SID</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">point_list</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">delay</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">single</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.set_trigger_strategy"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.set_trigger_strategy" title="Permalink to this definition">¶</a></dt>
<dd><p>Set and activate a trigger strategy.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>SID</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – the strategy bank ID to use.</p></li>
<li><p><strong>point_list</strong> (<code class="xref py py-data docutils literal notranslate"><span class="pre">Union</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>, <code class="xref py py-class docutils literal notranslate"><span class="pre">List</span></code>[<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>]]) – the sequence to match for the trigger.</p></li>
<li><p><strong>delay</strong> (<code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code>) – the delay (in milliseconds) between the moment of the detection and the moment where the trigger is actually set high.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.get_timers">
<code class="sig-name descname"><span class="pre">get_timers</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.get_timers"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.get_timers" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <cite>timers</cite> of the last command.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The <cite>Timer</cite> object.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>Timers</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.get_ATR">
<code class="sig-name descname"><span class="pre">get_ATR</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.get_ATR"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.get_ATR" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <cite>ATR</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>The <cite>ATR</cite> object.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p><a class="reference internal" href="#smartleia.ATR" title="smartleia.ATR">ATR</a></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.is_card_inserted">
<code class="sig-name descname"><span class="pre">is_card_inserted</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.is_card_inserted"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.is_card_inserted" title="Permalink to this definition">¶</a></dt>
<dd><p>Return <cite>True</cite> if a smartcard is inserted in LEIA.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-class docutils literal notranslate"><span class="pre">bool</span></code></p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><cite>True</cite> if a smartcard is inserted, else <cite>False</cite>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.dfu">
<code class="sig-name descname"><span class="pre">dfu</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.dfu"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.dfu" title="Permalink to this definition">¶</a></dt>
<dd><p>Reboot LEIA in DFU mode.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.flasher">
<code class="sig-name descname"><span class="pre">flasher</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.flasher"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.flasher" title="Permalink to this definition">¶</a></dt>
<dd><p>Reboot LEIA in funcard flasher mode.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.smartreader">
<code class="sig-name descname"><span class="pre">smartreader</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.smartreader"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.smartreader" title="Permalink to this definition">¶</a></dt>
<dd><p>Reboot LEIA in funcard smartreader mode.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><code class="xref py py-obj docutils literal notranslate"><span class="pre">None</span></code></p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="smartleia.LEIA.send_APDU">
<code class="sig-name descname"><span class="pre">send_APDU</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">apdu</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/smartleia.html#LEIA.send_APDU"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#smartleia.LEIA.send_APDU" title="Permalink to this definition">¶</a></dt>
<dd><p>Send an <cite>APDU</cite>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>apdu</strong> (<a class="reference internal" href="#smartleia.APDU" title="smartleia.APDU"><code class="xref py py-class docutils literal notranslate"><span class="pre">APDU</span></code></a>) – The <cite>APDU</cite> object.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>The <cite>RESP</cite> object.</p>
</dd>
<dt class="field-odd">Return type</dt>
<dd class="field-odd"><p><a class="reference internal" href="#smartleia.RESP" title="smartleia.RESP">RESP</a></p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</div>
<script type="text/javascript">
function init() {
WaveDrom.ProcessAll();
}
window.onload = init;
</script>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="publi.html" class="btn btn-neutral float-right" title="7. Publications" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
<a href="c/test.html" class="btn btn-neutral float-left" title="5. Firmware Doc" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2019-2020, ANSSI.
</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>