pkcs7.h (4281B)
1 /* pkcs7.h 2 * 3 * Copyright (C) 2006-2025 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 3 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 22 /* pkcs7.h for openSSL */ 23 24 25 #ifndef WOLFSSL_PKCS7_H_ 26 #define WOLFSSL_PKCS7_H_ 27 28 #include <wolfssl/openssl/ssl.h> 29 #include <wolfssl/wolfcrypt/pkcs7.h> 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #if defined(OPENSSL_ALL) && defined(HAVE_PKCS7) 36 37 #define PKCS7_TEXT 0x1 38 #define PKCS7_NOCERTS 0x2 39 #define PKCS7_DETACHED 0x40 40 #define PKCS7_BINARY 0x80 41 #define PKCS7_NOINTERN 0x0010 42 #define PKCS7_NOVERIFY 0x0020 43 #define PKCS7_STREAM 0x1000 44 #define PKCS7_PARTIAL 0x4000 45 46 typedef struct WOLFSSL_PKCS7 47 { 48 PKCS7 pkcs7; 49 unsigned char* data; 50 int len; 51 int type; /* from PKCS7_TYPES, for PKCS7_final() */ 52 WOLFSSL_STACK* certs; 53 } WOLFSSL_PKCS7; 54 55 56 WOLFSSL_API PKCS7* wolfSSL_PKCS7_new(void); 57 WOLFSSL_API PKCS7_SIGNED* wolfSSL_PKCS7_SIGNED_new(void); 58 WOLFSSL_API void wolfSSL_PKCS7_free(PKCS7* p7); 59 WOLFSSL_API void wolfSSL_PKCS7_SIGNED_free(PKCS7_SIGNED* p7); 60 WOLFSSL_API PKCS7* wolfSSL_d2i_PKCS7(PKCS7** p7, const unsigned char** in, 61 int len); 62 WOLFSSL_LOCAL PKCS7* wolfSSL_d2i_PKCS7_ex(PKCS7** p7, const unsigned char** in, 63 int len, byte* content, word32 contentSz); 64 WOLFSSL_API PKCS7* wolfSSL_d2i_PKCS7_bio(WOLFSSL_BIO* bio, PKCS7** p7); 65 WOLFSSL_API int wolfSSL_i2d_PKCS7_bio(WOLFSSL_BIO *bio, PKCS7 *p7); 66 WOLFSSL_API int wolfSSL_i2d_PKCS7(PKCS7 *p7, unsigned char **out); 67 WOLFSSL_API PKCS7* wolfSSL_PKCS7_sign(WOLFSSL_X509* signer, 68 WOLFSSL_EVP_PKEY* pkey, WOLFSSL_STACK* certs, WOLFSSL_BIO* in, int flags); 69 WOLFSSL_API int wolfSSL_PKCS7_verify(PKCS7* p7, WOLFSSL_STACK* certs, 70 WOLFSSL_X509_STORE* store, WOLFSSL_BIO* in, WOLFSSL_BIO* out, int flags); 71 WOLFSSL_API int wolfSSL_PKCS7_final(PKCS7* pkcs7, WOLFSSL_BIO* in, int flags); 72 WOLFSSL_API int wolfSSL_PKCS7_encode_certs(PKCS7* p7, WOLFSSL_STACK* certs, 73 WOLFSSL_BIO* out); 74 WOLFSSL_API WOLFSSL_STACK* wolfSSL_PKCS7_to_stack(PKCS7* pkcs7); 75 WOLFSSL_API WOLFSSL_STACK* wolfSSL_PKCS7_get0_signers(PKCS7* p7, 76 WOLFSSL_STACK* certs, int flags); 77 WOLFSSL_API int wolfSSL_PEM_write_bio_PKCS7(WOLFSSL_BIO* bio, PKCS7* p7); 78 #if defined(HAVE_SMIME) 79 WOLFSSL_API PKCS7* wolfSSL_SMIME_read_PKCS7(WOLFSSL_BIO* in, WOLFSSL_BIO** bcont); 80 WOLFSSL_API int wolfSSL_SMIME_write_PKCS7(WOLFSSL_BIO* out, PKCS7* pkcs7, 81 WOLFSSL_BIO* in, int flags); 82 #endif /* HAVE_SMIME */ 83 84 85 #define PKCS7_new wolfSSL_PKCS7_new 86 #define PKCS7_SIGNED_new wolfSSL_PKCS7_SIGNED_new 87 #define PKCS7_free wolfSSL_PKCS7_free 88 #define PKCS7_SIGNED_free wolfSSL_PKCS7_SIGNED_free 89 #define d2i_PKCS7 wolfSSL_d2i_PKCS7 90 #define d2i_PKCS7_bio wolfSSL_d2i_PKCS7_bio 91 #define i2d_PKCS7_bio wolfSSL_i2d_PKCS7_bio 92 #define i2d_PKCS7 wolfSSL_i2d_PKCS7 93 #define PKCS7_sign wolfSSL_PKCS7_sign 94 #define PKCS7_verify wolfSSL_PKCS7_verify 95 #define PKCS7_final wolfSSL_PKCS7_final 96 #define PKCS7_get0_signers wolfSSL_PKCS7_get0_signers 97 #define PEM_write_bio_PKCS7 wolfSSL_PEM_write_bio_PKCS7 98 #if defined(HAVE_SMIME) 99 #define SMIME_read_PKCS7 wolfSSL_SMIME_read_PKCS7 100 #define SMIME_write_PKCS7 wolfSSL_SMIME_write_PKCS7 101 #endif /* HAVE_SMIME */ 102 103 #endif /* OPENSSL_ALL && HAVE_PKCS7 */ 104 105 #ifdef __cplusplus 106 } /* extern "C" */ 107 #endif 108 109 #endif /* WOLFSSL_PKCS7_H_ */ 110