]> git.saurik.com Git - apple/security.git/blob - libsecurity_cryptkit/lib/ellipticMeasure.h
Security-55471.tar.gz
[apple/security.git] / libsecurity_cryptkit / lib / ellipticMeasure.h
1 /*
2 File: ellipticMeasure.h
3
4 Contains: xxx put contents here xxx
5
6 Written by: Doug Mitchell
7
8 Copyright: Copyright 1998 by Apple Computer, Inc.
9 All rights reserved.
10
11 Change History (most recent first):
12
13 <7> 10/06/98 ap Changed to compile with C++.
14
15 To Do:
16 */
17
18 /* Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
19 *
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 ***************************************************************************
27 *
28 * Measurement of feemods and mulgs withing an elliptic_simple() call.
29 */
30
31 #include "feeDebug.h"
32
33 #ifdef FEE_DEBUG
34 #define ELLIPTIC_MEASURE 0
35 #else // FEE_DEBUG
36 #define ELLIPTIC_MEASURE 0 /* always off */
37 #endif // FEE_DEBUG
38
39 #if ELLIPTIC_MEASURE
40
41 extern int doEllMeasure; // gather stats on/off */
42 extern int bitsInN;
43 extern int numFeeMods;
44 extern int numMulgs;
45
46 #define START_ELL_MEASURE(n) \
47 doEllMeasure = 1; \
48 bitsInN = bitlen(n); \
49 numFeeMods = 0; \
50 numMulgs = 0;
51
52 #define END_ELL_MEASURE doEllMeasure = 0;
53
54 #define INCR_FEEMODS \
55 if(doEllMeasure) { \
56 numFeeMods++; \
57 }
58
59 #define INCR_MULGS \
60 if(doEllMeasure) { \
61 numMulgs++; \
62 }
63
64 /*
65 * These two are used around mulg() calls in feemod() itself; they
66 * inhibit the counting of those mulg() calls.
67 */
68 #define PAUSE_ELL_MEASURE \
69 { \
70 int tempEllMeasure = doEllMeasure; \
71 doEllMeasure = 0;
72
73 #define RESUME_ELL_MEASURE \
74 doEllMeasure = tempEllMeasure; \
75 }
76
77 #else // ELLIPTIC_MEASURE
78
79 #define START_ELL_MEASURE(n)
80 #define END_ELL_MEASURE
81 #define INCR_FEEMODS
82 #define INCR_MULGS
83 #define PAUSE_ELL_MEASURE
84 #define RESUME_ELL_MEASURE
85
86 #endif // ELLIPTIC_MEASURE