]> git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/ellipticProj.h
Security-59306.11.20.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 #include "giantIntegers.h"
27 #include "curveParams.h"
28
29 /*
30 * A projective point.
31 */
32 typedef struct {
33 giant x;
34 giant y;
35 giant z;
36 } pointProjStruct;
37
38 typedef pointProjStruct *pointProj;
39
40 pointProj /* Allocates a new projective point. */
41 newPointProj(unsigned numDigits);
42
43 void /* Frees point. */
44 freePointProj(pointProj pt);
45
46 void /* Copies point to point; pt2 := pt1. */
47 ptopProj(pointProj pt1, pointProj pt2);
48
49 void /* Point doubling. */
50 ellDoubleProj(pointProj pt, curveParams *cp);
51
52 void /* Point adding; pt0 := pt0 - pt1. */
53 ellAddProj(pointProj pt0, pointProj pt1, curveParams *cp);
54
55 void /* Point negation; pt := -pt. */
56 ellNegProj(pointProj pt, curveParams *cp);
57
58 void /* Point subtraction; pt0 := pt0 - pt1. */
59 ellSubProj(pointProj pt0, pointProj pt1, curveParams *cp);
60
61 void /* pt := pt * k, result normalized */
62 ellMulProjSimple(pointProj pt0, giant k, curveParams *cp);
63
64 void /* General elliptic mul; pt1 := k*pt0. */
65 ellMulProj(pointProj pt0, pointProj pt1, giant k, curveParams *cp);
66
67 void /* Generate normalized point (X, Y, 1) from given (x,y,z). */
68 normalizeProj(pointProj pt, curveParams *cp);
69
70 void /* Find a point (x, y, 1) on the curve. */
71 findPointProj(pointProj pt, giant seed, curveParams *cp);
72
73 #endif /* _CRYPTKIT_ELLIPTIC_PROJ_H_ */