lbn32.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 LBN32_H
  6. #define LBN32_H
  7. #include "lbn.h"
  8. #ifndef BNWORD32
  9. #error 32-bit bignum library requires a 32-bit data type
  10. #endif
  11. #ifndef lbnCopy_32
  12. void lbnCopy_32(BNWORD32 *dest, BNWORD32 const *src, unsigned len);
  13. #endif
  14. #ifndef lbnZero_32
  15. void lbnZero_32(BNWORD32 *num, unsigned len);
  16. #endif
  17. #ifndef lbnNeg_32
  18. void lbnNeg_32(BNWORD32 *num, unsigned len);
  19. #endif
  20. #ifndef lbnAdd1_32
  21. BNWORD32 lbnAdd1_32(BNWORD32 *num, unsigned len, BNWORD32 carry);
  22. #endif
  23. #ifndef lbnSub1_32
  24. BNWORD32 lbnSub1_32(BNWORD32 *num, unsigned len, BNWORD32 borrow);
  25. #endif
  26. #ifndef lbnAddN_32
  27. BNWORD32 lbnAddN_32(BNWORD32 *num1, BNWORD32 const *num2, unsigned len);
  28. #endif
  29. #ifndef lbnSubN_32
  30. BNWORD32 lbnSubN_32(BNWORD32 *num1, BNWORD32 const *num2, unsigned len);
  31. #endif
  32. #ifndef lbnCmp_32
  33. int lbnCmp_32(BNWORD32 const *num1, BNWORD32 const *num2, unsigned len);
  34. #endif
  35. #ifndef lbnMulN1_32
  36. void lbnMulN1_32(BNWORD32 *out, BNWORD32 const *in, unsigned len, BNWORD32 k);
  37. #endif
  38. #ifndef lbnMulAdd1_32
  39. BNWORD32
  40. lbnMulAdd1_32(BNWORD32 *out, BNWORD32 const *in, unsigned len, BNWORD32 k);
  41. #endif
  42. #ifndef lbnMulSub1_32
  43. BNWORD32 lbnMulSub1_32(BNWORD32 *out, BNWORD32 const *in, unsigned len, BNWORD32 k);
  44. #endif
  45. #ifndef lbnLshift_32
  46. BNWORD32 lbnLshift_32(BNWORD32 *num, unsigned len, unsigned shift);
  47. #endif
  48. #ifndef lbnDouble_32
  49. BNWORD32 lbnDouble_32(BNWORD32 *num, unsigned len);
  50. #endif
  51. #ifndef lbnRshift_32
  52. BNWORD32 lbnRshift_32(BNWORD32 *num, unsigned len, unsigned shift);
  53. #endif
  54. #ifndef lbnMul_32
  55. void lbnMul_32(BNWORD32 *prod, BNWORD32 const *num1, unsigned len1,
  56. BNWORD32 const *num2, unsigned len2);
  57. #endif
  58. #ifndef lbnSquare_32
  59. void lbnSquare_32(BNWORD32 *prod, BNWORD32 const *num, unsigned len);
  60. #endif
  61. #ifndef lbnNorm_32
  62. unsigned lbnNorm_32(BNWORD32 const *num, unsigned len);
  63. #endif
  64. #ifndef lbnBits_32
  65. unsigned lbnBits_32(BNWORD32 const *num, unsigned len);
  66. #endif
  67. #ifndef lbnExtractBigBytes_32
  68. void lbnExtractBigBytes_32(BNWORD32 const *bn, unsigned char *buf,
  69. unsigned lsbyte, unsigned buflen);
  70. #endif
  71. #ifndef lbnInsertBigytes_32
  72. void lbnInsertBigBytes_32(BNWORD32 *n, unsigned char const *buf,
  73. unsigned lsbyte, unsigned buflen);
  74. #endif
  75. #ifndef lbnExtractLittleBytes_32
  76. void lbnExtractLittleBytes_32(BNWORD32 const *bn, unsigned char *buf,
  77. unsigned lsbyte, unsigned buflen);
  78. #endif
  79. #ifndef lbnInsertLittleBytes_32
  80. void lbnInsertLittleBytes_32(BNWORD32 *n, unsigned char const *buf,
  81. unsigned lsbyte, unsigned buflen);
  82. #endif
  83. #ifndef lbnDiv21_32
  84. BNWORD32 lbnDiv21_32(BNWORD32 *q, BNWORD32 nh, BNWORD32 nl, BNWORD32 d);
  85. #endif
  86. #ifndef lbnDiv1_32
  87. BNWORD32 lbnDiv1_32(BNWORD32 *q, BNWORD32 *rem,
  88. BNWORD32 const *n, unsigned len, BNWORD32 d);
  89. #endif
  90. #ifndef lbnModQ_32
  91. unsigned lbnModQ_32(BNWORD32 const *n, unsigned len, unsigned d);
  92. #endif
  93. #ifndef lbnDiv_32
  94. BNWORD32
  95. lbnDiv_32(BNWORD32 *q, BNWORD32 *n, unsigned nlen, BNWORD32 *d, unsigned dlen);
  96. #endif
  97. #ifndef lbnMontInv1_32
  98. BNWORD32 lbnMontInv1_32(BNWORD32 const x);
  99. #endif
  100. #ifndef lbnMontReduce_32
  101. void lbnMontReduce_32(BNWORD32 *n, BNWORD32 const *mod, unsigned const mlen,
  102. BNWORD32 inv);
  103. #endif
  104. #ifndef lbnToMont_32
  105. void lbnToMont_32(BNWORD32 *n, unsigned nlen, BNWORD32 *mod, unsigned mlen);
  106. #endif
  107. #ifndef lbnFromMont_32
  108. void lbnFromMont_32(BNWORD32 *n, BNWORD32 *mod, unsigned len);
  109. #endif
  110. #ifndef lbnExpMod_32
  111. int lbnExpMod_32(BNWORD32 *result, BNWORD32 const *n, unsigned nlen,
  112. BNWORD32 const *exp, unsigned elen, BNWORD32 *mod, unsigned mlen);
  113. #endif
  114. #ifndef lbnDoubleExpMod_32
  115. int lbnDoubleExpMod_32(BNWORD32 *result,
  116. BNWORD32 const *n1, unsigned n1len, BNWORD32 const *e1, unsigned e1len,
  117. BNWORD32 const *n2, unsigned n2len, BNWORD32 const *e2, unsigned e2len,
  118. BNWORD32 *mod, unsigned mlen);
  119. #endif
  120. #ifndef lbnTwoExpMod_32
  121. int lbnTwoExpMod_32(BNWORD32 *n, BNWORD32 const *exp, unsigned elen,
  122. BNWORD32 *mod, unsigned mlen);
  123. #endif
  124. #ifndef lbnGcd_32
  125. int lbnGcd_32(BNWORD32 *a, unsigned alen, BNWORD32 *b, unsigned blen,
  126. unsigned *rlen);
  127. #endif
  128. #ifndef lbnInv_32
  129. int lbnInv_32(BNWORD32 *a, unsigned alen, BNWORD32 const *mod, unsigned mlen);
  130. #endif
  131. int lbnBasePrecompBegin_32(BNWORD32 **array, unsigned n, unsigned bits,
  132. BNWORD32 const *g, unsigned glen, BNWORD32 *mod, unsigned mlen);
  133. int lbnBasePrecompExp_32(BNWORD32 *result, BNWORD32 const * const *array,
  134. unsigned bits, BNWORD32 const *exp, unsigned elen,
  135. BNWORD32 const *mod, unsigned mlen);
  136. int lbnDoubleBasePrecompExp_32(BNWORD32 *result, unsigned bits,
  137. BNWORD32 const * const *array1, BNWORD32 const *exp1, unsigned elen1,
  138. BNWORD32 const * const *array2, BNWORD32 const *exp2,
  139. unsigned elen2, BNWORD32 const *mod, unsigned mlen);
  140. #endif /* LBN32_H */