]> git.ipfire.org Git - thirdparty/hostap.git/blame - tests/test-x509.c
tests: sigma_dut controlled STA and beacon protection
[thirdparty/hostap.git] / tests / test-x509.c
CommitLineData
ab7ddc74
JM
1/*
2 * Testing tool for X.509v3 routines
f3e67159 3 * Copyright (c) 2006-2019, Jouni Malinen <j@w1.fi>
ab7ddc74 4 *
0f3d578e
JM
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
ab7ddc74
JM
7 */
8
9#include "includes.h"
10
11#include "common.h"
12#include "tls/x509v3.h"
13
ab7ddc74 14
f3e67159
JM
15#ifdef TEST_LIBFUZZER
16int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
17{
18 struct x509_certificate *cert;
19
20 cert = x509_certificate_parse(data, size);
21 x509_certificate_free(cert);
22 return 0;
23}
24#else /* TEST_LIBFUZZER */
ab7ddc74
JM
25int main(int argc, char *argv[])
26{
27 FILE *f;
28 u8 buf[3000];
29 size_t len;
30 struct x509_certificate *cert;
31
32 wpa_debug_level = 0;
33
34 f = fopen(argv[1], "rb");
35 if (f == NULL)
36 return -1;
37 len = fread(buf, 1, sizeof(buf), f);
38 fclose(f);
39
40 cert = x509_certificate_parse(buf, len);
41 if (cert == NULL)
42 printf("Failed to parse X.509 certificate\n");
43 x509_certificate_free(cert);
44
45 return 0;
46}
f3e67159 47#endif /* TEST_LIBFUZZER */