home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sysmgmt / lsapi / md4.h < prev    next >
C/C++ Source or Header  |  1996-04-30  |  5KB  |  121 lines

  1. #ifndef _MD4_H_
  2. #define _MD4_H_
  3.  
  4. /* MD4.H - header file for MD4C.C
  5.  */
  6.  
  7. /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  8.    rights reserved.
  9.  
  10.    License to copy and use this software is granted provided that it
  11.    is identified as the "RSA Data Security, Inc. MD4 Message-Digest
  12.    Algorithm" in all material mentioning or referencing this software
  13.    or this function.
  14.  
  15.    License is also granted to make and use derivative works provided
  16.    that such works are identified as "derived from the RSA Data
  17.    Security, Inc. MD4 Message-Digest Algorithm" in all material
  18.    mentioning or referencing the derived work.
  19.  
  20.    RSA Data Security, Inc. makes no representations concerning either
  21.    the merchantability of this software or the suitability of this
  22.    software for any particular purpose. It is provided "as is"
  23.    without express or implied warranty of any kind.
  24.  
  25.    These notices must be retained in any copies of any part of this
  26.    documentation and/or software.
  27.  */
  28.  
  29. /* This code differs from the MD4 implementation contained in Internet
  30.    RFC-1320 in the following respects:
  31.  
  32.    1. "global.h" is no longer needed.
  33.  
  34.    2. PROTO_LIST was removed from the function prototypes.
  35.  
  36.    3. Comments on the use of the main calls added to aid developers.
  37.  */
  38.  
  39. /* ---------------------------------------------------------------------
  40.  * The procedure for using the following function calls to compute a
  41.  * digest is as follows:
  42.  *
  43.  *   MD4_CTX context;
  44.  *      // create a storage context that persistes between calls.
  45.  *
  46.  *   MD4_Init (&context);
  47.  *      // initialize context's initial digest and byte-count
  48.  *
  49.  *   MD4Update (&context, inputString, inputLength);
  50.  *      // input first or only block of data to be digested.
  51.  *
  52.  *   MD4Update (&context, inputString, inputLength);
  53.  *      // input subsequent blocks or last block of data to be digested.
  54.  *
  55.  *   MD4Final (digest, &context);
  56.  *      // compute and return final 16-byte digest
  57.  *
  58.  * --------------------------------------------------------------------- */
  59.  
  60. typedef unsigned long UINT4;
  61.  
  62. /* POINTER defines a generic pointer type */
  63. typedef unsigned char *POINTER;
  64.  
  65. /* MD4 context. */
  66. typedef struct {
  67.   UINT4 state[4];                                   /* state (ABCD) */
  68.   UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
  69.   unsigned char buffer[64];                         /* input buffer */
  70. } MD4_CTX;
  71.  
  72. /* ---------------------------------------------------------------------
  73.  * This function initializes the context for the message digest.
  74.  * It must be called as the first step and before processing input data.
  75.  * --------------------------------------------------------------------- */
  76.  
  77. void MD4Init ( MD4_CTX *context ) ;              /* context */
  78.  
  79. /* ---------------------------------------------------------------------
  80.  * This function accepts input data of length "inputLen" and digests it.
  81.  * All data to be digested is input via this function and no other.
  82.  * The running byte count and any fragment of undigested data is stored
  83.  * in the context for retention between calls.
  84.  * --------------------------------------------------------------------- */
  85.  
  86. void MD4Update ( MD4_CTX *context,              /* context */
  87.                  POINTER input,                 /* input block */
  88.                  unsigned int inputLen ) ;      /* length of input block */
  89.  
  90. /* ---------------------------------------------------------------------
  91.  * This function accepts not data, but finishes up the digest and
  92.  * returns the 16 byte resulting message digest.  Finishing up includes
  93.  * taking any undigested fragment stored in the context, padding the
  94.  * message, appending the length and then digesting the resulting string.
  95.  * --------------------------------------------------------------------- */
  96.  
  97. void MD4Final ( unsigned char *digest,          /* 16-byte message digest */
  98.                 MD4_CTX   *context ) ;          /* context */
  99.  
  100. /* ---------------------------------------------------------------------
  101.  
  102.    The MD4 test suite results, contained in appendix A.5 of RFC-1320,
  103.    are as listed below.  They are printed by the "mddriver.c" test
  104.    driver contained in appendix A.4 of RFC-1320.
  105.  
  106.    MD4 test suite:
  107.    MD4 ("") = 31d6cfe0d16ae931b73c59d7e0c089c0
  108.    MD4 ("a") = bde52cb31de33e46245e05fbdbd6fb24
  109.    MD4 ("abc") = a448017aaf21d8525fc10ae87aa6729d
  110.    MD4 ("message digest") = d9130a8164549fe818874806e1c7014b
  111.    MD4 ("abcdefghijklmnopqrstuvwxyz") = d79e1c308aa5bbcdeea8ed63df412da9
  112.    MD4 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
  113.          = 043f8582f241db351ce627e153e7f0e4
  114.    MD4 ("123456789012345678901234567890123456789012345678901234567890123
  115.          45678901234567890") = e33b4ddc9c38f2199c3e7b164fcc0536
  116.  
  117.  * --------------------------------------------------------------------- */
  118.  
  119. #endif
  120.  
  121.