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.

68 lines
1.5 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: pkcrypto.h
  4. //
  5. // Microsoft Digital Rights Management
  6. // Copyright (C) Microsoft Corporation, 1998 - 1999, All Rights Reserved
  7. //
  8. // Description:
  9. // public key crypto library
  10. //
  11. // Author: marcuspe
  12. //
  13. //-----------------------------------------------------------------------------
  14. #ifndef __DRMPKCRYPTO_H__
  15. #define __DRMPKCRYPTO_H__
  16. #if _MSC_VER > 1000
  17. #pragma once
  18. #endif // _MSC_VER > 1000
  19. #include <wtypes.h>
  20. #define LNGQDW 5
  21. /*
  22. typedef struct {
  23. DWORD y[2*LNGQDW];
  24. } PUBKEY;
  25. typedef struct {
  26. DWORD x[LNGQDW];
  27. } PRIVKEY;
  28. */
  29. #define PK_ENC_PUBLIC_KEY_LEN (2 * LNGQDW * sizeof(DWORD))
  30. #define PK_ENC_PRIVATE_KEY_LEN ( LNGQDW * sizeof(DWORD))
  31. #define PK_ENC_PLAINTEXT_LEN ((LNGQDW-1) * sizeof(DWORD))
  32. #define PK_ENC_CIPHERTEXT_LEN (4 * LNGQDW * sizeof(DWORD))
  33. #define PK_ENC_SIGNATURE_LEN (2 * LNGQDW * sizeof(DWORD))
  34. typedef struct {
  35. BYTE y[ PK_ENC_PUBLIC_KEY_LEN ];
  36. } PUBKEY;
  37. typedef struct {
  38. BYTE x[ PK_ENC_PRIVATE_KEY_LEN ];
  39. } PRIVKEY;
  40. class CDRMPKCrypto {
  41. private:
  42. char *pkd;
  43. public:
  44. CDRMPKCrypto();
  45. ~CDRMPKCrypto();
  46. HRESULT PKinit();
  47. HRESULT PKencrypt( PUBKEY *pk, BYTE *in, BYTE *out );
  48. HRESULT PKdecrypt( PRIVKEY *pk, BYTE *in, BYTE *out );
  49. HRESULT PKsign( PRIVKEY *privkey, BYTE *buffer, DWORD lbuf, BYTE *sign );
  50. BOOL PKverify( PUBKEY *pubkey, BYTE *buffer, DWORD lbuf, BYTE *sign );
  51. HRESULT PKGenKeyPair( PUBKEY *pPub, PRIVKEY *pPriv );
  52. };
  53. #endif