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 LBN16_H 6 #define LBN16_H 7 8 #include "lbn.h" 9 10 #ifndef BNWORD16 11 #error 16-bit bignum library requires a 16-bit data type 12 #endif 13 14 #ifndef lbnCopy_16 15 void lbnCopy_16(BNWORD16 *dest, BNWORD16 const *src, unsigned len); 16 #endif 17 #ifndef lbnZero_16 18 void lbnZero_16(BNWORD16 *num, unsigned len); 19 #endif 20 #ifndef lbnNeg_16 21 void lbnNeg_16(BNWORD16 *num, unsigned len); 22 #endif 23 24 #ifndef lbnAdd1_16 25 BNWORD16 lbnAdd1_16(BNWORD16 *num, unsigned len, BNWORD16 carry); 26 #endif 27 #ifndef lbnSub1_16 28 BNWORD16 lbnSub1_16(BNWORD16 *num, unsigned len, BNWORD16 borrow); 29 #endif 30 31 #ifndef lbnAddN_16 32 BNWORD16 lbnAddN_16(BNWORD16 *num1, BNWORD16 const *num2, unsigned len); 33 #endif 34 #ifndef lbnSubN_16 35 BNWORD16 lbnSubN_16(BNWORD16 *num1, BNWORD16 const *num2, unsigned len); 36 #endif 37 38 #ifndef lbnCmp_16 39 int lbnCmp_16(BNWORD16 const *num1, BNWORD16 const *num2, unsigned len); 40 #endif 41 42 #ifndef lbnMulN1_16 43 void lbnMulN1_16(BNWORD16 *out, BNWORD16 const *in, unsigned len, BNWORD16 k); 44 #endif 45 #ifndef lbnMulAdd1_16 46 BNWORD16 47 lbnMulAdd1_16(BNWORD16 *out, BNWORD16 const *in, unsigned len, BNWORD16 k); 48 #endif 49 #ifndef lbnMulSub1_16 50 BNWORD16 lbnMulSub1_16(BNWORD16 *out, BNWORD16 const *in, unsigned len, BNWORD16 k); 51 #endif 52 53 #ifndef lbnLshift_16 54 BNWORD16 lbnLshift_16(BNWORD16 *num, unsigned len, unsigned shift); 55 #endif 56 #ifndef lbnDouble_16 57 BNWORD16 lbnDouble_16(BNWORD16 *num, unsigned len); 58 #endif 59 #ifndef lbnRshift_16 60 BNWORD16 lbnRshift_16(BNWORD16 *num, unsigned len, unsigned shift); 61 #endif 62 63 #ifndef lbnMul_16 64 void lbnMul_16(BNWORD16 *prod, BNWORD16 const *num1, unsigned len1, 65 BNWORD16 const *num2, unsigned len2); 66 #endif 67 #ifndef lbnSquare_16 68 void lbnSquare_16(BNWORD16 *prod, BNWORD16 const *num, unsigned len); 69 #endif 70 71 #ifndef lbnNorm_16 72 unsigned lbnNorm_16(BNWORD16 const *num, unsigned len); 73 #endif 74 #ifndef lbnBits_16 75 unsigned lbnBits_16(BNWORD16 const *num, unsigned len); 76 #endif 77 78 #ifndef lbnExtractBigBytes_16 79 void lbnExtractBigBytes_16(BNWORD16 const *bn, unsigned char *buf, 80 unsigned lsbyte, unsigned buflen); 81 #endif 82 #ifndef lbnInsertBigytes_16 83 void lbnInsertBigBytes_16(BNWORD16 *n, unsigned char const *buf, 84 unsigned lsbyte, unsigned buflen); 85 #endif 86 #ifndef lbnExtractLittleBytes_16 87 void lbnExtractLittleBytes_16(BNWORD16 const *bn, unsigned char *buf, 88 unsigned lsbyte, unsigned buflen); 89 #endif 90 #ifndef lbnInsertLittleBytes_16 91 void lbnInsertLittleBytes_16(BNWORD16 *n, unsigned char const *buf, 92 unsigned lsbyte, unsigned buflen); 93 #endif 94 95 #ifndef lbnDiv21_16 96 BNWORD16 lbnDiv21_16(BNWORD16 *q, BNWORD16 nh, BNWORD16 nl, BNWORD16 d); 97 #endif 98 #ifndef lbnDiv1_16 99 BNWORD16 lbnDiv1_16(BNWORD16 *q, BNWORD16 *rem, 100 BNWORD16 const *n, unsigned len, BNWORD16 d); 101 #endif 102 #ifndef lbnModQ_16 103 unsigned lbnModQ_16(BNWORD16 const *n, unsigned len, unsigned d); 104 #endif 105 #ifndef lbnDiv_16 106 BNWORD16 107 lbnDiv_16(BNWORD16 *q, BNWORD16 *n, unsigned nlen, BNWORD16 *d, unsigned dlen); 108 #endif 109 110 #ifndef lbnMontInv1_16 111 BNWORD16 lbnMontInv1_16(BNWORD16 const x); 112 #endif 113 #ifndef lbnMontReduce_16 114 void lbnMontReduce_16(BNWORD16 *n, BNWORD16 const *mod, unsigned const mlen, 115 BNWORD16 inv); 116 #endif 117 #ifndef lbnToMont_16 118 void lbnToMont_16(BNWORD16 *n, unsigned nlen, BNWORD16 *mod, unsigned mlen); 119 #endif 120 #ifndef lbnFromMont_16 121 void lbnFromMont_16(BNWORD16 *n, BNWORD16 *mod, unsigned len); 122 #endif 123 124 #ifndef lbnExpMod_16 125 int lbnExpMod_16(BNWORD16 *result, BNWORD16 const *n, unsigned nlen, 126 BNWORD16 const *exp, unsigned elen, BNWORD16 *mod, unsigned mlen); 127 #endif 128 #ifndef lbnDoubleExpMod_16 129 int lbnDoubleExpMod_16(BNWORD16 *result, 130 BNWORD16 const *n1, unsigned n1len, BNWORD16 const *e1, unsigned e1len, 131 BNWORD16 const *n2, unsigned n2len, BNWORD16 const *e2, unsigned e2len, 132 BNWORD16 *mod, unsigned mlen); 133 #endif 134 #ifndef lbnTwoExpMod_16 135 int lbnTwoExpMod_16(BNWORD16 *n, BNWORD16 const *exp, unsigned elen, 136 BNWORD16 *mod, unsigned mlen); 137 #endif 138 #ifndef lbnGcd_16 139 int lbnGcd_16(BNWORD16 *a, unsigned alen, BNWORD16 *b, unsigned blen, 140 unsigned *rlen); 141 #endif 142 #ifndef lbnInv_16 143 int lbnInv_16(BNWORD16 *a, unsigned alen, BNWORD16 const *mod, unsigned mlen); 144 #endif 145 146 int lbnBasePrecompBegin_16(BNWORD16 **array, unsigned n, unsigned bits, 147 BNWORD16 const *g, unsigned glen, BNWORD16 *mod, unsigned mlen); 148 int lbnBasePrecompExp_16(BNWORD16 *result, BNWORD16 const * const *array, 149 unsigned bits, BNWORD16 const *exp, unsigned elen, 150 BNWORD16 const *mod, unsigned mlen); 151 int lbnDoubleBasePrecompExp_16(BNWORD16 *result, unsigned bits, 152 BNWORD16 const * const *array1, BNWORD16 const *exp1, unsigned elen1, 153 BNWORD16 const * const *array2, BNWORD16 const *exp2, 154 unsigned elen2, BNWORD16 const *mod, unsigned mlen); 155 156 #endif /* LBN16_H */ 157