1/* Copyright (c) 1998 Apple Computer, 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 COMPUTER, INC. AND THE
6 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE COMPUTER,
7 * INC.  ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
8 * EXPOSE YOU TO LIABILITY.
9 ***************************************************************************
10 *
11 * giantPort_PPC.h - PPC-dependent giant definitions.
12 *
13 * Revision History
14 * ----------------
15 * 10/06/98		ap
16 *	Changed to compile with C++.
17 * 06 Apr 1998	Doug Mitchell at Apple
18 *	Created.
19 */
20
21#ifndef	_CK_NSGIANT_PORT_PPC_H_
22#define _CK_NSGIANT_PORT_PPC_H_
23
24#include "feeDebug.h"
25#include "platform.h"
26#include "giantIntegers.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/**** FIXME - implement asm giant digits! ****/
33/*
34 * 0 ==> use function declarations from this file and implementation
35 *       in giantPort_PPC.c
36 * 1 ==> use static inline C function in giantPort_Generic.h
37 */
38/*@@@ HACK @@@
39#if defined NeXT
40#define PPC_GIANT_PORT_INLINE	1
41#else
42#define PPC_GIANT_PORT_INLINE	0
43#endif
44*/
45#define PPC_GIANT_PORT_INLINE	1
46
47#if	PPC_GIANT_PORT_INLINE
48
49#include "giantPort_Generic.h"
50
51#else	// PPC_GIANT_PORT_INLINE
52
53/*
54 * We'll be using the compiler's 64-bit long long for these routines.
55 *
56 * Mask for upper word.
57 */
58#define GIANT_UPPER_DIGIT_MASK	(~(unsigned long long(GIANT_DIGIT_MASK)))
59
60/*
61 * Multiple-precision arithmetic routines/macros. C for now, eventually
62 * they'll be in assembly.
63 */
64
65/*
66 * Add two digits, return sum. Carry bit returned as an out parameter.
67 * This should work any size giantDigits up to unsigned int.
68 */
69extern giantDigit giantAddDigits(
70	giantDigit dig1,
71	giantDigit dig2,
72	giantDigit *carry);			/* RETURNED, 0 or 1 */
73
74/*
75 * Add a single digit value to a double digit accumulator in place.
76 * Carry out of the MSD of the accumulator is not handled.
77 */
78void giantAddDouble(
79	giantDigit *accLow,			/* IN/OUT */
80	giantDigit *accHigh,			/* IN/OUT */
81	giantDigit val);
82
83
84/*
85 * Subtract a - b, return difference. Borrow bit returned as an out parameter.
86 */
87giantDigit giantSubDigits(
88	giantDigit a,
89	giantDigit b,
90	giantDigit *borrow);			/* RETURNED, 0 or 1 */
91
92
93/*
94 * Multiply two digits, return two digits.
95 */
96void giantMulDigits(
97	giantDigit	dig1,
98	giantDigit	dig2,
99 	giantDigit	*lowProduct,		/* RETURNED, low digit */
100	giantDigit	*hiProduct);		/* RETURNED, high digit */
101
102/*
103 * Multiply a vector of giantDigits, candVector, by a single giantDigit,
104 * plierDigit, adding results into prodVector. Returns m.s. digit from
105 * final multiply; only candLength digits of *prodVector will be written.
106 */
107giantDigit VectorMultiply(
108	giantDigit plierDigit,
109	giantDigit *candVector,
110	unsigned candLength,
111	giantDigit *prodVector);
112
113#ifdef __cplusplus
114}
115#endif
116
117#endif	/* !PPC_GIANT_PORT_INLINE */
118
119#endif	/*_CK_NSGIANT_PORT_PPC_H_*/
120