| 1 | /* Copyright (c) 2017, 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 | |
| 15 | #ifndef OPENSSL_HEADER_PKCS7_INTERNAL_H |
| 16 | #define |
| 17 | |
| 18 | #include <openssl/base.h> |
| 19 | |
| 20 | #if defined(__cplusplus) |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | |
| 25 | // pkcs7_parse_header reads the non-certificate/non-CRL prefix of a PKCS#7 |
| 26 | // SignedData blob from |cbs| and sets |*out| to point to the rest of the |
| 27 | // input. If the input is in BER format, then |*der_bytes| will be set to a |
| 28 | // pointer that needs to be freed by the caller once they have finished |
| 29 | // processing |*out| (which will be pointing into |*der_bytes|). |
| 30 | // |
| 31 | // It returns one on success or zero on error. On error, |*der_bytes| is |
| 32 | // NULL. |
| 33 | int (uint8_t **der_bytes, CBS *out, CBS *cbs); |
| 34 | |
| 35 | // pkcs7_bundle writes a PKCS#7, SignedData structure to |out| and then calls |
| 36 | // |cb| with a CBB to which certificate or CRL data can be written, and the |
| 37 | // opaque context pointer, |arg|. The callback can return zero to indicate an |
| 38 | // error. |
| 39 | // |
| 40 | // pkcs7_bundle returns one on success or zero on error. |
| 41 | int pkcs7_bundle(CBB *out, int (*cb)(CBB *out, const void *arg), |
| 42 | const void *arg); |
| 43 | |
| 44 | |
| 45 | #if defined(__cplusplus) |
| 46 | } // extern C |
| 47 | #endif |
| 48 | |
| 49 | #endif // OPENSSL_HEADER_PKCS7_INTERNAL_H |
| 50 | |