]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/test-x509.c
tests: sigma_dut controlled STA and beacon protection
[thirdparty/hostap.git] / tests / test-x509.c
1 /*
2 * Testing tool for X.509v3 routines
3 * Copyright (c) 2006-2019, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9 #include "includes.h"
10
11 #include "common.h"
12 #include "tls/x509v3.h"
13
14
15 #ifdef TEST_LIBFUZZER
16 int 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 */
25 int 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 }
47 #endif /* TEST_LIBFUZZER */