]>
git.saurik.com Git - apple/security.git/blob - libsecurity_cryptkit/lib/feeDebug.h
4 Contains: Debug macros.
6 Written by: Doug Mitchell
8 Copyright: Copyright 1998 by Apple Computer, Inc.
11 Change History (most recent first):
13 <9> 10/06/98 ap Changed to compile with C++.
18 /* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
20 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
21 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
22 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE COMPUTER, INC. AND THE
23 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE COMPUTER,
24 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
25 * EXPOSE YOU TO LIABILITY.
26 ***************************************************************************
29 #ifndef _CK_FEEDEBUG_H_
30 #define _CK_FEEDEBUG_H_
32 #include "giantIntegers.h"
34 #include "curveParams.h"
50 extern void printGiant(const giant x
);
51 extern void printGiantHex(const giant x
);
52 extern void printGiantExp(const giant x
);
53 extern void printKey(const key k
);
54 extern void printCurveParams(const curveParams
*p
);
58 #define dbgLog(x) printf x
65 #endif /* FEE_DEBUG */
70 #define FEE_PROFILE 0 /* general purpose profile */
71 #define ELL_PROFILE 0 /* ell_even/ell_odd only */
73 #if (FEE_PROFILE || ELL_PROFILE)
74 #include <kern/time_stamp.h>
75 #endif /* (FEE_PROFILE || ELL_PROFILE) */
78 * Place this macro after the last local and before any code in a routine
82 struct tsval _profStartTime; \
83 struct tsval _profEndTime; \
84 kern_timestamp(&_profStartTime);
87 * This one goes at the end of the routine, just before the (only) return.
88 * There must be a static accumulator (an unsigned int) on a per-routine basis.
90 #define CPROF_END(accum) \
91 kern_timestamp(&_profEndTime); \
92 accum += (_profEndTime.low_val - _profStartTime.low_val);
95 * Increment a profiling counter.
97 #define CPROF_INCR(ctr) ctr++
101 #define PROF_START CPROF_START
102 #define PROF_END(a) CPROF_END(a)
103 #define PROF_INCR(ctr) CPROF_INCR(ctr)
106 * As of 14 Apr 1998, we no longer time mulg or gsquare calls with this
107 * mechanism; the time overhead is the same magnitude as the mulg. Instead
108 * we'll just count the mulgs and gsquares.
110 #define PROF_TIME_MULGS 0
116 extern unsigned ellAddTime
;
117 extern unsigned whichCurveTime
;
118 extern unsigned ellipticTime
;
119 extern unsigned sigCompTime
;
122 * low-level primitives
124 extern unsigned numerDoubleTime
;
125 extern unsigned numerPlusTime
;
126 extern unsigned numerTimesTime
;
127 extern unsigned denomDoubleTime
;
128 extern unsigned denomTimesTime
;
129 extern unsigned powerModTime
;
130 extern unsigned modgTime
;
131 extern unsigned binvauxTime
;
134 * Counters for calculating microseconds per {mulg, feemod, ...}
136 extern unsigned numMulg
;
137 extern unsigned numFeemod
;
138 extern unsigned numGsquare
;
139 extern unsigned numBorrows
;
141 extern void clearProfile();
143 #else /* FEE_PROFILE */
146 #define PROF_INCR(ctr)
147 #endif /* FEE_PROFILE */
150 extern unsigned ellOddTime
;
151 extern unsigned ellEvenTime
;
152 extern unsigned numEllOdds
;
153 extern unsigned numEllEvens
;
154 extern void clearEllProfile();
156 #define EPROF_START CPROF_START
157 #define EPROF_END(a) CPROF_END(a)
158 #define EPROF_INCR(ctr) CPROF_INCR(ctr)
160 #else /* ELL_PROFILE */
163 #define EPROF_INCR(ctr)
164 #endif /* ELL_PROFILE */
167 * NULL gets defined externally if FEE_DEBUG is true..
171 #define NULL ((void *)0)
173 #endif /* !FEE_DEBUG */
177 #include "platform.h"
179 #define CKASSERT(expression) \
180 ((expression) ? (void)0 : \
181 (printf ("Assertion failed: " #expression \
182 ", file " __FILE__ ", line %d.\n", __LINE__), \
183 CKRaise("Assertion Failure")))
185 #else /* FEE_DEBUG */
187 #define CKASSERT(expression)
189 #endif /* FEE_DEBUG */
195 #endif /* _CK_FEEDEBUG_H_ */