]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/ellipticProj.h
Security-57740.1.18.tar.gz
[apple/security.git] / OSX / libsecurity_cryptkit / lib / ellipticProj.h
1 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
2 *
3 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
4 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
5 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
7 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
10 *
11 * ellipticProj.h - declaration of elliptic projective algebra routines.
12 *
13 * Revision History
14 * ----------------
15 * 10/06/98 ap
16 * Changed to compile with C++.
17 * 1 Sep 1998 at Apple
18 * Created.
19 */
20
21 #ifndef _CRYPTKIT_ELLIPTIC_PROJ_H_
22 #define _CRYPTKIT_ELLIPTIC_PROJ_H_
23
24 #include "ckconfig.h"
25
26 #if CRYPTKIT_ELL_PROJ_ENABLE
27
28 #include "giantIntegers.h"
29 #include "curveParams.h"
30
31 /*
32 * A projective point.
33 */
34 typedef struct {
35 giant x;
36 giant y;
37 giant z;
38 } pointProjStruct;
39
40 typedef pointProjStruct *pointProj;
41
42 pointProj /* Allocates a new projective point. */
43 newPointProj(unsigned numDigits);
44
45 void /* Frees point. */
46 freePointProj(pointProj pt);
47
48 void /* Copies point to point; pt2 := pt1. */
49 ptopProj(pointProj pt1, pointProj pt2);
50
51 void /* Point doubling. */
52 ellDoubleProj(pointProj pt, curveParams *cp);
53
54 void /* Point adding; pt0 := pt0 - pt1. */
55 ellAddProj(pointProj pt0, pointProj pt1, curveParams *cp);
56
57 void /* Point negation; pt := -pt. */
58 ellNegProj(pointProj pt, curveParams *cp);
59
60 void /* Point subtraction; pt0 := pt0 - pt1. */
61 ellSubProj(pointProj pt0, pointProj pt1, curveParams *cp);
62
63 void /* pt := pt * k, result normalized */
64 ellMulProjSimple(pointProj pt0, giant k, curveParams *cp);
65
66 void /* General elliptic mul; pt1 := k*pt0. */
67 ellMulProj(pointProj pt0, pointProj pt1, giant k, curveParams *cp);
68
69 void /* Generate normalized point (X, Y, 1) from given (x,y,z). */
70 normalizeProj(pointProj pt, curveParams *cp);
71
72 void /* Find a point (x, y, 1) on the curve. */
73 findPointProj(pointProj pt, giant seed, curveParams *cp);
74
75 #endif /* CRYPTKIT_ELL_PROJ_ENABLE*/
76 #endif /* _CRYPTKIT_ELLIPTIC_PROJ_H_ */