25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pkcs8.cc 1.3 KiB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* Copyright (c) 2016, Google Inc.
  2. *
  3. * Permission to use, copy, modify, and/or distribute this software for any
  4. * purpose with or without fee is hereby granted, provided that the above
  5. * copyright notice and this permission notice appear in all copies.
  6. *
  7. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  10. * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  12. * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  13. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
  14. #include <openssl/bytestring.h>
  15. #include <openssl/evp.h>
  16. #include <openssl/mem.h>
  17. extern "C" int LLVMFuzzerTestOneInput(uint8_t *buf, size_t len) {
  18. CBS cbs;
  19. CBS_init(&cbs, buf, len);
  20. EVP_PKEY *pkey = EVP_parse_private_key(&cbs);
  21. if (pkey == NULL) {
  22. return 0;
  23. }
  24. uint8_t *der;
  25. size_t der_len;
  26. CBB cbb;
  27. if (CBB_init(&cbb, 0) &&
  28. EVP_marshal_private_key(&cbb, pkey) &&
  29. CBB_finish(&cbb, &der, &der_len)) {
  30. OPENSSL_free(der);
  31. }
  32. CBB_cleanup(&cbb);
  33. EVP_PKEY_free(pkey);
  34. return 0;
  35. }