fuzz_x509crt.c 670 B

1234567891011121314151617181920212223242526272829
  1. #define MBEDTLS_ALLOW_PRIVATE_ACCESS
  2. #include <stdint.h>
  3. #include "mbedtls/x509_crt.h"
  4. int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
  5. #ifdef MBEDTLS_X509_CRT_PARSE_C
  6. int ret;
  7. mbedtls_x509_crt crt;
  8. unsigned char buf[4096];
  9. mbedtls_x509_crt_init( &crt );
  10. ret = mbedtls_x509_crt_parse( &crt, Data, Size );
  11. #if !defined(MBEDTLS_X509_REMOVE_INFO)
  12. if (ret == 0) {
  13. ret = mbedtls_x509_crt_info( (char *) buf, sizeof( buf ) - 1, " ", &crt );
  14. }
  15. #else
  16. ((void) ret);
  17. ((void) buf);
  18. #endif /* !MBEDTLS_X509_REMOVE_INFO */
  19. mbedtls_x509_crt_free( &crt );
  20. #else
  21. (void) Data;
  22. (void) Size;
  23. #endif
  24. return 0;
  25. }