pkcs7.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* pkcs7.h
  2. *
  3. * Copyright (C) 2006-2022 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. /* pkcs7.h for openSSL */
  22. #ifndef WOLFSSL_PKCS7_H_
  23. #define WOLFSSL_PKCS7_H_
  24. #include <wolfssl/openssl/ssl.h>
  25. #include <wolfssl/wolfcrypt/pkcs7.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. #if defined(OPENSSL_ALL) && defined(HAVE_PKCS7)
  30. #define PKCS7_TEXT 0x1
  31. #define PKCS7_NOCERTS 0x2
  32. #define PKCS7_DETACHED 0x40
  33. #define PKCS7_BINARY 0x80
  34. #define PKCS7_NOINTERN 0x0010
  35. #define PKCS7_NOVERIFY 0x0020
  36. #define PKCS7_STREAM 0x1000
  37. #define PKCS7_PARTIAL 0x4000
  38. typedef struct WOLFSSL_PKCS7
  39. {
  40. PKCS7 pkcs7;
  41. unsigned char* data;
  42. int len;
  43. int type; /* from PKCS7_TYPES, for PKCS7_final() */
  44. WOLFSSL_STACK* certs;
  45. } WOLFSSL_PKCS7;
  46. WOLFSSL_API PKCS7* wolfSSL_PKCS7_new(void);
  47. WOLFSSL_API PKCS7_SIGNED* wolfSSL_PKCS7_SIGNED_new(void);
  48. WOLFSSL_API void wolfSSL_PKCS7_free(PKCS7* p7);
  49. WOLFSSL_API void wolfSSL_PKCS7_SIGNED_free(PKCS7_SIGNED* p7);
  50. WOLFSSL_API PKCS7* wolfSSL_d2i_PKCS7(PKCS7** p7, const unsigned char** in,
  51. int len);
  52. WOLFSSL_LOCAL PKCS7* wolfSSL_d2i_PKCS7_ex(PKCS7** p7, const unsigned char** in,
  53. int len, byte* content, word32 contentSz);
  54. WOLFSSL_API PKCS7* wolfSSL_d2i_PKCS7_bio(WOLFSSL_BIO* bio, PKCS7** p7);
  55. WOLFSSL_API int wolfSSL_i2d_PKCS7_bio(WOLFSSL_BIO *bio, PKCS7 *p7);
  56. WOLFSSL_API int wolfSSL_i2d_PKCS7(PKCS7 *p7, unsigned char **out);
  57. WOLFSSL_API PKCS7* wolfSSL_PKCS7_sign(WOLFSSL_X509* signer,
  58. WOLFSSL_EVP_PKEY* pkey, WOLFSSL_STACK* certs, WOLFSSL_BIO* in, int flags);
  59. WOLFSSL_API int wolfSSL_PKCS7_verify(PKCS7* p7, WOLFSSL_STACK* certs,
  60. WOLFSSL_X509_STORE* store, WOLFSSL_BIO* in, WOLFSSL_BIO* out, int flags);
  61. WOLFSSL_API int wolfSSL_PKCS7_final(PKCS7* pkcs7, WOLFSSL_BIO* in, int flags);
  62. WOLFSSL_API int wolfSSL_PKCS7_encode_certs(PKCS7* p7, WOLFSSL_STACK* certs,
  63. WOLFSSL_BIO* out);
  64. WOLFSSL_API WOLFSSL_STACK* wolfSSL_PKCS7_to_stack(PKCS7* pkcs7);
  65. WOLFSSL_API WOLFSSL_STACK* wolfSSL_PKCS7_get0_signers(PKCS7* p7,
  66. WOLFSSL_STACK* certs, int flags);
  67. WOLFSSL_API int wolfSSL_PEM_write_bio_PKCS7(WOLFSSL_BIO* bio, PKCS7* p7);
  68. #if defined(HAVE_SMIME)
  69. WOLFSSL_API PKCS7* wolfSSL_SMIME_read_PKCS7(WOLFSSL_BIO* in, WOLFSSL_BIO** bcont);
  70. WOLFSSL_API int wolfSSL_SMIME_write_PKCS7(WOLFSSL_BIO* out, PKCS7* pkcs7,
  71. WOLFSSL_BIO* in, int flags);
  72. #endif /* HAVE_SMIME */
  73. #define PKCS7_new wolfSSL_PKCS7_new
  74. #define PKCS7_SIGNED_new wolfSSL_PKCS7_SIGNED_new
  75. #define PKCS7_free wolfSSL_PKCS7_free
  76. #define PKCS7_SIGNED_free wolfSSL_PKCS7_SIGNED_free
  77. #define d2i_PKCS7 wolfSSL_d2i_PKCS7
  78. #define d2i_PKCS7_bio wolfSSL_d2i_PKCS7_bio
  79. #define i2d_PKCS7_bio wolfSSL_i2d_PKCS7_bio
  80. #define i2d_PKCS7 wolfSSL_i2d_PKCS7
  81. #define PKCS7_sign wolfSSL_PKCS7_sign
  82. #define PKCS7_verify wolfSSL_PKCS7_verify
  83. #define PKCS7_final wolfSSL_PKCS7_final
  84. #define PKCS7_get0_signers wolfSSL_PKCS7_get0_signers
  85. #define PEM_write_bio_PKCS7 wolfSSL_PEM_write_bio_PKCS7
  86. #if defined(HAVE_SMIME)
  87. #define SMIME_read_PKCS7 wolfSSL_SMIME_read_PKCS7
  88. #define SMIME_write_PKCS7 wolfSSL_SMIME_write_PKCS7
  89. #endif /* HAVE_SMIME */
  90. #endif /* OPENSSL_ALL && HAVE_PKCS7 */
  91. #ifdef __cplusplus
  92. } /* extern "C" */
  93. #endif
  94. #endif /* WOLFSSL_PKCS7_H_ */