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.

113 lines
2.5 KiB

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