2
0

cms.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL licenses, (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. * https://www.openssl.org/source/license.html
  8. * or in the file LICENSE in the source distribution.
  9. */
  10. /*
  11. * Test CMS DER parsing.
  12. */
  13. #include <openssl/bio.h>
  14. #include <openssl/cms.h>
  15. #include <openssl/err.h>
  16. #include "fuzzer.h"
  17. int FuzzerInitialize(int *argc, char ***argv)
  18. {
  19. OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL);
  20. ERR_get_state();
  21. CRYPTO_free_ex_index(0, -1);
  22. return 1;
  23. }
  24. int FuzzerTestOneInput(const uint8_t *buf, size_t len)
  25. {
  26. CMS_ContentInfo *cms;
  27. BIO *in;
  28. if (len == 0)
  29. return 0;
  30. in = BIO_new(BIO_s_mem());
  31. OPENSSL_assert((size_t)BIO_write(in, buf, len) == len);
  32. cms = d2i_CMS_bio(in, NULL);
  33. if (cms != NULL) {
  34. BIO *out = BIO_new(BIO_s_null());
  35. i2d_CMS_bio(out, cms);
  36. BIO_free(out);
  37. CMS_ContentInfo_free(cms);
  38. }
  39. BIO_free(in);
  40. ERR_clear_error();
  41. return 0;
  42. }
  43. void FuzzerCleanup(void)
  44. {
  45. }