Skip to content

Commit 2a4bd42

Browse files
add run python script
1 parent d8e33ce commit 2a4bd42

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<javacard jckit="${JCKIT}">
3737
<cap output="${cap.dir}/SecureApplet.cap"
3838
sources="${src.dir}/toys"
39-
classes="${class.dir}/SecureApplet"
39+
classes="${class.dir}/Secure"
4040
includes="${deps.secureapplet}"
4141
>
4242
<applet class="toys.SecureApplet" aid="B00B5111FF01"/>

run_sim.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import subprocess, os, sys
2+
3+
CURRENT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)))
4+
5+
# TODO: get from build
6+
aids = {
7+
"Teapot": "B00B5111CA01",
8+
"Secure": "B00B5111FF01",
9+
"MemoryCard": "B00B5111CB01",
10+
"BlindOracle": "B00B5111CE01",
11+
"SingleUseKey": "B00B5111CD01"
12+
}
13+
14+
if __name__ == '__main__':
15+
if len(sys.argv) == 1:
16+
print("No arguments provided.")
17+
print(f"Usage: {sys.argv[0]} applet [aid]")
18+
print(f"Examples: {sys.argv[0]} BlindOracle")
19+
print(f" {sys.argv[0]} BlindOracle B00B5111CE01")
20+
sys.exit(1)
21+
applet = sys.argv[1]
22+
aid = None
23+
if len(sys.argv) >= 3:
24+
aid = sys.argv[2]
25+
if aid is None and applet not in aids:
26+
print("Applet not found")
27+
sys.exit(1)
28+
args = ["java", "-jar", "simulator.jar",
29+
"-p", "21111",
30+
"-a", aids[applet],
31+
"-c", f"toys.{applet}Applet",
32+
"-u", f"file://{CURRENT_DIR}/build/classes/{applet}/"
33+
]
34+
while True:
35+
print("Starting simulator...")
36+
proc = subprocess.run(args)

0 commit comments

Comments
 (0)