home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: Security / Security.zip / bfish163.zip / ENCRYPT.H < prev    next >
Text File  |  1998-01-09  |  6KB  |  124 lines

  1. /**************************************************/
  2. /*                                                */
  3. /* ENCRYPT.H - Public interface to ENCRYPT.DLL    */
  4. /*                                                */
  5. /* Author: Matthew Spencer (msspenc@ibm.net)      */
  6. /*                                                */
  7. /* Version: 1.62                                  */
  8. /*                                                */
  9. /* Date:    9th January, 1998                     */
  10. /*                                                */
  11. /**************************************************/
  12. #ifndef ENCRYPT_H
  13. #define ENCRYPT_H
  14.  
  15. /*
  16. ** Chaining mode enumeration - see blowfish.doc for explanation
  17. */
  18. enum ChainingMode{ReInitialise, CarryForward};
  19.  
  20. /*
  21. ** Prototypes.  There are 2 sets of functions.  Use the ones which
  22. ** your compiler supports.  IBM C-Set and VisualAge C++ use _Optlink
  23. ** as the default linkage, while Borland C++ only supports _System.
  24. **
  25. ** New with Version 1.62:  I have used a couple of macros to save having
  26. ** to declare both sets of functions.  Borland C++ users (or those wishing
  27. ** to call the _System linkage functions) should revert to calling "Initialise"
  28. ** instead of "BfInitialise", and so on.
  29. ** Thanks to Jeremy Mathers for this idea.
  30. **
  31. */
  32.  
  33. #ifdef __BORLANDC__
  34.    #define BF_SYS_LINKAGE
  35. #endif
  36.  
  37. #ifndef BF_SYS_LINKAGE
  38.    #define BF_LINKAGE(func) _Optlink func
  39. #else
  40.    #define FUNC_NAME(func) Bf##func
  41.    #define SetBfVersion    FUNC_NAME(SetVersion     )
  42.    #define GetBfVersion    FUNC_NAME(GetVersion     )
  43.    #define SetChainingMode FUNC_NAME(SetChainingMode)
  44.    #define SetChainingSeed FUNC_NAME(SetChainingSeed)
  45.    #define Initialise      FUNC_NAME(Initialise     )
  46.    #define EncryptBlock    FUNC_NAME(EncryptBlock   )
  47.    #define DecryptBlock    FUNC_NAME(DecryptBlock   )
  48.    #define GetRandomBlock  FUNC_NAME(GetRandomBlock )
  49.    #define BF_LINKAGE(func) _System func
  50. #endif
  51.  
  52. void BF_LINKAGE(SetBfVersion   )(long version);           /* use version = 162, for compatibility */
  53. long BF_LINKAGE(GetBfVersion   )(void);                   /* query version being used             */
  54. void BF_LINKAGE(SetChainingMode)(int mode);               /* see blowfish.doc                     */
  55. void BF_LINKAGE(SetChainingSeed)(unsigned char * buffer); /* buffer size == 8, exactly!           */
  56. void BF_LINKAGE(Initialise     )(unsigned char * key,    short length);          /* length <= 56  */
  57. void BF_LINKAGE(EncryptBlock   )(unsigned char * buffer, unsigned long length);  /* length >= 8   */
  58. void BF_LINKAGE(DecryptBlock   )(unsigned char * buffer, unsigned long length);  /* length >= 8   */
  59. unsigned char *
  60.      BF_LINKAGE(GetRandomBlock )(unsigned char * buffer); /* buffer size == 8, exactly!           */
  61.  
  62. /*********************************************************************************/
  63. /*                                                                               */
  64. /* Compression/Decompression functions: (new with 1.62)                          */
  65. /*                                                                               */
  66. /* Both the Compress() and Decompress() functions take 3 arguments.  The first   */
  67. /* is a pointer (unsigned char *) to the original data.  The second is the       */
  68. /* length of the original data (unsigned long), and the third is a pointer to    */
  69. /* a pointer (unsigned char **), which is set by the functions, and which will   */
  70. /* point to the compressed (or decompressed) data after the operation.  Both     */
  71. /* functions return the length (unsigned long) of the compressed (or             */
  72. /* decompressed) data.                                                           */
  73. /*                                                                               */
  74. /* NOTE that these functions both allocate memory, and that it is the            */
  75. /* responsiblity of the calling modules to free this memory.  The original data  */
  76. /* is not altered in any way by these functions.                                 */
  77. /*                                                                               */
  78. /*********************************************************************************/
  79.  
  80. #ifdef BF_SYS_LINKAGE
  81.    #define Compress        FUNC_NAME(Compress       )
  82.    #define Decompress      FUNC_NAME(Decompress     )
  83. #endif
  84.  
  85. unsigned long BF_LINKAGE(Compress  )(unsigned char *  inputData,
  86.                                      unsigned long    inputLength,
  87.                                      unsigned char ** outputData);
  88.  
  89. unsigned long BF_LINKAGE(Decompress)(unsigned char *  inputData,
  90.                                      unsigned long    inputLength,
  91.                                      unsigned char ** outputData);
  92. /*
  93. ** Possible return codes
  94. */
  95. #ifndef NO_ERROR
  96.   #define NO_ERROR                                   0
  97. #endif
  98. #define BYTE_COUNT_DIFFERS_FROM_EXPECTED_LENGTH      1
  99. #define ERROR_DELETING_SOURCE_FILE                   3
  100. #define ERROR_OPENING_SOURCE_FILE                    7
  101. #define ERROR_OPENING_TARGET_FILE                    8
  102. #define ERROR_READING_SOURCE_FILE                    9
  103. #define INCORRECT_KEY                               11
  104. #define INCORRECT_SIGNATURE_IN_SOURCE_FILE          12
  105. #define OPERATION_ABORTED                           13
  106. #define INSUFFICIENT_SPACE_ON_TARGET_DRIVE          16
  107. #define KEY_HAS_ZERO_LENGTH                         18
  108. #define NO_FILES_MATCH_FILESPEC                     19
  109. #define FILE_HAS_ZERO_LENGTH                        20
  110. #define SINGLE_TARGET_MULTI_SOURCE                  21
  111. #define FILENAME_PROCESSING_ERROR                   22
  112. #define ERROR_DURING_TEMPORARY_FILE_RENAME          23
  113. #define TARGET_NAME_MATCHES_PREVIOUS_TARGET         24
  114. #define KEYS_DO_NOT_MATCH                           25
  115. #define SKIPPED_ALREADY_ENCRYPTED                   26
  116. #define SKIPPED_ALREADY_DECRYPTED                   27
  117. #define WILDCARDS_NOT_ALLOWED_IN_TARGET             28
  118. #define OLD_BLOWFISH_VERSION                        29
  119.  
  120. #define SYNTAX_ERROR                                98
  121. #define UNKNOWN_ERROR                               99
  122.  
  123. #endif
  124.