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 */ 34typedef struct { 35 giant x; 36 giant y; 37 giant z; 38} pointProjStruct; 39 40typedef pointProjStruct *pointProj; 41 42pointProj /* Allocates a new projective point. */ 43newPointProj(unsigned numDigits); 44 45void /* Frees point. */ 46freePointProj(pointProj pt); 47 48void /* Copies point to point; pt2 := pt1. */ 49ptopProj(pointProj pt1, pointProj pt2); 50 51void /* Point doubling. */ 52ellDoubleProj(pointProj pt, curveParams *cp); 53 54void /* Point adding; pt0 := pt0 - pt1. */ 55ellAddProj(pointProj pt0, pointProj pt1, curveParams *cp); 56 57void /* Point negation; pt := -pt. */ 58ellNegProj(pointProj pt, curveParams *cp); 59 60void /* Point subtraction; pt0 := pt0 - pt1. */ 61ellSubProj(pointProj pt0, pointProj pt1, curveParams *cp); 62 63void /* pt := pt * k, result normalized */ 64ellMulProjSimple(pointProj pt0, giant k, curveParams *cp); 65 66void /* General elliptic mul; pt1 := k*pt0. */ 67ellMulProj(pointProj pt0, pointProj pt1, giant k, curveParams *cp); 68 69void /* Generate normalized point (X, Y, 1) from given (x,y,z). */ 70normalizeProj(pointProj pt, curveParams *cp); 71 72void /* Find a point (x, y, 1) on the curve. */ 73findPointProj(pointProj pt, giant seed, curveParams *cp); 74 75#endif /* CRYPTKIT_ELL_PROJ_ENABLE*/ 76#endif /* _CRYPTKIT_ELLIPTIC_PROJ_H_ */ 77