]> git.saurik.com Git - apple/security.git/blame_incremental - OSX/libsecurity_ssl/lib/sslDebug.h
Security-58286.41.2.tar.gz
[apple/security.git] / OSX / libsecurity_ssl / lib / sslDebug.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 2000-2001,2005-2007,2010-2012,2014 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24/*
25 * sslDebug.h - Debugging macros.
26 */
27
28#ifndef _SSL_DEBUG_H_
29#define _SSL_DEBUG_H_
30
31#ifdef KERNEL
32/* TODO: support secinfo in the kernel */
33#define secinfo(x...)
34#else /* KERNEL */
35#include <utilities/debugging.h>
36#endif
37
38#ifndef NDEBUG
39#include <AssertMacros.h>
40#endif
41
42
43#define ssl_secinfo secinfo
44
45#ifndef NDEBUG
46
47/* log changes in handshake state */
48#define sslHdskStateDebug(args...) ssl_secinfo("sslHdskState", ## args)
49
50/* log handshake and alert messages */
51#define sslHdskMsgDebug(args...) ssl_secinfo("sslHdskMsg", ## args)
52
53/* log negotiated handshake parameters */
54#define sslLogNegotiateDebug(args...) ssl_secinfo("sslLogNegotiate", ## args)
55
56/* log received protocol messsages */
57#define sslLogRxProtocolDebug(msgType) ssl_secinfo("sslLogRxProtocol", \
58 "---received protoMsg %s", msgType)
59
60/* log resumable session info */
61#define sslLogResumSessDebug(args...) ssl_secinfo("sslResumSession", ## args)
62
63/* log low-level session info in appleSession.c */
64#define sslLogSessCacheDebug(args...) ssl_secinfo("sslSessionCache", ## args)
65
66/* log record-level I/O (SSLRead, SSLWrite) */
67#define sslLogRecordIo(args...) ssl_secinfo("sslRecordIo", ## args)
68
69/* cert-related info */
70#define sslCertDebug(args...) ssl_secinfo("sslCert", ## args)
71
72/* Diffie-Hellman */
73#define sslDhDebug(args...) ssl_secinfo("sslDh", ## args)
74
75/* EAP-FAST PAC-based session resumption */
76#define sslEapDebug(args...) ssl_secinfo("sslEap", ## args)
77
78/* ECDSA */
79#define sslEcdsaDebug(args...) ssl_secinfo("sslEcdsa", ## args)
80
81#else /* NDEBUG */
82
83/* deployment build */
84#define sslHdskStateDebug(args...)
85#define sslHdskMsgDebug(args...)
86#define sslLogNegotiateDebug(args...)
87#define sslLogRxProtocolDebug(msgType)
88#define sslLogResumSessDebug(args...)
89#define sslLogSessCacheDebug(args...)
90#define sslLogRecordIo(args...)
91#define sslCertDebug(args...)
92#define sslDhDebug(args...)
93#define sslEapDebug(args...)
94#define sslEcdsaDebug(args...)
95
96#endif /*
97NDEBUG */
98
99#ifdef NDEBUG
100
101/* all errors logged to stdout for DEBUG config only */
102#define sslErrorLog(args...)
103#define sslDebugLog(args...)
104#define sslDump(d, l)
105
106#else
107
108extern void SSLDump(const unsigned char *data, unsigned long len);
109
110/* extra debug logging of non-error conditions, if SSL_DEBUG is defined */
111#if SSL_DEBUG
112//#define sslDebugLog(args...) printf(args)
113#define sslDebugLog(args...) ssl_secinfo("sslDebug", ## args)
114#else
115#define sslDebugLog(args...)
116#endif
117/* all errors logged to stdout for DEBUG config only */
118//#define sslErrorLog(args...) printf(args)
119#define sslErrorLog(args...) ssl_secinfo("sslError", ## args)
120#define sslDump(d, l) SSLDump((d), (l))
121
122#endif /* NDEBUG */
123
124
125#ifdef NDEBUG
126#define ASSERT(s)
127#else
128#define ASSERT(s) check(s)
129#endif
130
131#endif /* _SSL_DEBUG_H_ */