Andres Amaya Garcia | f2d1792 | 2017-10-24 22:47:14 +0100 | [diff] [blame] | 1 | # test_zeroize.gdb |
| 2 | # |
| 3 | # This file is part of mbed TLS (https://tls.mbed.org) |
| 4 | # |
| 5 | # Copyright (c) 2017, ARM Limited, All Rights Reserved |
| 6 | # |
| 7 | # Purpose |
| 8 | # |
| 9 | # Run a test using the debugger to check that the mbedtls_zeroize() function in |
| 10 | # utils.h is not being optimized out by the compiler. To do so, the script |
| 11 | # loads the test program at programs/test/zeroize.c and sets a breakpoint at |
| 12 | # the last return statement in the main(). When the breakpoint is hit, the |
| 13 | # debugger manually checks the contents to be zeroized and checks that it is |
| 14 | # actually cleared. |
| 15 | # |
| 16 | # Note: This test requires that the test program is compiled with -g3. |
| 17 | |
Andres Amaya Garcia | ddebc49 | 2017-10-24 22:16:34 +0100 | [diff] [blame] | 18 | set confirm off |
| 19 | file ./programs/test/zeroize |
Andres Amaya Garcia | 7111a0d | 2017-10-31 21:28:31 +0000 | [diff] [blame^] | 20 | break zeroize.c:90 |
Andres Amaya Garcia | ddebc49 | 2017-10-24 22:16:34 +0100 | [diff] [blame] | 21 | |
| 22 | set args ./programs/test/zeroize.c |
| 23 | run |
| 24 | |
| 25 | set $i = 0 |
| 26 | set $len = sizeof(buf) |
| 27 | set $buf = buf |
| 28 | |
| 29 | if exit_code != 0 |
| 30 | echo The program did not terminate correctly\n |
| 31 | quit 1 |
| 32 | end |
| 33 | |
| 34 | while $i < $len |
| 35 | if $buf[$i++] != 0 |
| 36 | echo The buffer at was not zeroized\n |
| 37 | quit 1 |
| 38 | end |
| 39 | end |
| 40 | |
| 41 | echo The buffer was correctly zeroized\n |
| 42 | quit 0 |