diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /roms/skiboot/libstb/secvar/test/secvar-test-pkcs7.c | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'roms/skiboot/libstb/secvar/test/secvar-test-pkcs7.c')
-rw-r--r-- | roms/skiboot/libstb/secvar/test/secvar-test-pkcs7.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/roms/skiboot/libstb/secvar/test/secvar-test-pkcs7.c b/roms/skiboot/libstb/secvar/test/secvar-test-pkcs7.c new file mode 100644 index 000000000..d5e88709f --- /dev/null +++ b/roms/skiboot/libstb/secvar/test/secvar-test-pkcs7.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later +/* Copyright 2021 IBM Corp. */ + +#define MBEDTLS_PKCS7_C +#include "secvar_common_test.c" +#include "../../crypto/pkcs7/pkcs7.c" + +const char *secvar_test_name = "pkcs7"; + +int run_test() +{ + const unsigned char underrun_p7s[] = {0x30, 0x48}; + mbedtls_pkcs7 pkcs7; + unsigned char *data; + int rc; + + mbedtls_pkcs7_init(&pkcs7); + /* The data must live in the heap, not the stack, for valgrind to + catch the overread. */ + data = malloc(sizeof(underrun_p7s)); + memcpy(data, underrun_p7s, sizeof(underrun_p7s)); + rc = mbedtls_pkcs7_parse_der(data, sizeof(underrun_p7s), &pkcs7); + free(data); + ASSERT(0 > rc); + + return 0; +} + +int main(void) +{ + return run_test(); +} |