File indexing completed on 2025-01-18 10:05:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef OPENSSL_TRACE_H
0011 # define OPENSSL_TRACE_H
0012 # pragma once
0013
0014 # include <stdarg.h>
0015
0016 # include <openssl/bio.h>
0017
0018 # ifdef __cplusplus
0019 extern "C" {
0020 # endif
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 # define OSSL_TRACE_CATEGORY_ALL 0
0041 # define OSSL_TRACE_CATEGORY_TRACE 1
0042 # define OSSL_TRACE_CATEGORY_INIT 2
0043 # define OSSL_TRACE_CATEGORY_TLS 3
0044 # define OSSL_TRACE_CATEGORY_TLS_CIPHER 4
0045 # define OSSL_TRACE_CATEGORY_CONF 5
0046 # define OSSL_TRACE_CATEGORY_ENGINE_TABLE 6
0047 # define OSSL_TRACE_CATEGORY_ENGINE_REF_COUNT 7
0048 # define OSSL_TRACE_CATEGORY_PKCS5V2 8
0049 # define OSSL_TRACE_CATEGORY_PKCS12_KEYGEN 9
0050 # define OSSL_TRACE_CATEGORY_PKCS12_DECRYPT 10
0051 # define OSSL_TRACE_CATEGORY_X509V3_POLICY 11
0052 # define OSSL_TRACE_CATEGORY_BN_CTX 12
0053 # define OSSL_TRACE_CATEGORY_CMP 13
0054 # define OSSL_TRACE_CATEGORY_STORE 14
0055 # define OSSL_TRACE_CATEGORY_DECODER 15
0056 # define OSSL_TRACE_CATEGORY_ENCODER 16
0057 # define OSSL_TRACE_CATEGORY_REF_COUNT 17
0058 # define OSSL_TRACE_CATEGORY_HTTP 18
0059
0060 # define OSSL_TRACE_CATEGORY_NUM 19
0061
0062
0063
0064 int OSSL_trace_get_category_num(const char *name);
0065
0066
0067 const char *OSSL_trace_get_category_name(int num);
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080 int OSSL_trace_set_channel(int category, BIO* channel);
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 int OSSL_trace_set_prefix(int category, const char *prefix);
0092 int OSSL_trace_set_suffix(int category, const char *suffix);
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105 typedef size_t (*OSSL_trace_cb)(const char *buffer, size_t count,
0106 int category, int cmd, void *data);
0107
0108
0109
0110 # define OSSL_TRACE_CTRL_BEGIN 0
0111 # define OSSL_TRACE_CTRL_WRITE 1
0112 # define OSSL_TRACE_CTRL_END 2
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125 int OSSL_trace_set_callback(int category, OSSL_trace_cb callback, void *data);
0126
0127
0128
0129
0130
0131
0132
0133
0134 int OSSL_trace_enabled(int category);
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153 BIO *OSSL_trace_begin(int category);
0154 void OSSL_trace_end(int category, BIO *channel);
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 # if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE
0202
0203 # define OSSL_TRACE_BEGIN(category) \
0204 do { \
0205 BIO *trc_out = OSSL_trace_begin(OSSL_TRACE_CATEGORY_##category); \
0206 \
0207 if (trc_out != NULL)
0208
0209 # define OSSL_TRACE_END(category) \
0210 OSSL_trace_end(OSSL_TRACE_CATEGORY_##category, trc_out); \
0211 } while (0)
0212
0213 # define OSSL_TRACE_CANCEL(category) \
0214 OSSL_trace_end(OSSL_TRACE_CATEGORY_##category, trc_out) \
0215
0216 # else
0217
0218 # define OSSL_TRACE_BEGIN(category) \
0219 do { \
0220 BIO *trc_out = NULL; \
0221 if (0)
0222
0223 # define OSSL_TRACE_END(category) \
0224 } while(0)
0225
0226 # define OSSL_TRACE_CANCEL(category) \
0227 ((void)0)
0228
0229 # endif
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240 # if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE
0241
0242 # define OSSL_TRACE_ENABLED(category) \
0243 OSSL_trace_enabled(OSSL_TRACE_CATEGORY_##category)
0244
0245 # else
0246
0247 # define OSSL_TRACE_ENABLED(category) (0)
0248
0249 # endif
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273 # if !defined OPENSSL_NO_TRACE && !defined FIPS_MODULE
0274
0275 # define OSSL_TRACEV(category, args) \
0276 OSSL_TRACE_BEGIN(category) \
0277 BIO_printf args; \
0278 OSSL_TRACE_END(category)
0279
0280 # else
0281
0282 # define OSSL_TRACEV(category, args) ((void)0)
0283
0284 # endif
0285
0286 # define OSSL_TRACE(category, text) \
0287 OSSL_TRACEV(category, (trc_out, "%s", text))
0288
0289 # define OSSL_TRACE1(category, format, arg1) \
0290 OSSL_TRACEV(category, (trc_out, format, arg1))
0291 # define OSSL_TRACE2(category, format, arg1, arg2) \
0292 OSSL_TRACEV(category, (trc_out, format, arg1, arg2))
0293 # define OSSL_TRACE3(category, format, arg1, arg2, arg3) \
0294 OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3))
0295 # define OSSL_TRACE4(category, format, arg1, arg2, arg3, arg4) \
0296 OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4))
0297 # define OSSL_TRACE5(category, format, arg1, arg2, arg3, arg4, arg5) \
0298 OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5))
0299 # define OSSL_TRACE6(category, format, arg1, arg2, arg3, arg4, arg5, arg6) \
0300 OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6))
0301 # define OSSL_TRACE7(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
0302 OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7))
0303 # define OSSL_TRACE8(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
0304 OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
0305 # define OSSL_TRACE9(category, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
0306 OSSL_TRACEV(category, (trc_out, format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
0307
0308 #define OSSL_TRACE_STRING_MAX 80
0309 int OSSL_trace_string(BIO *out, int text, int full,
0310 const unsigned char *data, size_t size);
0311 #define OSSL_TRACE_STRING(category, text, full, data, len) \
0312 OSSL_TRACE_BEGIN(category) { \
0313 OSSL_trace_string(trc_out, text, full, data, len); \
0314 } OSSL_TRACE_END(category)
0315
0316 # ifdef __cplusplus
0317 }
0318 # endif
0319
0320 #endif