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.

101 lines
2.3 KiB

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