0fd41403566870f532b0ce223eef193287a84eb0
[oweals/openssl.git] / doc / internal / man3 / ossl_cmp_msg_check_received.pod
1 =pod
2
3 =head1 NAME
4
5 ossl_cmp_allow_unprotected_cb_t,
6 ossl_cmp_msg_check_received
7 - does all checks on a received CMP message that can be done generically
8
9 =head1 SYNOPSIS
10
11  #include "cmp_local.h"
12
13  typedef int (*ossl_cmp_allow_unprotected_cb_t)(const OSSL_CMP_CTX *ctx,
14                                                 const OSSL_CMP_MSG *msg,
15                                                 int invalid_protection, int arg);
16
17  int ossl_cmp_msg_check_received(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *msg,
18                                  ossl_cmp_allow_unprotected_cb_t cb, int cb_arg);
19
20 =head1 DESCRIPTION
21
22 ossl_cmp_msg_check_received() checks the given message B<msg>,
23 which may be a server response or a request by some client.
24
25 It is ensured for the B<msg> that
26
27 =over 4
28
29 =item it has a valid body type,
30
31 =item its protection is present and valid (or a callback function B<cb>
32 is present and indicates that a missing or invalid protection is acceptable),
33
34 =item its recipNonce matches any previous senderNonce stored in B<ctx>, and
35
36 =item its transaction ID matches any previous transaction ID stored in B<ctx>.
37
38 =back
39
40 In case no protection is present and B<cb> is not NULL then this callback
41 function is called with its B<invalid_protection> parameter being 0, while in
42 case an invalid protection is present the B<invalid_protection> parameter is 1.
43 The callback is passed also the arguments B<ctx>, B<msg>, and <cb_arg>
44 (which typically contains the expected message type).
45 The callback should return 1 on acceptance, 0 on rejection, or -1 on error.
46 It should not put and error on the error stack since this could be misleading.
47
48 If all checks pass then ossl_cmp_msg_check_received()
49
50 =over 4
51
52 =item learns the senderNonce from the received message,
53
54 =item learns the transaction ID if it is not yet in B<ctx>, and
55
56 =item adds any extraCerts contained in the <msg> to the list of untrusted
57 certificates in B<ctx> for future use, such that
58 they are available already to the certificate confirmation callback and the
59 peer does not need to send them again (at least not in the same transaction).
60 For efficiency, the extraCerts are prepended to the list so they get used first.
61
62 =back
63
64 =head1 RETURN VALUES
65
66 ossl_cmp_msg_check_received() returns the message body type (which is >= 0)
67 on success, -1 on error.
68
69 =head1 SEE ALSO
70
71 L<OSSL_CMP_validate_msg(3)>
72
73 =head1 HISTORY
74
75 The OpenSSL CMP support was added in OpenSSL 3.0.
76
77 =head1 COPYRIGHT
78
79 Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
80
81 Licensed under the Apache License 2.0 (the "License").  You may not use
82 this file except in compliance with the License.  You can obtain a copy
83 in the file LICENSE in the source distribution or at
84 L<https://www.openssl.org/source/license.html>.
85
86 =cut