On2Crypt.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //==========================================================================
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1999 - 2001 On2 Technologies Inc. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------
  11. #if !defined(ON2CRYPT_H)
  12. #define ON2CRYPT_H
  13. //______________________________________________________________________________
  14. //
  15. // On2Crypt.h
  16. // API to on2comp's encryption dll
  17. //--------------------------------------------------------------------------
  18. #ifdef _USRDLL
  19. #define DLLExport __declspec(dllexport)
  20. #else
  21. #define DLLExport
  22. #endif
  23. #define DLLCC __stdcall
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. typedef void* HOn2Encryptor;
  29. DLLExport int DLLCC MakeEncryptor(unsigned char* pString, int iLength, HOn2Encryptor* phOn2Encryptor);
  30. //***************************************************************************************
  31. // Name : MakeEncryptor
  32. // Description: set up an encryption session
  33. // Inputs : pString -> information to be used by encryptor to set up encryption session
  34. // iLength -> number of bytes used in pString
  35. // Outputs : phOn2Encryptor -> pointer to an encryption session
  36. // Returns : 0 = success
  37. //***************************************************************************************
  38. DLLExport int DLLCC GetEncryptionCode(char* pfccCode); // size of szCode must be >= 4
  39. //***************************************************************************************
  40. // Name : GetEncryptionCode
  41. // Description: get the 4 character code to use as a reference for this encryption dll
  42. // Inputs :
  43. // Outputs : pfccCode 4 character code
  44. // Returns : 0 = success
  45. //***************************************************************************************
  46. DLLExport int DLLCC GetDRMXLength(HOn2Encryptor hOn2Encryptor, int* piLength);
  47. //***************************************************************************************
  48. // Name : GetDRMXLength
  49. // Description: calculates the length of decryption chunk to be produced
  50. // Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
  51. // Outputs : piLength -> filled with length of extra information
  52. // Returns : 0 = success
  53. //***************************************************************************************
  54. DLLExport int DLLCC GenerateDRMX(HOn2Encryptor hOn2Encryptor, unsigned char* pBuffer);
  55. //***************************************************************************************
  56. // Name : GenerateDRMX
  57. // Description: generates a decryption chunk
  58. // Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
  59. // Outputs : pBuffer is filled with information necessary to decrypt the file we are
  60. // encrypting
  61. // Returns : 0 = success
  62. //***************************************************************************************
  63. DLLExport int DLLCC EncryptedSize(HOn2Encryptor hOn2Encryptor, int iSizeIn, int* piSizeOut);
  64. //***************************************************************************************
  65. // Name : EncryptedSize
  66. // Description: returns size that an encrypted chunk will be given a size in
  67. // Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
  68. // : iSizeIn -> size of input data
  69. // Outputs : piSizeOut -> size of output data
  70. // Returns : 0 = success
  71. //***************************************************************************************
  72. DLLExport int DLLCC EncryptBytes(HOn2Encryptor hOn2Encryptor, unsigned char* pBufferIn, int iSizeIn, unsigned char* pBufferOut, int iSizeOutMax, int* piSizeOut);
  73. //***************************************************************************************
  74. // Name : EncryptBytes
  75. // Description: encrypts bytes in input buffer and stores them to the output buffer
  76. // Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
  77. // : pBufferIn -> buffer holding bytes to encrypt
  78. // iSizeIn -> number of bytes to encrypt of that buffer
  79. // Outputs : pBufferOut -> buffer for holding encrypted bytes
  80. // iSizeOutMax -> maximum number of bytes to write to pBufferOut
  81. // piSizeOut -> number of bytes actually written to pbufferout
  82. // Returns : 0 = success
  83. //***************************************************************************************
  84. DLLExport int DLLCC EncryptorError(char* szError, int nErrorMax);
  85. //***************************************************************************************
  86. // Name : EncryptorError
  87. // Description: gets a string description of the last error
  88. // Inputs : szError -> pointer to string
  89. // nErrorMax -> the largest number of bytes to fill in in szerror
  90. // Outputs :
  91. // Returns : 0 = success
  92. //***************************************************************************************
  93. DLLExport int DLLCC DeleteEncryptor(HOn2Encryptor hOn2Encryptor);
  94. //***************************************************************************************
  95. // Name : DeleteEncryptor
  96. // Description: ends the encryption session and cleans up
  97. // Inputs : hOn2Encryptor -> handle of encryption sesion to use ( from make encryptor)
  98. // Outputs :
  99. // Returns : 0 = success
  100. //***************************************************************************************
  101. typedef int (DLLCC *PFNMakeEncryptor)(unsigned char* pString, int iLength, HOn2Encryptor* phOn2Encryptor);
  102. typedef int (DLLCC *PFNGetEncryptionCode)(char* pfccCode); // size of szCode must be >= 4
  103. typedef int (DLLCC *PFNGetDRMXLength)(HOn2Encryptor hOn2Encryptor, int* piLength);
  104. typedef int (DLLCC *PFNGenerateDRMX)(HOn2Encryptor hOn2Encryptor, unsigned char* pBuffer);
  105. typedef int (DLLCC *PFNEncryptedSize)(HOn2Encryptor hOn2Encryptor, int iSizeIn, int* piSizeOut);
  106. typedef int (DLLCC *PFNEncryptBytes)(HOn2Encryptor hOn2Encryptor, unsigned char* pBufferIn, int iSizeIn, unsigned char* pBufferOut, int iSizeOutMax, int* piSizeOut);
  107. typedef int (DLLCC *PFNEncryptorError)(char* szError, int nErrorMax);
  108. typedef int (DLLCC *PFNDeleteEncryptor)(HOn2Encryptor hOn2Encryptor);
  109. #ifdef __cplusplus
  110. } // extern "C"
  111. #endif
  112. #endif // ON2CRYPT_H