]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/ellipticMeasure.h
Security-58286.41.2.tar.gz
[apple/security.git] / OSX / libsecurity_cryptkit / lib / ellipticMeasure.h
1 /*
2 File: ellipticMeasure.h
3
4 Contains: xxx put contents here xxx
5
6
7 Copyright: Copyright (c) 1998,2011,2014 Apple Inc.
8 All rights reserved.
9
10 Change History (most recent first):
11
12 <7> 10/06/98 ap Changed to compile with C++.
13
14 To Do:
15 */
16
17 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
18 *
19 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
20 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
21 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
22 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
23 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
24 * EXPOSE YOU TO LIABILITY.
25 ***************************************************************************
26 *
27 * Measurement of feemods and mulgs withing an elliptic_simple() call.
28 */
29
30 #include "feeDebug.h"
31
32 #ifdef FEE_DEBUG
33 #define ELLIPTIC_MEASURE 0
34 #else // FEE_DEBUG
35 #define ELLIPTIC_MEASURE 0 /* always off */
36 #endif // FEE_DEBUG
37
38 #if ELLIPTIC_MEASURE
39
40 extern int doEllMeasure; // gather stats on/off */
41 extern int bitsInN;
42 extern int numFeeMods;
43 extern int numMulgs;
44
45 #define START_ELL_MEASURE(n) \
46 doEllMeasure = 1; \
47 bitsInN = bitlen(n); \
48 numFeeMods = 0; \
49 numMulgs = 0;
50
51 #define END_ELL_MEASURE doEllMeasure = 0;
52
53 #define INCR_FEEMODS \
54 if(doEllMeasure) { \
55 numFeeMods++; \
56 }
57
58 #define INCR_MULGS \
59 if(doEllMeasure) { \
60 numMulgs++; \
61 }
62
63 /*
64 * These two are used around mulg() calls in feemod() itself; they
65 * inhibit the counting of those mulg() calls.
66 */
67 #define PAUSE_ELL_MEASURE \
68 { \
69 int tempEllMeasure = doEllMeasure; \
70 doEllMeasure = 0;
71
72 #define RESUME_ELL_MEASURE \
73 doEllMeasure = tempEllMeasure; \
74 }
75
76 #else // ELLIPTIC_MEASURE
77
78 #define START_ELL_MEASURE(n)
79 #define END_ELL_MEASURE
80 #define INCR_FEEMODS
81 #define INCR_MULGS
82 #define PAUSE_ELL_MEASURE
83 #define RESUME_ELL_MEASURE
84
85 #endif // ELLIPTIC_MEASURE