bn32.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 1995 Colin Plumb. All rights reserved.
  3. * For licensing and other legal details, see the file legal.c.
  4. *
  5. * bn32.h - interface to 32-bit bignum routines.
  6. */
  7. struct BigNum;
  8. struct BnBasePrecomp;
  9. void bnInit_32(void);
  10. void bnEnd_32(struct BigNum *bn);
  11. int bnPrealloc_32(struct BigNum *bn, unsigned bits);
  12. int bnCopy_32(struct BigNum *dest, struct BigNum const *src);
  13. int bnSwap_32(struct BigNum *a, struct BigNum *b);
  14. void bnNorm_32(struct BigNum *bn);
  15. void bnExtractBigBytes_32(struct BigNum const *bn, unsigned char *dest,
  16. unsigned lsbyte, unsigned dlen);
  17. int bnInsertBigBytes_32(struct BigNum *bn, unsigned char const *src,
  18. unsigned lsbyte, unsigned len);
  19. void bnExtractLittleBytes_32(struct BigNum const *bn, unsigned char *dest,
  20. unsigned lsbyte, unsigned dlen);
  21. int bnInsertLittleBytes_32(struct BigNum *bn, unsigned char const *src,
  22. unsigned lsbyte, unsigned len);
  23. unsigned bnLSWord_32(struct BigNum const *src);
  24. int bnReadBit_32(struct BigNum const *bn, unsigned bit);
  25. unsigned bnBits_32(struct BigNum const *src);
  26. int bnAdd_32(struct BigNum *dest, struct BigNum const *src);
  27. int bnSub_32(struct BigNum *dest, struct BigNum const *src);
  28. int bnCmpQ_32(struct BigNum const *a, unsigned b);
  29. int bnSetQ_32(struct BigNum *dest, unsigned src);
  30. int bnAddQ_32(struct BigNum *dest, unsigned src);
  31. int bnSubQ_32(struct BigNum *dest, unsigned src);
  32. int bnCmp_32(struct BigNum const *a, struct BigNum const *b);
  33. int bnSquare_32(struct BigNum *dest, struct BigNum const *src);
  34. int bnMul_32(struct BigNum *dest, struct BigNum const *a,
  35. struct BigNum const *b);
  36. int bnMulQ_32(struct BigNum *dest, struct BigNum const *a, unsigned b);
  37. int bnDivMod_32(struct BigNum *q, struct BigNum *r, struct BigNum const *n,
  38. struct BigNum const *d);
  39. int bnMod_32(struct BigNum *dest, struct BigNum const *src,
  40. struct BigNum const *d);
  41. unsigned bnModQ_32(struct BigNum const *src, unsigned d);
  42. int bnExpMod_32(struct BigNum *dest, struct BigNum const *n,
  43. struct BigNum const *exp, struct BigNum const *mod);
  44. int bnDoubleExpMod_32(struct BigNum *dest,
  45. struct BigNum const *n1, struct BigNum const *e1,
  46. struct BigNum const *n2, struct BigNum const *e2,
  47. struct BigNum const *mod);
  48. int bnTwoExpMod_32(struct BigNum *n, struct BigNum const *exp,
  49. struct BigNum const *mod);
  50. int bnGcd_32(struct BigNum *dest, struct BigNum const *a,
  51. struct BigNum const *b);
  52. int bnInv_32(struct BigNum *dest, struct BigNum const *src,
  53. struct BigNum const *mod);
  54. int bnLShift_32(struct BigNum *dest, unsigned amt);
  55. void bnRShift_32(struct BigNum *dest, unsigned amt);
  56. unsigned bnMakeOdd_32(struct BigNum *n);
  57. int bnBasePrecompBegin_32(struct BnBasePrecomp *pre, struct BigNum const *base,
  58. struct BigNum const *mod, unsigned maxebits);
  59. void bnBasePrecompEnd_32(struct BnBasePrecomp *pre);
  60. int bnBasePrecompExpMod_32(struct BigNum *dest, struct BnBasePrecomp const *pre,
  61. struct BigNum const *exp, struct BigNum const *mod);
  62. int bnDoubleBasePrecompExpMod_32(struct BigNum *dest,
  63. struct BnBasePrecomp const *pre1, struct BigNum const *exp1,
  64. struct BnBasePrecomp const *pre2, struct BigNum const *exp2,
  65. struct BigNum const *mod);