2
0

lbn16.h 4.6 KB

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