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.

90 lines
1.9 KiB

  1. #ifndef __DES_H__
  2. #define __DES_H__
  3. #ifndef RSA32API
  4. #define RSA32API __stdcall
  5. #endif
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef struct _destable {
  10. unsigned long keytab[16][2];
  11. } DESTable;
  12. #define DES_TABLESIZE (sizeof(DESTable))
  13. #define DES_BLOCKLEN (8)
  14. #define DES_KEYSIZE (8)
  15. typedef struct _desxtable {
  16. unsigned char inWhitening[8];
  17. unsigned char outWhitening[8];
  18. DESTable desTable;
  19. } DESXTable;
  20. #define DESX_TABLESIZE (sizeof(DESXTable))
  21. #define DESX_BLOCKLEN (8)
  22. #define DESX_KEYSIZE (24)
  23. /* In deskey.c:
  24. Fill in the DESTable struct with the decrypt and encrypt
  25. key expansions.
  26. Assumes that the second parameter points to DES_BLOCKLEN
  27. bytes of key.
  28. */
  29. void RSA32API deskey(DESTable *,unsigned char *);
  30. /* In desport.c:
  31. Encrypt or decrypt with the key in DESTable
  32. */
  33. void RSA32API des(UCHAR *pbOut, UCHAR *pbIn, void *key, int op);
  34. //
  35. // set the parity on the DES key to be odd
  36. // NOTE : must be called before deskey
  37. // key must be cbKey number of bytes
  38. //
  39. void RSA32API desparityonkey(UCHAR *pbKey, ULONG cbKey);
  40. //
  41. // reduce the DES key to a 40 bit key
  42. // NOTE : must be called before deskey
  43. // key must be 8 bytes
  44. //
  45. void RSA32API desreducekey(UCHAR *key);
  46. // Expand 40 bit DES key to 64 and check weakness
  47. // same as desreducekey except expands instead of weakening keys
  48. void RSA32API deskeyexpand(UCHAR *pbKey, UCHAR *pbExpanded_key);
  49. void
  50. RSA32API
  51. desexpand128to192(
  52. UCHAR *pbKey, // input 128bit or 192bit buffer
  53. UCHAR *pbExpandedKey // output buffer (must be 192bit wide if pbKey == pbExpandedKey
  54. );
  55. // DES-X routines
  56. // initialize desX key struct. key size is 24 bytes
  57. void RSA32API desxkey(DESXTable *k, UCHAR *key);
  58. void RSA32API desx(UCHAR *pbOut, UCHAR *pbIn, void *keyin, int op);
  59. extern int Asmversion; /* 1 if we're linked with an asm version, 0 if C */
  60. #ifdef __cplusplus
  61. }
  62. #endif
  63. #endif // __DES_H__