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 OPENSSL_HEADER_PKCS7_INTERNAL_H 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 pkcs7_parse_header(uint8_t **der_bytes, CBS *out, CBS *cbs); 34 35 // pkcs7_add_signed_data writes a PKCS#7, SignedData structure to |out|. While 36 // doing so it makes callbacks to let the caller fill in parts of the structure. 37 // All callbacks are ignored if NULL and return one on success or zero on error. 38 // 39 // digest_algos_cb: may write AlgorithmIdentifiers into the given CBB, which 40 // is a SET of digest algorithms. 41 // cert_crl_cb: may write the |certificates| or |crls| fields. 42 // (See https://datatracker.ietf.org/doc/html/rfc2315#section-9.1) 43 // signer_infos_cb: may write the contents of the |signerInfos| field. 44 // (See https://datatracker.ietf.org/doc/html/rfc2315#section-9.1) 45 // 46 // pkcs7_add_signed_data returns one on success or zero on error. 47 int pkcs7_add_signed_data(CBB *out, 48 int (*digest_algos_cb)(CBB *out, const void *arg), 49 int (*cert_crl_cb)(CBB *out, const void *arg), 50 int (*signer_infos_cb)(CBB *out, const void *arg), 51 const void *arg); 52 53 54 #if defined(__cplusplus) 55 } // extern C 56 #endif 57 58 #endif // OPENSSL_HEADER_PKCS7_INTERNAL_H 59