1 =pod 2 3 =head1 NAME 4 5 ossl_cmp_calc_protection, 6 ossl_cmp_msg_protect, 7 ossl_cmp_msg_add_extraCerts 8 - functions for producing CMP message protection 9 10 =head1 SYNOPSIS 11 12 #include "cmp_local.h" 13 14 ASN1_BIT_STRING *ossl_cmp_calc_protection(const OSSL_CMP_CTX *ctx, 15 const OSSL_CMP_MSG *msg); 16 int ossl_cmp_msg_protect(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg); 17 int ossl_cmp_msg_add_extraCerts(OSSL_CMP_CTX *ctx, OSSL_CMP_MSG *msg); 18 19 =head1 DESCRIPTION 20 21 ossl_cmp_calc_protection() calculates the protection for the given I<msg> 22 according to the algorithm and parameters in the message header's protectionAlg 23 using the credentials, library context, and property criteria in the I<ctx>. 24 25 ossl_cmp_msg_protect() (re-)protects the given message I<msg> using an algorithm 26 depending on the available context information given in the I<ctx>. 27 If there is a secretValue it selects PBMAC, else if there is a protection cert 28 it selects Signature and uses ossl_cmp_msg_add_extraCerts (see below). 29 It also sets the protectionAlg field in the message header accordingly. 30 31 ossl_cmp_msg_add_extraCerts() adds elements to the extraCerts field in I<msg>. 32 If signature-based message protection is used it adds first the CMP signer cert 33 ctx->cert and then its chain ctx->chain. If this chain is not present in I<ctx> 34 tries to build it using ctx->untrusted and caches the result in ctx->chain. 35 In any case all the certificates explicitly specified to be sent out (i.e., 36 I<ctx->extraCertsOut>) are added. Note that it will NOT add the root certificate 37 of the chain, i.e, the trust anchor (unless it is part of extraCertsOut). 38 39 =head1 NOTES 40 41 CMP is defined in RFC 4210 (and CRMF in RFC 4211). 42 43 The I<ctx> parameter of ossl_cmp_msg_add_extraCerts() 44 and thus also of ossl_cmp_msg_protect() cannot be made I<const> 45 because I<ctx->chain> may get adapted to cache the chain of the CMP signer cert. 46 47 =head1 RETURN VALUES 48 49 ossl_cmp_calc_protection() returns the protection on success, else NULL. 50 51 All other functions return 1 on success, 0 on error. 52 53 =head1 HISTORY 54 55 The OpenSSL CMP support was added in OpenSSL 3.0. 56 57 =head1 COPYRIGHT 58 59 Copyright 2007-2023 The OpenSSL Project Authors. All Rights Reserved. 60 61 Licensed under the Apache License 2.0 (the "License"). You may not use 62 this file except in compliance with the License. You can obtain a copy 63 in the file LICENSE in the source distribution or at 64 L<https://www.openssl.org/source/license.html>. 65 66 =cut 67