2
0

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