chunk 5 of CMP contribution to OpenSSL
[openssl.git] / doc / internal / man3 / ossl_cmp_hdr_init.pod
1 =pod
2
3 =head1 NAME
4
5 ossl_cmp_hdr_set_pvno,
6 ossl_cmp_hdr_get_pvno,
7 ossl_cmp_hdr_get0_sendernonce,
8 ossl_cmp_hdr_set1_sender,
9 ossl_cmp_hdr_set1_recipient,
10 ossl_cmp_hdr_update_messagetime,
11 ossl_cmp_hdr_set1_senderKID,
12 ossl_cmp_hdr_push0_freeText,
13 ossl_cmp_hdr_push1_freeText,
14 ossl_cmp_hdr_generalinfo_item_push0,
15 ossl_cmp_hdr_generalinfo_items_push1,
16 ossl_cmp_hdr_set_implicitConfirm,
17 ossl_cmp_hdr_check_implicitConfirm,
18 ossl_cmp_hdr_init
19 - functions manipulating CMP message headers
20
21 =head1 SYNOPSIS
22
23   #include "cmp_int.h"
24
25   int ossl_cmp_hdr_set_pvno(OSSL_CMP_PKIHEADER *hdr, int pvno);
26   int ossl_cmp_hdr_get_pvno(const OSSL_CMP_PKIHEADER *hdr);
27   ASN1_OCTET_STRING
28      *ossl_cmp_hdr_get0_sendernonce(const OSSL_CMP_PKIHEADER *hdr);
29
30   int ossl_cmp_hdr_set1_sender(OSSL_CMP_PKIHEADER *hdr, const X509_NAME *nm);
31   int ossl_cmp_hdr_set1_recipient(OSSL_CMP_PKIHEADER *hdr, const X509_NAME *nm);
32   int ossl_cmp_hdr_update_messagetime(OSSL_CMP_PKIHEADER *hdr);
33   int ossl_cmp_hdr_set1_senderKID(OSSL_CMP_PKIHEADER *hdr,
34                                   const ASN1_OCTET_STRING *senderKID);
35   int ossl_cmp_hdr_generalinfo_item_push0(OSSL_CMP_PKIHEADER *hdr,
36                                           OSSL_CMP_ITAV *itav);
37   int ossl_cmp_hdr_generalinfo_items_push1(OSSL_CMP_PKIHEADER *hdr,
38                                            STACK_OF(OSSL_CMP_ITAV) *itavs);
39   int ossl_cmp_hdr_push0_freeText(OSSL_CMP_PKIHEADER *hdr,
40                                   ASN1_UTF8STRING *text);
41   int ossl_cmp_hdr_push1_freeText(OSSL_CMP_PKIHEADER *hdr,
42                                   ASN1_UTF8STRING *text);
43   int ossl_cmp_hdr_set_implicitConfirm(OSSL_CMP_PKIHEADER *hdr);
44   int ossl_cmp_hdr_check_implicitConfirm(OSSL_CMP_PKIHEADER *hdr);
45   int ossl_cmp_hdr_init(OSSL_CMP_CTX *ctx, OSSL_CMP_PKIHEADER *hdr);
46
47 =head1 DESCRIPTION
48
49 ossl_cmp_hdr_set_pvno() sets hdr->pvno to the given B<pvno>.
50
51 ossl_cmp_hdr_get_pvno() returns the pvno of the given B<hdr> or -1 on error.
52
53 ossl_cmp_hdr_get0_sendernonce() returns the sender nonce of the given PKIHeader.
54
55 ossl_cmp_hdr_set1_sender() sets the sender field in the given PKIHeader
56 to the given X509 Name value, without consuming the pointer.
57
58 ossl_cmp_hdr_set1_recipient() sets the recipient field in the given
59 PKIHeader to the given X509 Name value, without consuming the pointer.
60 If B<nm> is NULL, recipient is set to the NULL DN (the empty list of strings).
61
62 ossl_cmp_hdr_update_messagetime() (re-)sets the messageTime to the current
63 system time. As written in RFC 4210, section 5.1.1:
64 The messageTime field contains the time at which the sender created the message.
65 This may be useful to allow end entities to correct/check their local time for
66 consistency with the time on a central system.
67
68 ossl_cmp_hdr_set1_senderKID() Sets hdr->senderKID to the given string.
69 In an PBMAC-protected IR this usually is a reference number issued by the CA,
70 else the subject key ID of the sender's protecting certificate.
71
72 ossl_cmp_hdr_push0_freeText() pushes an ASN1_UTF8STRING to
73 hdr->freeText and consumes the given pointer.
74
75 ossl_cmp_hdr_push1_freeText() pushes an ASN1_UTF8STRING to
76 hdr->freeText and does not consume the pointer.
77
78 ossl_cmp_hdr_generalinfo_item_push0() adds the given InfoTypeAndValue
79 item to the hdr->generalInfo stack. Consumes the B<itav> pointer.
80
81 ossl_cmp_hdr_generalinfo_items_push1() adds a copy of the B<itavs> stack to
82 the generalInfo field of PKIheader of the B<hdr>. Does not consume the B<itavs>
83 pointer.
84
85 ossl_cmp_hdr_set_implicitConfirm() sets implicitConfirm in the generalInfo field
86 of the PKIMessage header.
87
88 ossl_cmp_hdr_check_implicitConfirm() returns 1 if implicitConfirm is
89 set int generalInfo field of the given PKIMessage header, 0 if not.
90
91 ossl_cmp_hdr_init() initializes a PKIHeader structure based on the
92 values in the given OSSL_CMP_CTX structure.
93 This starts a new transaction in case ctx->transactionID is NULL.
94 The sender name is copied from the subject of the client cert, if any,
95 or else from the subject name provided for certification requests.
96 As required by RFC 4210 section 5.1.1., if the sender name is not known
97 to the client it set to the NULL-DN. In this case for identification at least
98 the senderKID must be set, which we take from any referenceValue provided.
99
100 =head1 NOTES
101
102 CMP is defined in RFC 4210 (and CRMF in RFC 4211).
103
104 =head1 RETURN VALUES
105
106 ossl_cmp_hdr_get_pvno() returns the pvno of the given B<hdr> or -1 on error.
107
108 ossl_cmp_hdr_get0_sendernonce() returns the respective nonce.
109
110 All other functions return 1 on success, 0 on error.
111
112 See the individual functions above.
113
114 =head1 HISTORY
115
116 The OpenSSL CMP support was added in OpenSSL 3.0.
117
118 =head1 COPYRIGHT
119
120 Copyright 2007-2019 The OpenSSL Project Authors. All Rights Reserved.
121
122 Licensed under the Apache License 2.0 (the "License").  You may not use
123 this file except in compliance with the License.  You can obtain a copy
124 in the file LICENSE in the source distribution or at
125 L<https://www.openssl.org/source/license.html>.
126
127 =cut