]> andersk Git - moira.git/blame - util/gdss/lib/crypto/bignum/h/BigNum.h
Remove incorrect krb_get_lrealm() prototype.
[moira.git] / util / gdss / lib / crypto / bignum / h / BigNum.h
CommitLineData
0095f096 1/* Copyright Digital Equipment Corporation & INRIA 1988, 1989 */
2/* Last modified_on Fri Aug 17 17:19:01 GMT+2:00 1990 by shand */
3/* modified_on Wed Jul 5 10:19:33 GMT+2:00 1989 by bertin */
4/* modified_on Fri Apr 28 20:03:23 GMT+2:00 1989 by herve */
5
6
7/* BigN.h - Types and structures for clients of BigNum */
8
9
10
11 /******** representation of a bignum ******/
12/*
13** <--------------------------- nl ---------------------------->
14** | Least Most |
15** |Significant| | | |Significant|
16** |BigNumDigit| | | |BigNumDigit|
17** |___________|___________|___________|___________|___________|
18** ^ (sometimes
19** | is zero)
20** nn
21*/
22
23/* signals BigNum.h already included */
24#define BIGNUM
25
26 /*************** sizes ********************/
27
28#define BN_BYTE_SIZE 8
29#define BN_WORD_SIZE (sizeof (int) * BN_BYTE_SIZE)
30#define BN_DIGIT_SIZE (sizeof (BigNumDigit) * BN_BYTE_SIZE)
31
32/* notes: */
33/* BN_BYTE_SIZE: number of bits in a byte */
34/* BN_WORD_SIZE: number of bits in an "int" in the target language */
35/* BN_DIGIT_SIZE: number of bits in a digit of a BigNum */
36
37
38 /****** results of compare functions ******/
39
40 /* Note: we don't use "enum" to interface with Modula2+, Lisp, ... */
41#define BN_LT -1
42#define BN_EQ 0
43#define BN_GT 1
44
45 /*************** boolean ******************/
46
47#define TRUE 1
48#define FALSE 0
49
50
51 /* if DIGITon16BITS is defined, a single digit is on 16 bits */
52 /* otherwise (by default) a single digit is on 32 bits *****/
53 /* Note: on 32 bit machine it makes little sense to mix */
54 /* longs and short, so we define Boolean & BigNumCmp to be */
55 /* int usually */
56
57#ifdef DIGITon16BITS
58typedef unsigned short BigNumDigit;
59typedef short Boolean;
60#else
61typedef unsigned int BigNumDigit;
62typedef int Boolean;
63#endif
64
65
66 /* bignum types: digits, big numbers, carries ... */
67
68typedef BigNumDigit * BigNum; /* A big number is a digit pointer */
69typedef BigNumDigit BigNumCarry; /* Either 0 or 1 */
70typedef unsigned long BigNumProduct; /* The product of two digits */
71typedef unsigned long BigNumLength; /* The length of a bignum */
72#ifdef DIGITon16BITS
73typedef short BigNumCmp; /* result of comparison */
74#else
75typedef int BigNumCmp; /* result of comparison */
76#endif
77
78
79/*\f*/
80
81
82 /************ functions of bn.c ***********/
83
84extern void BnnInit ();
85extern void BnnClose ();
86
87extern Boolean BnnIsZero ();
88extern BigNumCarry BnnMultiply ();
89extern void BnnDivide ();
90extern BigNumCmp BnnCompare ();
91
92
93 /*********** functions of KerN.c **********/
94
95extern void BnnSetToZero ();
96extern void BnnAssign ();
97extern void BnnSetDigit ();
98extern BigNumDigit BnnGetDigit ();
99extern BigNumLength BnnNumDigits ();
100extern BigNumDigit BnnNumLeadingZeroBitsInDigit ();
101extern Boolean BnnDoesDigitFitInWord ();
102extern Boolean BnnIsDigitZero ();
103extern Boolean BnnIsDigitNormalized ();
104extern Boolean BnnIsDigitOdd ();
105extern BigNumCmp BnnCompareDigits ();
106extern void BnnComplement ();
107extern void BnnAndDigits ();
108extern void BnnOrDigits ();
109extern void BnnXorDigits ();
110extern BigNumDigit BnnShiftLeft ();
111extern BigNumDigit BnnShiftRight ();
112extern BigNumCarry BnnAddCarry ();
113extern BigNumCarry BnnAdd ();
114extern BigNumCarry BnnSubtractBorrow ();
115extern BigNumCarry BnnSubtract ();
116extern BigNumCarry BnnMultiplyDigit ();
117extern BigNumDigit BnnDivideDigit ();
118
119/*\f*/
120
121 /* some functions can be written with macro-procedures */
122
123
124#ifndef BNNMACROS_OFF
125/* the functions BnnIsZero and BnnCompareDigits are not macro procedures
126since they use parameters twice, and that can produce some bugs if
127you pass a parameter like x++, the increment will be executed twice ! */
128#define BnnSetDigit(nn,d) (*(nn) = (d))
129#define BnnGetDigit(nn) ((unsigned)(*(nn)))
130#define BnnDoesDigitFitInWord(d) (BN_DIGIT_SIZE > BN_WORD_SIZE ? ((d) >= 1 << BN_WORD_SIZE ? FALSE : TRUE) : TRUE)
131#define BnnIsDigitZero(d) ((d) == 0)
132#define BnnIsDigitNormalized(d) ((d) & (1 << (BN_DIGIT_SIZE - 1)) ? TRUE : FALSE)
133#define BnnIsDigitOdd(d) ((d) & 1 ? TRUE : FALSE)
134#define BnnAndDigits(nn, d) (*(nn) &= (d))
135#define BnnOrDigits(nn, d) (*(nn) |= (d))
136#define BnnXorDigits(nn, d) (*(nn) ^= (d))
137
138#endif
139
140
This page took 0.55312 seconds and 5 git commands to generate.