Adam Langley | d9e397b | 2015-01-22 14:27:53 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2014, 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 | |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 15 | #ifndef OPENSSL_HEADER_PKCS7_H |
| 16 | #define OPENSSL_HEADER_PKCS7_H |
| 17 | |
| 18 | #include <openssl/base.h> |
| 19 | |
| 20 | #include <openssl/stack.h> |
| 21 | |
| 22 | #if defined(__cplusplus) |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
| 26 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 27 | // PKCS#7. |
| 28 | // |
| 29 | // This library contains functions for extracting information from PKCS#7 |
| 30 | // structures (RFC 2315). |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 31 | |
| 32 | DECLARE_STACK_OF(CRYPTO_BUFFER) |
| 33 | DECLARE_STACK_OF(X509) |
| 34 | DECLARE_STACK_OF(X509_CRL) |
| 35 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 36 | // PKCS7_get_raw_certificates parses a PKCS#7, SignedData structure from |cbs| |
| 37 | // and appends the included certificates to |out_certs|. It returns one on |
| 38 | // success and zero on error. |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 39 | OPENSSL_EXPORT int PKCS7_get_raw_certificates( |
| 40 | STACK_OF(CRYPTO_BUFFER) *out_certs, CBS *cbs, CRYPTO_BUFFER_POOL *pool); |
| 41 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 42 | // PKCS7_get_certificates behaves like |PKCS7_get_raw_certificates| but parses |
| 43 | // them into |X509| objects. |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 44 | OPENSSL_EXPORT int PKCS7_get_certificates(STACK_OF(X509) *out_certs, CBS *cbs); |
| 45 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 46 | // PKCS7_bundle_certificates appends a PKCS#7, SignedData structure containing |
| 47 | // |certs| to |out|. It returns one on success and zero on error. |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 48 | OPENSSL_EXPORT int PKCS7_bundle_certificates( |
| 49 | CBB *out, const STACK_OF(X509) *certs); |
| 50 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 51 | // PKCS7_get_CRLs parses a PKCS#7, SignedData structure from |cbs| and appends |
| 52 | // the included CRLs to |out_crls|. It returns one on success and zero on |
| 53 | // error. |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 54 | OPENSSL_EXPORT int PKCS7_get_CRLs(STACK_OF(X509_CRL) *out_crls, CBS *cbs); |
| 55 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 56 | // PKCS7_bundle_CRLs appends a PKCS#7, SignedData structure containing |
| 57 | // |crls| to |out|. It returns one on success and zero on error. |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 58 | OPENSSL_EXPORT int PKCS7_bundle_CRLs(CBB *out, const STACK_OF(X509_CRL) *crls); |
| 59 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 60 | // PKCS7_get_PEM_certificates reads a PEM-encoded, PKCS#7, SignedData structure |
| 61 | // from |pem_bio| and appends the included certificates to |out_certs|. It |
| 62 | // returns one on success and zero on error. |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 63 | OPENSSL_EXPORT int PKCS7_get_PEM_certificates(STACK_OF(X509) *out_certs, |
| 64 | BIO *pem_bio); |
| 65 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 66 | // PKCS7_get_PEM_CRLs reads a PEM-encoded, PKCS#7, SignedData structure from |
| 67 | // |pem_bio| and appends the included CRLs to |out_crls|. It returns one on |
| 68 | // success and zero on error. |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 69 | OPENSSL_EXPORT int PKCS7_get_PEM_CRLs(STACK_OF(X509_CRL) *out_crls, |
| 70 | BIO *pem_bio); |
| 71 | |
| 72 | |
| 73 | #if defined(__cplusplus) |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 74 | } // extern C |
Robert Sloan | 9254e68 | 2017-04-24 09:42:06 -0700 | [diff] [blame] | 75 | #endif |
| 76 | |
| 77 | #define PKCS7_R_BAD_PKCS7_VERSION 100 |
| 78 | #define PKCS7_R_NOT_PKCS7_SIGNED_DATA 101 |
| 79 | #define PKCS7_R_NO_CERTIFICATES_INCLUDED 102 |
| 80 | #define PKCS7_R_NO_CRLS_INCLUDED 103 |
| 81 | |
Robert Sloan | 8f860b1 | 2017-08-28 07:37:06 -0700 | [diff] [blame] | 82 | #endif // OPENSSL_HEADER_PKCS7_H |