Simulate a smart card reader connected to a TB100 like smart card for exclusive use with WSCT core framework.
It's based on a port of an previously developed javacard applet: TB100 like card and some tweaks to simulate a T=0 javacard runtime environment.
Beeing developed in a hurry for teaching purposes during the covid-19, please don't complain if you can't find much (if any) unit tests ;-) .
"Do as I say, not as I do."
- SELECT
- CREATE FILE
- DELETE FILE
- GENERATE RANDOM
- READ BINARY
- WRITE BINARY
- ERASE
This framework aims to provide an API indentical to the JavaCard one for easy port of JavaCard applets to C#.
Current mocked JavaCard classes and methods are based my own needs so expect not to see all the JavaCard framework to be mocked.
javacard.framework
(in namespaceWSCT.Fake.JavaCard.Framework
)APDU
Applet
ISO7816
ISOException
JCSystem
Util
security
(in namespaceSecurity
)Cipher
Key
KeyBuilder
MessageDigest
RandomData
SecureRandom
Signature
- Copy the JavaCard code (
.java
files) to.cs
files. - Replace JavaCard
import
s with the correspondingusing
s of WSCT.Fake namespaces. - Replace
package
clauses withnamespace
clauses. - Replace
.length
by.Length
on java arrays. - Replace
static final
s withconst
forbyte
andshort
typed constants. - Replace
boolean
s withbool
s. - Remove
final
from method signatures. - REplace
ISO7816.
withJavaCard.ISO7816
(there's a conflict betweenWSCT.ISO7816
namespace andWSCT.Fake.JavaCard.ISO7816
class) - Enclose
(short)
cast where bit 31 (most significative bit) is set 1 in aunchecked(...)
clause. - In
install
method, remove the applet instanciation (the mechanism in not yet implemented) - Optionaly: add an attribute to suppress IDE1006 warning because JavaCard uses the camelCase coding style.
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "JavaCard")]
var FakeCard = new FakeJavaCard("F0 43 41 45 4E 42 01".FromHexa(),new EmvApplet())
HostedApplet[] hostedApplets =
{
new HostedApplet("F0 43 41 45 4E 42 01".FromHexa(),new EmvApplet()),
new HostedApplet("1PAY.SYS.DDF01".FromString(), new PseApplet())
};
var FakeCard = new FakeJavaCard(hostedApplets)