| 6 | // |
| 7 | // https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 |
| 15 | #ifndef OPENSSL_HEADER_CRYPTO_PKCS7_INTERNAL_H |
| 16 | #define OPENSSL_HEADER_CRYPTO_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_CRYPTO_PKCS7_INTERNAL_H |
| 59 |