1 /* 2 * Copyright (c) 1995 Colin Plumb. All rights reserved. 3 * For licensing and other legal details, see the file legal.c. 4 */ 5 #ifndef LBN64_H 6 #define LBN64_H 7 8 #include "lbn.h" 9 10 #ifndef BNWORD64 11 #error 64-bit bignum library requires a 64-bit data type 12 #endif 13 14 #ifndef lbnCopy_64 15 void lbnCopy_64(BNWORD64 *dest, BNWORD64 const *src, unsigned len); 16 #endif 17 #ifndef lbnZero_64 18 void lbnZero_64(BNWORD64 *num, unsigned len); 19 #endif 20 #ifndef lbnNeg_64 21 void lbnNeg_64(BNWORD64 *num, unsigned len); 22 #endif 23 24 #ifndef lbnAdd1_64 25 BNWORD64 lbnAdd1_64(BNWORD64 *num, unsigned len, BNWORD64 carry); 26 #endif 27 #ifndef lbnSub1_64 28 BNWORD64 lbnSub1_64(BNWORD64 *num, unsigned len, BNWORD64 borrow); 29 #endif 30 31 #ifndef lbnAddN_64 32 BNWORD64 lbnAddN_64(BNWORD64 *num1, BNWORD64 const *num2, unsigned len); 33 #endif 34 #ifndef lbnSubN_64 35 BNWORD64 lbnSubN_64(BNWORD64 *num1, BNWORD64 const *num2, unsigned len); 36 #endif 37 38 #ifndef lbnCmp_64 39 int lbnCmp_64(BNWORD64 const *num1, BNWORD64 const *num2, unsigned len); 40 #endif 41 42 #ifndef lbnMulN1_64 43 void lbnMulN1_64(BNWORD64 *out, BNWORD64 const *in, unsigned len, BNWORD64 k); 44 #endif 45 #ifndef lbnMulAdd1_64 46 BNWORD64 47 lbnMulAdd1_64(BNWORD64 *out, BNWORD64 const *in, unsigned len, BNWORD64 k); 48 #endif 49 #ifndef lbnMulSub1_64 50 BNWORD64 lbnMulSub1_64(BNWORD64 *out, BNWORD64 const *in, unsigned len, BNWORD64 k); 51 #endif 52 53 #ifndef lbnLshift_64 54 BNWORD64 lbnLshift_64(BNWORD64 *num, unsigned len, unsigned shift); 55 #endif 56 #ifndef lbnDouble_64 57 BNWORD64 lbnDouble_64(BNWORD64 *num, unsigned len); 58 #endif 59 #ifndef lbnRshift_64 60 BNWORD64 lbnRshift_64(BNWORD64 *num, unsigned len, unsigned shift); 61 #endif 62 63 #ifndef lbnMul_64 64 void lbnMul_64(BNWORD64 *prod, BNWORD64 const *num1, unsigned len1, 65 BNWORD64 const *num2, unsigned len2); 66 #endif 67 #ifndef lbnSquare_64 68 void lbnSquare_64(BNWORD64 *prod, BNWORD64 const *num, unsigned len); 69 #endif 70 71 #ifndef lbnNorm_64 72 unsigned lbnNorm_64(BNWORD64 const *num, unsigned len); 73 #endif 74 #ifndef lbnBits_64 75 unsigned lbnBits_64(BNWORD64 const *num, unsigned len); 76 #endif 77 78 #ifndef lbnExtractBigBytes_64 79 void lbnExtractBigBytes_64(BNWORD64 const *bn, unsigned char *buf, 80 unsigned lsbyte, unsigned buflen); 81 #endif 82 #ifndef lbnInsertBigytes_64 83 void lbnInsertBigBytes_64(BNWORD64 *n, unsigned char const *buf, 84 unsigned lsbyte, unsigned buflen); 85 #endif 86 #ifndef lbnExtractLittleBytes_64 87 void lbnExtractLittleBytes_64(BNWORD64 const *bn, unsigned char *buf, 88 unsigned lsbyte, unsigned buflen); 89 #endif 90 #ifndef lbnInsertLittleBytes_64 91 void lbnInsertLittleBytes_64(BNWORD64 *n, unsigned char const *buf, 92 unsigned lsbyte, unsigned buflen); 93 #endif 94 95 #ifndef lbnDiv21_64 96 BNWORD64 lbnDiv21_64(BNWORD64 *q, BNWORD64 nh, BNWORD64 nl, BNWORD64 d); 97 #endif 98 #ifndef lbnDiv1_64 99 BNWORD64 lbnDiv1_64(BNWORD64 *q, BNWORD64 *rem, 100 BNWORD64 const *n, unsigned len, BNWORD64 d); 101 #endif 102 #ifndef lbnModQ_64 103 unsigned lbnModQ_64(BNWORD64 const *n, unsigned len, unsigned d); 104 #endif 105 #ifndef lbnDiv_64 106 BNWORD64 107 lbnDiv_64(BNWORD64 *q, BNWORD64 *n, unsigned nlen, BNWORD64 *d, unsigned dlen); 108 #endif 109 110 #ifndef lbnMontInv1_64 111 BNWORD64 lbnMontInv1_64(BNWORD64 const x); 112 #endif 113 #ifndef lbnMontReduce_64 114 void lbnMontReduce_64(BNWORD64 *n, BNWORD64 const *mod, unsigned const mlen, 115 BNWORD64 inv); 116 #endif 117 #ifndef lbnToMont_64 118 void lbnToMont_64(BNWORD64 *n, unsigned nlen, BNWORD64 *mod, unsigned mlen); 119 #endif 120 #ifndef lbnFromMont_64 121 void lbnFromMont_64(BNWORD64 *n, BNWORD64 *mod, unsigned len); 122 #endif 123 124 #ifndef lbnExpMod_64 125 int lbnExpMod_64(BNWORD64 *result, BNWORD64 const *n, unsigned nlen, 126 BNWORD64 const *exp, unsigned elen, BNWORD64 *mod, unsigned mlen); 127 #endif 128 #ifndef lbnDoubleExpMod_64 129 int lbnDoubleExpMod_64(BNWORD64 *result, 130 BNWORD64 const *n1, unsigned n1len, BNWORD64 const *e1, unsigned e1len, 131 BNWORD64 const *n2, unsigned n2len, BNWORD64 const *e2, unsigned e2len, 132 BNWORD64 *mod, unsigned mlen); 133 #endif 134 #ifndef lbnTwoExpMod_64 135 int lbnTwoExpMod_64(BNWORD64 *n, BNWORD64 const *exp, unsigned elen, 136 BNWORD64 *mod, unsigned mlen); 137 #endif 138 #ifndef lbnGcd_64 139 int lbnGcd_64(BNWORD64 *a, unsigned alen, BNWORD64 *b, unsigned blen, 140 unsigned *rlen); 141 #endif 142 #ifndef lbnInv_64 143 int lbnInv_64(BNWORD64 *a, unsigned alen, BNWORD64 const *mod, unsigned mlen); 144 #endif 145 146 int lbnBasePrecompBegin_64(BNWORD64 **array, unsigned n, unsigned bits, 147 BNWORD64 const *g, unsigned glen, BNWORD64 *mod, unsigned mlen); 148 int lbnBasePrecompExp_64(BNWORD64 *result, BNWORD64 const * const *array, 149 unsigned bits, BNWORD64 const *exp, unsigned elen, 150 BNWORD64 const *mod, unsigned mlen); 151 int lbnDoubleBasePrecompExp_64(BNWORD64 *result, unsigned bits, 152 BNWORD64 const * const *array1, BNWORD64 const *exp1, unsigned elen1, 153 BNWORD64 const * const *array2, BNWORD64 const *exp2, 154 unsigned elen2, BNWORD64 const *mod, unsigned mlen); 155 156 #endif /* LBN64_H */ 157