WSCT.JCSimulator
1.2.0
dotnet add package WSCT.JCSimulator --version 1.2.0
NuGet\Install-Package WSCT.JCSimulator -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WSCT.JCSimulator" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WSCT.JCSimulator" Version="1.2.0" />
<PackageReference Include="WSCT.JCSimulator" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WSCT.JCSimulator --version 1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WSCT.JCSimulator, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WSCT.JCSimulator@1.2.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WSCT.JCSimulator&version=1.2.0
#tool nuget:?package=WSCT.JCSimulator&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WSCT.JCSimulator
Public repository for WSCT GlobalPlatform project.
Goal
Enable the WSCT framework to communicate directly with a Java Card simulator.
Features
This project is currently a work in progress.
Java Card Simulator:
- Connect to the Java Card simulator using localhost and default port 9025
- Connect to a simulator using any other protocol than TCP/IP
Card management:
- Connect to the card
- Support PPS
- Retrieve ATR
- Disconnect from the card
T=0 transmission protocol: not yet implemented
T=1 transmission protocol:
- Negociate IFSC / IFSD
- Receive chained I-block
- Send chained I-block
- Handle transmission errors
APDU:
- Send APDU command
- Receive APDU response
Implementation for WSCT:
- ICardContext interface
- ICardChannel interface
- ICardContextLayer interface
- ICardChannelLayer interface
Architecture overview
---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
direction TB
namespace WSCT.JCSimulator.Wrapper {
class JcsClient
class IJcsConnection
class TcpConnection
}
IJcsConnection <-- JcsClient
IJcsConnection <|.. TcpConnection
namespace WSCT.Core {
class ICardContext
class ICardChannel
}
namespace WSCT.JCSimulator.Core {
class JcsCardContextCore
class JcsCardChannelCore
}
ICardContext <|.. JcsCardContextCore
ICardChannel <|.. JcsCardChannelCore
JcsCardChannelCore --> JcsClient
namespace WSCT.Stack {
class ICardContextLayer
class ICardChannelLayer
}
namespace WSCT.JCSimulator.Stack {
class JcsCardContextLayer
class JcsCardChannelLayer
}
ICardContextLayer <|.. JcsCardContextLayer
ICardChannelLayer <|.. JcsCardChannelLayer
ICardContext <|-- ICardContextLayer
ICardChannel <|-- ICardChannelLayer
JcsCardChannelLayer --> JcsCardChannelCore
Usage examples
Using the WSCT wrapper (LinqPad script)
var context = new JcsCardContextCore().ToObservable();
context.Establish().Dump("Establish");
context.ListReaders("").Dump("listReaders");
context.Readers.Dump();
var jcSimulatorClient = new JcsClient(new TcpConnection("127.0.0.1", 9025));
await jcSimulatorClient.ConnectToSimulatorAsync();
var channel = new JcsCardChannelCore(context, context.Readers.Last(), jcSimulatorClient);
channel.Connect(ShareMode.Exclusive, Protocol.Any)
.Dump("Connect");
byte[] atr = [];
channel.GetAttrib(Attrib.AtrString, ref atr);
atr.DumpHexa("ATR");
var capdu = new CommandAPDU("00 A4 04 00 00")
.Dump("C-APDU SELECT", collapseTo: 0);
var crp = new CommandResponsePair(capdu);
crp.Transmit(channel)
.Dump("transmit");
crp.RApdu.Dump("rapdu");
channel.Disconnect(Disposition.UnpowerCard)
.Dump("Disconnect");
context.Release()
.Dump("release");
Using the raw wrapper (LinqPad script)
var jcSimulatorClient = new JcsClient(new TcpConnection("127.0.0.1", 9025));
await jcSimulatorClient.ConnectToSimulatorAsync();
// **** Connect()
await jcSimulatorClient.SendAsync("F0 00 00 00".FromHexa().DumpHexa("D ▶ C Connect"));
var connectResult = await jcSimulatorClient.ReceiveDeviceResultAsync()
.DumpHexa("D ◀ C Connect Result");
var atr = connectResult[4..].DumpHexa("ATR");
// **** IFS
await jcSimulatorClient.SendIfsAsync(0xfe);
// **** SELECT Command
var apdu = new CommandAPDU("00 A4 04 00 00")
//var apdu = new CommandAPDU("00 A4 04 00 07 F0010203040001")
.Dump("C-APDU SELECT", collapseTo: 0);
await jcSimulatorClient.SendCommandAPDUAsync(apdu);
var responseApdu = await jcSimulatorClient.ReceiveResponseApduAsync()
.Dump("R-APDU");
// **** Disconnect()
await jcSimulatorClient.SendAsync("FE 00 00 00".FromHexa().DumpHexa("D ▶ C Connect"));
var disconnectResult = await jcSimulatorClient.ReceiveDeviceResultAsync()
.DumpHexa("D ◀ C Disconnect Result");
jcSimulatorClient.DisconnectFromSimulator();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- WSCT.Core (>= 6.7.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.