From 452e2d4716952e65045af3ae8dbd71db62df150e Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 7 Nov 2023 08:40:28 +0100 Subject: [PATCH] Add tests for the `SecretApplet` --- .vscode/tasks.json | 12 +++++++++ hwb1/tests/SecretApplet.txt | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 hwb1/tests/SecretApplet.txt diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 15176fc..1c0c04f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -46,6 +46,18 @@ }, "problemMatcher": [] }, + { + "label": "Test SecretApplet", + "type": "shell", + "command": "${workspaceFolder}/scripts/test.cmd", + "options": { + "env": { + "PACKAGE": "hwb1", + "APPLET": "SecretApplet" + } + }, + "problemMatcher": [] + }, { "label": "Delete Applet", "type": "shell", diff --git a/hwb1/tests/SecretApplet.txt b/hwb1/tests/SecretApplet.txt new file mode 100644 index 0000000..1e86a09 --- /dev/null +++ b/hwb1/tests/SecretApplet.txt @@ -0,0 +1,49 @@ +// test my applet +establish_context +enable_trace +enable_timer +card_connect +// select +send_apdu -sc 0 -APDU 00A40400080102030405060809 + +// Triggering Unsupported CLA Error +send_apdu -sc 0 -APDU 9001000000 + +// Triggering Unsupported Instruction Error +send_apdu -sc 0 -APDU 8001000000 + +// Sending Too Much Data for Encryption +send_apdu -sc 0 -APDU 80420000410102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F4041 + +// Send Incorrectly Unpadded Data +send_apdu -sc 0 -APDU 804200000B48656C6C6F20576F726C64 + +// Encrypt Short Message +send_apdu -sc 0 -APDU 804200001048656C6C6F2C206D7920667269656E6420 + +// Answer is: +// 06031CEC546648D86AD549EDD9CB1A1AC67A3073E0A0334657DE9BF469C79BC0 + +// Decrypt Short Message +send_apdu -sc 0 -APDU 804400002006031CEC546648D86AD549EDD9CB1A1AC67A3073E0A0334657DE9BF469C79BC010 + +// Encrypt Long Message (32 Bytes) +send_apdu -sc 0 -APDU 804200002048656C6C6F206D7920667269656E642120486F7720697320776561746865723F30 + +// Answer is: +// A3631530E3C2E874B5CAB11416D928C1E4B63349BE3CE0CE77298AD53DD2BF0B9336BE3C5AD57471E01D22B045721D9F + +// Decrypt Long Message (32 Bytes) +send_apdu -sc 0 -APDU 8044000030A3631530E3C2E874B5CAB11416D928C1E4B63349BE3CE0CE77298AD53DD2BF0B9336BE3C5AD57471E01D22B045721D9F20 + +// Sending Too Much Data for Decryption +send_apdu -sc 0 -APDU 80440000510102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F5051 + +// Trying to Decrypt Unpadded Data +send_apdu -sc 0 -APDU 80420000110102030405060708090A0B0C0D0E0F101101 + +// Trying to Decrypt Tampered Short Message +send_apdu -sc 0 -APDU 804400002006031CEC546648D86AE549EDD9CB1A1AC67A3073E0A0334657DE9BF469C79BC010 + +card_disconnect +release_context