4da735f801813cb5bd3bb5d9fa6ad3fcf5898905
[platform/upstream/krb5.git] / src / plugins / preauth / pkinit / pkinit_trace.h
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* plugins/preauth/pkinit/pkinit_trace.h - PKINIT tracing macros */
3 /*
4  * Copyright (C) 2012 by the Massachusetts Institute of Technology.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  *   notice, this list of conditions and the following disclaimer.
13  *
14  * * Redistributions in binary form must reproduce the above copyright
15  *   notice, this list of conditions and the following disclaimer in
16  *   the documentation and/or other materials provided with the
17  *   distribution.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
28  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
30  * OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef PKINIT_TRACE_H
34 #define PKINIT_TRACE_H
35
36 #include "k5-trace.h"
37
38 #define TRACE_PKINIT_CLIENT_EKU_ACCEPT(c)                       \
39     TRACE(c, "PKINIT client found acceptable EKU in KDC cert")
40 #define TRACE_PKINIT_CLIENT_EKU_REJECT(c)                               \
41     TRACE(c, "PKINIT client found no acceptable EKU in KDC cert")
42 #define TRACE_PKINIT_CLIENT_EKU_SKIP(c)                                 \
43     TRACE(c, "PKINIT client skipping EKU check due to configuration")
44 #define TRACE_PKINIT_CLIENT_FRESHNESS_TOKEN(c)                  \
45     TRACE(c, "PKINIT client received freshness token from KDC")
46 #define TRACE_PKINIT_CLIENT_KDF_ALG(c, kdf, keyblock)                   \
47     TRACE(c, "PKINIT client used KDF {hexdata} to compute reply key "   \
48           "{keyblock}", kdf, keyblock)
49 #define TRACE_PKINIT_CLIENT_KDF_OS2K(c, keyblock)                       \
50     TRACE(c, "PKINIT client used octetstring2key to compute reply key " \
51           "{keyblock}", keyblock)
52 #define TRACE_PKINIT_CLIENT_NO_DRAFT9(c)                                \
53     TRACE(c, "PKINIT client ignoring draft 9 offer from RFC 4556 KDC")
54 #define TRACE_PKINIT_CLIENT_NO_IDENTITY(c)                              \
55     TRACE(c, "PKINIT client has no configured identity; giving up")
56 #define TRACE_PKINIT_CLIENT_REP_CHECKSUM_FAIL(c, expected, received)    \
57     TRACE(c, "PKINIT client checksum mismatch: expected {cksum}, "      \
58           "received {cksum}", expected, received)
59 #define TRACE_PKINIT_CLIENT_REP_DH(c)           \
60     TRACE(c, "PKINIT client verified DH reply")
61 #define TRACE_PKINIT_CLIENT_REP_DH_FAIL(c)              \
62     TRACE(c, "PKINIT client could not verify DH reply")
63 #define TRACE_PKINIT_CLIENT_REP_RSA(c)                  \
64     TRACE(c, "PKINIT client verified RSA reply")
65 #define TRACE_PKINIT_CLIENT_REP_RSA_KEY(c, keyblock, cksum)             \
66     TRACE(c, "PKINIT client retrieved reply key {keyblock} from RSA "   \
67           "reply (checksum {cksum})", keyblock, cksum)
68 #define TRACE_PKINIT_CLIENT_REP_RSA_FAIL(c)                     \
69     TRACE(c, "PKINIT client could not verify RSA reply")
70 #define TRACE_PKINIT_CLIENT_REQ_CHECKSUM(c, cksum)                      \
71     TRACE(c, "PKINIT client computed kdc-req-body checksum {cksum}", cksum)
72 #define TRACE_PKINIT_CLIENT_REQ_DH(c)                           \
73     TRACE(c, "PKINIT client making DH request")
74 #define TRACE_PKINIT_CLIENT_REQ_RSA(c)                  \
75     TRACE(c, "PKINIT client making RSA request")
76 #define TRACE_PKINIT_CLIENT_SAN_CONFIG_DNSNAME(c, host)                 \
77     TRACE(c, "PKINIT client config accepts KDC dNSName SAN {str}", host)
78 #define TRACE_PKINIT_CLIENT_SAN_MATCH_DNSNAME(c, host)                  \
79     TRACE(c, "PKINIT client matched KDC hostname {str} against "     \
80           "dNSName SAN; EKU check still required", host)
81 #define TRACE_PKINIT_CLIENT_SAN_MATCH_NONE(c)                           \
82     TRACE(c, "PKINIT client found no acceptable SAN in KDC cert")
83 #define TRACE_PKINIT_CLIENT_SAN_MATCH_PRINC(c, princ)                   \
84     TRACE(c, "PKINIT client matched KDC principal {princ} against "     \
85           "id-pkinit-san; no EKU check required", princ)
86 #define TRACE_PKINIT_CLIENT_SAN_ERR(c)                          \
87     TRACE(c, "PKINIT client failed to decode SANs in KDC cert")
88 #define TRACE_PKINIT_CLIENT_SAN_KDCCERT_DNSNAME(c, host)                \
89     TRACE(c, "PKINIT client found dNSName SAN in KDC cert: {str}", host)
90 #define TRACE_PKINIT_CLIENT_SAN_KDCCERT_PRINC(c, princ)                 \
91     TRACE(c, "PKINIT client found id-pkinit-san in KDC cert: {princ}", princ)
92 #define TRACE_PKINIT_CLIENT_TRYAGAIN(c)                                 \
93     TRACE(c, "PKINIT client trying again with KDC-provided parameters")
94
95 #define TRACE_PKINIT_OPENSSL_ERROR(c, msg)              \
96     TRACE(c, "PKINIT OpenSSL error: {str}", msg)
97
98 #define TRACE_PKINIT_SERVER_CERT_AUTH(c, modname)                       \
99     TRACE(c, "PKINIT server authorizing cert with module {str}",        \
100           modname)
101 #define TRACE_PKINIT_SERVER_EKU_REJECT(c)                               \
102     TRACE(c, "PKINIT server found no acceptable EKU in client cert")
103 #define TRACE_PKINIT_SERVER_EKU_SKIP(c)                                 \
104     TRACE(c, "PKINIT server skipping EKU check due to configuration")
105 #define TRACE_PKINIT_SERVER_INIT_REALM(c, realm)                \
106     TRACE(c, "PKINIT server initializing realm {str}", realm)
107 #define TRACE_PKINIT_SERVER_INIT_FAIL(c, realm, retval)                 \
108     TRACE(c, "PKINIT server initialization failed for realm {str}: {kerr}", \
109           realm, retval)
110 #define TRACE_PKINIT_SERVER_MATCHING_UPN_FOUND(c)                       \
111     TRACE(c, "PKINIT server found a matching UPN SAN in client cert")
112 #define TRACE_PKINIT_SERVER_MATCHING_SAN_FOUND(c)                       \
113     TRACE(c, "PKINIT server found a matching SAN in client cert")
114 #define TRACE_PKINIT_SERVER_NO_SAN(c)                           \
115     TRACE(c, "PKINIT server found no SAN in client cert")
116 #define TRACE_PKINIT_SERVER_PADATA_VERIFY(c)                    \
117     TRACE(c, "PKINIT server verifying KRB5_PADATA_PK_AS_REQ")
118 #define TRACE_PKINIT_SERVER_PADATA_VERIFY_OLD(c)                        \
119     TRACE(c, "PKINIT server verifying KRB5_PADATA_PK_AS_REQ_OLD")
120 #define TRACE_PKINIT_SERVER_PADATA_VERIFY_FAIL(c)       \
121     TRACE(c, "PKINIT server failed to verify PA data")
122 #define TRACE_PKINIT_SERVER_RETURN_PADATA(c)    \
123     TRACE(c, "PKINIT server returning PA data")
124 #define TRACE_PKINIT_SERVER_SAN_REJECT(c)                               \
125     TRACE(c, "PKINIT server found no acceptable SAN in client cert")
126 #define TRACE_PKINIT_SERVER_UPN_PARSE_FAIL(c, upn, ret)                 \
127     TRACE(c, "PKINIT server could not parse UPN \"{str}\": {kerr}",     \
128           upn, ret)
129
130 #define TRACE_PKINIT_EKU(c)                                             \
131     TRACE(c, "PKINIT found acceptable EKU and digitalSignature KU")
132 #define TRACE_PKINIT_EKU_NO_KU(c)                                       \
133     TRACE(c, "PKINIT found acceptable EKU but no digitalSignature KU")
134 #define TRACE_PKINIT_LOADED_CERT(c, name)                       \
135     TRACE(c, "PKINIT loaded cert and key for {str}", name)
136 #define TRACE_PKINIT_LOAD_FROM_FILE(c)                          \
137     TRACE(c, "PKINIT loading CA certs and CRLs from FILE")
138 #define TRACE_PKINIT_LOAD_FROM_DIR(c)                           \
139     TRACE(c, "PKINIT loading CA certs and CRLs from DIR")
140 #define TRACE_PKINIT_NO_CA_ANCHOR(c, file)              \
141     TRACE(c, "PKINIT no anchor CA in file {str}", file)
142 #define TRACE_PKINIT_NO_CA_INTERMEDIATE(c, file)                \
143     TRACE(c, "PKINIT no intermediate CA in file {str}", file)
144 #define TRACE_PKINIT_NO_CERT(c)                 \
145     TRACE(c, "PKINIT no certificate provided")
146 #define TRACE_PKINIT_NO_CERT_AND_KEY(c, dirname)                        \
147     TRACE(c, "PKINIT no cert and key pair found in directory {str}",    \
148           dirname)
149 #define TRACE_PKINIT_NO_CRL(c, file)                    \
150     TRACE(c, "PKINIT no CRL in file {str}", file)
151 #define TRACE_PKINIT_NO_DEFAULT_CERT(c, count)                          \
152     TRACE(c, "PKINIT error: There are {int} certs, but there must "     \
153           "be exactly one.", count)
154 #define TRACE_PKINIT_NO_MATCHING_CERT(c)                \
155     TRACE(c, "PKINIT no matching certificate found")
156 #define TRACE_PKINIT_NO_PRIVKEY(c)              \
157     TRACE(c, "PKINIT no private key provided")
158 #define TRACE_PKINIT_PKCS_DECODE_FAIL(c, name)                          \
159     TRACE(c, "PKINIT failed to decode PKCS12 file {str} contents", name)
160 #define TRACE_PKINIT_PKCS_OPEN_FAIL(c, name, err)                       \
161     TRACE(c, "PKINIT failed to open PKCS12 file {str}: err {errno}",    \
162           name, err)
163 #define TRACE_PKINIT_PKCS_PARSE_FAIL_FIRST(c)                           \
164     TRACE(c, "PKINIT initial PKCS12_parse with no password failed")
165 #define TRACE_PKINIT_PKCS_PARSE_FAIL_SECOND(c)                          \
166     TRACE(c, "PKINIT second PKCS12_parse with password failed")
167 #define TRACE_PKINIT_PKCS_PROMPT_FAIL(c)                        \
168     TRACE(c, "PKINIT failed to prompt for PKCS12 password")
169
170 #define TRACE_CERTAUTH_VTINIT_FAIL(c, ret)                              \
171     TRACE(c, "certauth module failed to init vtable: {kerr}", ret)
172 #define TRACE_CERTAUTH_INIT_FAIL(c, name, ret)                          \
173     TRACE(c, "certauth module {str} failed to init: {kerr}", name, ret)
174
175 #endif /* PKINIT_TRACE_H */