Skip to content

Commit

Permalink
SmartCardConnection.transmit() algorithm (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
dandrader authored Aug 11, 2023
1 parent c44d257 commit 293347e
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,8 @@ <h3><dfn>connect()</dfn> method</h3>
<li>Set |connection|.{{SmartCardConnection/[[comm]]}} to |comm|.
<li>Set |connection|.{{SmartCardConnection/[[context]]}} to
[=this=].
<li>Set |connection|.{{SmartCardConnection/[[activeProtocol]]}} to
|activeProtocol|.
<li>Set |result|["{{SmartCardConnectResult/connection}}"] to
|connection|.</li>
<li>If |activeProtocol| is a [=SmartCardProtocol/valid
Expand Down Expand Up @@ -895,6 +897,12 @@ <h2><dfn>SmartCardConnection</dfn> interface</h2>
<td>`null`</td>
<td>The {{SmartCardContext}} that created this instance.</td>
</tr>
<tr>
<td><dfn>[[\activeProtocol]]</dfn></td>
<td>0</td>
<td>The active protocol `DWORD`, as returned by the platform's
[[PCSC5]] implementation.</td>
</tr>
</table>
<section>
<h3><dfn>disconnect()</dfn> method</h3>
Expand Down Expand Up @@ -968,7 +976,60 @@ <h4><dfn>SmartCardDisposition</dfn> enum</h3>
</section>
<section>
<h3><dfn>transmit()</dfn> method</h3>
<div class="issue">Write an algorithm for this method.</div>
<p>The {{SmartCardConnection/transmit(sendBuffer)}} method steps
are:</p>
<ol>
<li>Let |promise:Promise| be [=a new promise=].</li>
<li>If
[=this=].{{SmartCardConnection/[[context]]}}.{{SmartCardContext/[[operationInProgress]]}}
is `true`, [=reject=] |promise| with a "{{InvalidStateError}}"
{{DOMException}} and return |promise|.</li>
<li>If [=this=].{{SmartCardConnection/[[comm]]}} is `null`, [=reject=]
|promise| with a "{{InvalidStateError}}" {{DOMException}} and return
|promise|.</li>
<li>If [=this=].{{SmartCardConnection/[[activeProtocol]]}} is not a
[=SmartCardProtocol/valid protocol value=], [=reject=] |promise|
with a "{{InvalidStateError}}" {{DOMException}} and return
|promise|.</li>
<li>Set
[=this=].{{SmartCardConnection/[[context]]}}.{{SmartCardContext/[[operationInProgress]]}}
to `true`.</li>
<li>Let |sendPci:SCARD_IO_HEADER| be the platform's [[PCSC5]]
`SCARD_IO_HEADER` corresponding to
[=this=].{{SmartCardConnection/[[activeProtocol]]}}.</li>
<li>Let |pcscSendBuffer:array of BYTE| be a [[PCSC5]] `BYTE[]`
containing |sendBuffer:BufferSource|.</li>
<li>Let |recvPci:SCARD_IO_HEADER| be the platform's `SCARD_IO_HEADER`
equivalent of empty or null.</li>
<li>Let |recvBuffer:array of BYTE| be a `BYTE[]` big enough to hold
the largest [[ISO7186-3]] extended response APDU (65538 bytes).</li>
<li>Let |recvLength:DWORD| be a `DWORD` set to `0`.</li>
<li>Run the following steps [=in parallel=]:
<ol>
<li>Call [=this=].{{SmartCardConnection/[[comm]]}}.`Transmit()`
with |sendPci|, |pcscSendBuffer|, |recvPci|, |recvBuffer| and
|recvLength| as arguments.</li>
<li>Let |responseCode:RESPONSECODE| be the returned
`RESPONSECODE`.</li>
<li>[=Queue a global task=] on the [=relevant global object=] of
[=this=] using the [=smart card task source=] which performs the
following steps:
<ol>
<li>Set
[=this=].{{SmartCardConnection/[[context]]}}.{{SmartCardContext/[[operationInProgress]]}}
to `false`.</li>
<li>If |responseCode| is not `SCARD_S_SUCCESS`, [=reject=]
|promise| with a {{DOMException}}
{{SmartCardError/corresponding}} to |responseCode| and abort
these steps.</li>
<li>[=Resolve=] |promise| with an {{ArrayBuffer}} containing
the first |recvLength| bytes of |recvBuffer|.</li>
</ol>
</li>
</ol>
</li>
<li>Return |promise|.</li>
</ol>
</section>
<section>
<h3><dfn>startTransaction()</dfn> method</h3>
Expand Down

0 comments on commit 293347e

Please sign in to comment.