Source code of Windows XP (NT5)
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.

139 lines
3.0 KiB

  1. /* crypto.h
  2. *
  3. * Prototypes and definitions for services in crypto.c
  4. *
  5. * ported to win nt from win 95 on 6/95
  6. * Cory West
  7. */
  8. #include <windef.h>
  9. #define CIPHERBLOCKSIZE 8 // size of RC2 block
  10. #define MAX_RSA_BITS 512 // actually 420
  11. #define MAX_RSA_BYTES (MAX_RSA_BITS/8)
  12. #define B_PSIZEBITS 210
  13. #define B_PSIZEWORDS (1 + B_PSIZEBITS/32)
  14. void __cdecl
  15. GenRandomBytes(
  16. BYTE *output,
  17. int len
  18. );
  19. //
  20. // Generate an 8 byte key from a seed of the given length.
  21. //
  22. void __cdecl
  23. GenKey8(
  24. BYTE *keyData,
  25. int keyDataLen,
  26. BYTE key8[8]
  27. );
  28. void __cdecl
  29. MD2(
  30. BYTE *input,
  31. const int inlen,
  32. BYTE *output
  33. );
  34. //
  35. // RC2 encrypt and decrypt wrappers.
  36. //
  37. int __cdecl
  38. CBCEncrypt(
  39. BYTE *key, // secret key
  40. BYTE const *ivec, // initialization vector, NULL implies zero vector
  41. BYTE *const input, // plain text
  42. int inlen, // size of plaintext
  43. BYTE *const output, // encrypted text
  44. int *outlen, // OUTPUT: size of encrypted text
  45. const int checksumlen // size of checksum, if 0 no checksum is used
  46. );
  47. int __cdecl
  48. CBCDecrypt(
  49. BYTE *key, // secret key
  50. BYTE *ivec, // initialization vector, null ptr implies zero vector
  51. BYTE *input, // encrypted text
  52. int inlen, // size of encrypted text
  53. BYTE *output, // plain text
  54. int *outlen, // OUTPUT: size of plaintext
  55. int checksumlen // size of checksum; 0=> no checksum
  56. );
  57. //
  58. // Wrappers to the RSA code.
  59. //
  60. int __cdecl
  61. RSAGetInputBlockSize(
  62. BYTE *keydata,
  63. int keylen
  64. );
  65. BYTE * __cdecl
  66. RSAGetModulus(
  67. BYTE *keydata,
  68. int keylen,
  69. int *modSize
  70. );
  71. BYTE * _cdecl
  72. RSAGetPublicExponent(
  73. BYTE *keydata,
  74. int keylen,
  75. int *expSize
  76. );
  77. int __cdecl
  78. RSAPack(
  79. BYTE *input,
  80. int inlen,
  81. BYTE *output,
  82. int blocksize
  83. );
  84. int __cdecl
  85. RSAPublic(
  86. BYTE *pukeydata, // BSAFE 1 itemized public key data
  87. int pukeylen, // length of BSAFE1 keydata (including sign)
  88. BYTE *input, // input block
  89. int inlen, // size of input (< modulus)
  90. BYTE *output // encrypted block (modulus sized)
  91. );
  92. int __cdecl
  93. RSAPrivate(
  94. BYTE *prkeydata,
  95. int prkeylen,
  96. BYTE *input,
  97. int inlen,
  98. BYTE *output
  99. );
  100. int __cdecl
  101. RSAModMpy(
  102. BYTE *pukeydata, // BSAFE 1 itemized public key data
  103. int pukeylen, // length of BSAFE1 keydata (including sign)
  104. BYTE *input1, // input block
  105. int inlen1, // size of input (< modulus)
  106. BYTE *input2, // multiplier
  107. int inlen2, // size of multiplier
  108. BYTE *output // encrypted block (modulus sized)
  109. );
  110. int __cdecl
  111. RSAModExp(
  112. BYTE *pukeydata, // BSAFE 1 itemized public key data
  113. int pukeylen, // length of BSAFE1 keydata (including sign)
  114. BYTE *input1, // input block
  115. int inlen1, // size of input (< modulus)
  116. BYTE *exponent,
  117. int explen,
  118. BYTE *output // encrypted block (modulus sized)
  119. );