Add tests for the SecretApplet

This commit is contained in:
Manuel Thalmann 2023-11-07 08:40:28 +01:00
parent 60df2dc4b9
commit 452e2d4716
2 changed files with 61 additions and 0 deletions

12
.vscode/tasks.json vendored
View file

@ -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",

View file

@ -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