Skip to content

Commit 932499f

Browse files
committed
Implement an address sanitizer test. Fix some of the configurable limit defaults.
1 parent 683b1af commit 932499f

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

.github/workflows/make-test-swtpm.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ jobs:
139139
- name: make debug io
140140
run: make
141141

142+
# build with clang address sanitizer
143+
- name: configure clang asan
144+
run: ./configure --enable-swtpm CC=clang CFLAGS="-fsanitize=address -fno-omit-frame-pointer -g"
145+
- name: make clang asan
146+
run: make
147+
- name: make check clang asan
148+
run: |
149+
make check
150+
ASAN_OPTIONS=detect_leaks=1:abort_on_error=1 WOLFSSL_PATH=./wolfssl ./examples/run_examples.sh
151+
142152
# build pedantic
143153
- name: configure pedantic
144154
run: ./configure CFLAGS="-Wpedantic"

tests/unit_tests.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ static void test_wolfTPM2_EccSignVerifyDig(WOLFTPM2_DEV* dev,
504504
AssertIntEQ(rc, 0);
505505

506506
/* combine R and S at key size (zero pad leading) */
507-
XMEMCPY(&sigRs[curveSize-rLen], r, rLen);
507+
XMEMMOVE(&sigRs[curveSize-rLen], r, rLen);
508508
XMEMSET(&sigRs[0], 0, curveSize-rLen);
509-
XMEMCPY(&sigRs[curveSize + (curveSize-sLen)], s, sLen);
509+
XMEMMOVE(&sigRs[curveSize + (curveSize-sLen)], s, sLen);
510510
XMEMSET(&sigRs[curveSize], 0, curveSize-sLen);
511511

512512
/* Verify wolfCrypt signature with TPM */

wolftpm/tpm2_types.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ typedef int64_t INT64;
172172
#define XFREE(p, h, t) free(p)
173173
#endif
174174
#define XMEMCPY(d,s,l) memcpy((d),(s),(l))
175+
#define XMEMMOVE(d,s,l) memmove((d),(s),(l))
175176
#define XMEMSET(b,c,l) memset((b),(c),(l))
176177
#define XMEMCMP(s1,s2,n) memcmp((s1),(s2),(n))
177178
#define XSTRLEN(s1) strlen((s1))
@@ -428,10 +429,10 @@ typedef int64_t INT64;
428429
#define MAX_SYM_BLOCK_SIZE 20
429430
#endif
430431
#ifndef MAX_SYM_KEY_BYTES
431-
#define MAX_SYM_KEY_BYTES 256
432+
#define MAX_SYM_KEY_BYTES 32
432433
#endif
433434
#ifndef LABEL_MAX_BUFFER
434-
#define LABEL_MAX_BUFFER 128
435+
#define LABEL_MAX_BUFFER 48
435436
#endif
436437
#ifndef MAX_RSA_KEY_BITS
437438
#define MAX_RSA_KEY_BITS 2048
@@ -444,11 +445,11 @@ typedef int64_t INT64;
444445
#define MAX_ECC_KEY_BITS 521
445446
#endif
446447
#ifndef MAX_ECC_KEY_BYTES
447-
#define MAX_ECC_KEY_BYTES (((MAX_ECC_KEY_BITS+7)/8)*2)
448+
#define MAX_ECC_KEY_BYTES ((MAX_ECC_KEY_BITS+7)/8)
448449
#endif
449450

450451
#ifndef MAX_AES_KEY_BITS
451-
#define MAX_AES_KEY_BITS 128
452+
#define MAX_AES_KEY_BITS 256
452453
#endif
453454
#ifndef MAX_AES_BLOCK_SIZE_BYTES
454455
#define MAX_AES_BLOCK_SIZE_BYTES 16

0 commit comments

Comments
 (0)