Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
2.4 KiB

  1. /* rsa_math.h
  2. *
  3. * Headers for math routines related to RSA.
  4. *
  5. * Except for Mod(), output parameters are listed first
  6. */
  7. // void Decrement(LPDWORD A, DWORD N)
  8. // Decrement the value A of length N.
  9. void Decrement(LPDWORD A, DWORD N);
  10. // BOOL Increment(LPDWORD A, DWORD N)
  11. // Increment the value A of length N.
  12. BOOL Increment(LPDWORD A, DWORD N);
  13. // void SetValDWORD(LPDWORD num DWORD val, WORD len)
  14. // Set the value of num to val.
  15. void SetValDWORD(LPDWORD num, DWORD val, DWORD len);
  16. // void TwoPower(LPDWORD A, DWORD V, DWORD N)
  17. // Set A to 2^^V
  18. void TwoPower(LPDWORD A, DWORD V, DWORD N);
  19. // DWORD DigitLen(LPDWORD A, DWORD N)
  20. // Return the number of non-zero words in A.
  21. // N is number of total words in A.
  22. DWORD DigitLen(LPDWORD A, DWORD N);
  23. // DWORD BitLen(LPDWORD A, DWORD N)
  24. // Return the bit length of A.
  25. // N is the number of total words in A.
  26. DWORD BitLen(LPDWORD A, DWORD N);
  27. // void MultiplyLow(A, B, C, N)
  28. // A = lower half of B * C.
  29. void MultiplyLow(LPDWORD A, LPDWORD B, LPDWORD C, DWORD N);
  30. // int Compare(A, B, N)
  31. // Return 1 if A > B
  32. // Return 0 if A = B
  33. // Return -1 if A < B
  34. int Compare(LPDWORD A, LPDWORD B, DWORD N);
  35. // Multiply(A, B, C, N)
  36. // A = B * C
  37. // B and C are N DWORDS long
  38. // A is 2N DWORDS long
  39. void Multiply(LPDWORD A, LPDWORD B, LPDWORD C, DWORD N);
  40. // Square(A, B, N)
  41. // A = B * B
  42. // B is N DWORDS long
  43. // A is 2N DWORDS long
  44. void Square(LPDWORD A, LPDWORD B, DWORD N);
  45. // Mod(A, B, R, T, N)
  46. // R = A mod B
  47. // T = allocated length of A
  48. // N = allocated length of B
  49. BOOL Mod(LPDWORD A, LPDWORD B, LPDWORD R, DWORD T, DWORD N);
  50. // ModSquare(A, B, D, N)
  51. // A = B ^ 2 mod D
  52. // N = len B
  53. BOOL ModSquare(LPDWORD A, LPDWORD B, LPDWORD D, DWORD N);
  54. // ModMultiply(A, B, C, D, N)
  55. // A = B * C mod D
  56. // N = len B, C, D
  57. BOOL ModMultiply(LPDWORD A, LPDWORD B, LPDWORD C, LPDWORD D, DWORD N);
  58. // Divide(qi, ri, uu, vv, N)
  59. // qi = uu / vv
  60. // ri = uu mod vv
  61. // N = len uu, vv
  62. BOOL Divide(LPDWORD qi,LPDWORD ri, LPDWORD uu, LPDWORD vv, DWORD ll, DWORD kk);
  63. // GCD
  64. // extended euclid GCD.
  65. // N = length of params
  66. BOOL GCD(LPDWORD u3, LPDWORD u1, LPDWORD u2, LPDWORD u, LPDWORD v, DWORD k);
  67. // ModExp
  68. // A = B ^ C mod D
  69. // N = len of params
  70. BOOL ModExp(LPDWORD A, LPDWORD B, LPDWORD C, LPDWORD D, DWORD len);
  71. // ModRoot(M, C, PP, QQ, DP, DQ, CR)
  72. // CRT ModExp.
  73. BOOL ModRoot(LPDWORD M, LPDWORD C, LPDWORD PP, LPDWORD QQ, LPDWORD DP, LPDWORD DQ, LPDWORD CR, DWORD PSize) ;