Package com.aurelienpierre.sioul
Class Ccid
java.lang.Object
com.aurelienpierre.sioul.Ccid
A smart card's messages over USB (CCID, the USB Integrated Circuit(s) Cards
Interface Device class, revision 1.1, ยง6), for your security key plugged
into the phone (SecurityKeyLink.java). Pure Java over a
Ccid.Pipe, the
key's two bulk endpoints, so that android/jvm-checks runs it against a
stand-in reader.
- Messages: PC_to_RDR_IccPowerOn (0x62) answered by the card's ATR, PC_to_RDR_XfrBlock (0x6F) carrying one APDU, PC_to_RDR_IccPowerOff (0x63); each with a sequence number its answer must repeat, slot 0.
- Sent in packets of the endpoint's size, with a zero-length packet when a message fills its last packet exactly, so that the key knows it ended.
- A key waiting for a touch says so with a time extension (status
0x80), or stays silent: Sioul reads again, as long as
WAIT_MSat most (a YubiKey waits 15 seconds for a touch), while the band asks for the touch, so that no touch setting breaks the operation; a key unplugged meanwhile fails at once. Any other failure is said as a code, never bytes. - Nothing kept: each message's buffer is wiped once sent or read.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classThe key's answer that said nothing sensible, or a failure of its own: a code, never its bytes.(package private) static interfaceThe key's two bulk endpoints. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final byte(package private) static final intA message's header.(package private) static final intThe longest answer read: an extended APDU's, with room.private final intprivate final Ccid.Pipe(package private) static final byte(package private) static final byteprivate byte(package private) static final byte(package private) static final intOne bulk transfer at most.(package private) static final intHow long a key may keep Sioul waiting for an answer, a touch included: a YubiKey gives up waiting for one after 15 seconds; ten more as a margin.(package private) static final byte -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]exchange(byte type, byte[] data, byte expected) (package private) static byte[]message(byte type, byte[] data, byte sequence) The header and the data of one message to the key.(package private) voidpowerOff()The key powered off, its state with it.(package private) byte[]powerOn()The key powered on: its ATR.private byte[]receive(long until) One whole message from the key, its header first.private voidsend(byte[] message) (package private) byte[]transmit(byte[] apdu) One APDU to the key: its answer, status words included.
-
Field Details
-
TRANSFER_MS
One bulk transfer at most.- See Also:
-
WAIT_MS
How long a key may keep Sioul waiting for an answer, a touch included: a YubiKey gives up waiting for one after 15 seconds; ten more as a margin.- See Also:
-
HEADER
A message's header.- See Also:
-
LONGEST
The longest answer read: an extended APDU's, with room.- See Also:
-
POWER_ON
- See Also:
-
POWER_OFF
- See Also:
-
XFR_BLOCK
- See Also:
-
DATA_BLOCK
- See Also:
-
SLOT_STATUS
- See Also:
-
pipe
-
packet
-
sequence
-
-
Constructor Details
-
Ccid
Messages overpipe, whose endpoints takepacketbytes a packet.
-
-
Method Details
-
powerOn
The key powered on: its ATR.- Throws:
IOException
-
powerOff
The key powered off, its state with it.- Throws:
IOException
-
transmit
One APDU to the key: its answer, status words included. The APDU is the caller's to wipe.- Throws:
IOException
-
message
The header and the data of one message to the key. -
exchange
- Throws:
IOException
-
send
- Throws:
IOException
-
receive
One whole message from the key, its header first.- Throws:
IOException
-