smime.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright 2023 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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. #include "fuzzer.h"
  11. #include <openssl/err.h>
  12. #include <openssl/pkcs7.h>
  13. #include <openssl/x509.h>
  14. #include <stdio.h>
  15. int FuzzerInitialize(int *argc, char ***argv)
  16. {
  17. return 1;
  18. }
  19. int FuzzerTestOneInput(const uint8_t *buf, size_t len)
  20. {
  21. BIO *b = BIO_new_mem_buf(buf, len);
  22. PKCS7 *p7 = SMIME_read_PKCS7(b, NULL);
  23. if (p7 != NULL) {
  24. STACK_OF(PKCS7_SIGNER_INFO) *p7si = PKCS7_get_signer_info(p7);
  25. int i;
  26. for (i = 0; i < sk_PKCS7_SIGNER_INFO_num(p7si); i++) {
  27. STACK_OF(X509_ALGOR) *algs;
  28. PKCS7_cert_from_signer_info(p7,
  29. sk_PKCS7_SIGNER_INFO_value(p7si, i));
  30. algs = PKCS7_get_smimecap(sk_PKCS7_SIGNER_INFO_value(p7si, i));
  31. sk_X509_ALGOR_pop_free(algs, X509_ALGOR_free);
  32. }
  33. PKCS7_free(p7);
  34. }
  35. BIO_free(b);
  36. ERR_clear_error();
  37. return 0;
  38. }
  39. void FuzzerCleanup(void)
  40. {
  41. }