ext/digest/md5/md5.h


DEFINITIONS

This source file includes following functions.


   1  /*
   2    Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
   3  
   4    This software is provided 'as-is', without any express or implied
   5    warranty.  In no event will the authors be held liable for any damages
   6    arising from the use of this software.
   7  
   8    Permission is granted to anyone to use this software for any purpose,
   9    including commercial applications, and to alter it and redistribute it
  10    freely, subject to the following restrictions:
  11  
  12    1. The origin of this software must not be misrepresented; you must not
  13       claim that you wrote the original software. If you use this software
  14       in a product, an acknowledgment in the product documentation would be
  15       appreciated but is not required.
  16    2. Altered source versions must be plainly marked as such, and must not be
  17       misrepresented as being the original software.
  18    3. This notice may not be removed or altered from any source distribution.
  19  
  20    L. Peter Deutsch
  21    ghost@aladdin.com
  22  
  23   */
  24  /*
  25    Independent implementation of MD5 (RFC 1321).
  26  
  27    This code implements the MD5 Algorithm defined in RFC 1321.
  28    It is derived directly from the text of the RFC and not from the
  29    reference implementation.
  30  
  31    The original and principal author of md5.h is L. Peter Deutsch
  32    <ghost@aladdin.com>.  Other authors are noted in the change history
  33    that follows (in reverse chronological order):
  34  
  35    1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
  36    1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
  37          added conditionalization for C++ compilation from Martin
  38          Purschke <purschke@bnl.gov>.
  39    1999-05-03 lpd Original version.
  40   */
  41  
  42  /* $OrigId: md5.h,v 1.2 2001/03/26 08:57:14 matz Exp $ */
  43  /* $RoughId: md5.h,v 1.3 2002/02/24 08:14:31 knu Exp $ */
  44  /* $Id: md5.h,v 1.2 2002/02/24 08:20:22 knu Exp $ */
  45  
  46  #ifndef MD5_INCLUDED
  47  #  define MD5_INCLUDED
  48  
  49  #include "defs.h"
  50  
  51  /*
  52   * This code has some adaptations for the Ghostscript environment, but it
  53   * will compile and run correctly in any environment with 8-bit chars and
  54   * 32-bit ints.  Specifically, it assumes that if the following are
  55   * defined, they have the same meaning as in Ghostscript: P1, P2, P3.
  56   */
  57  
  58  /* Define the state of the MD5 Algorithm. */
  59  typedef struct md5_state_s {
  60      uint32_t count[2];  /* message length in bits, lsw first */
  61      uint32_t state[4];  /* digest buffer */
  62      uint8_t buffer[64]; /* accumulate block */
  63  } MD5_CTX;
  64  
  65  #ifdef RUBY
  66  #define MD5_Init        rb_Digest_MD5_Init
  67  #define MD5_Update      rb_Digest_MD5_Update
  68  #define MD5_Final       rb_Digest_MD5_Final
  69  #define MD5_End         rb_Digest_MD5_End
  70  #define MD5_Equal       rb_Digest_MD5_Equal
  71  #endif
  72  
  73  void    MD5_Init _((MD5_CTX *pms));
  74  void    MD5_Update _((MD5_CTX *pms, const uint8_t *data, size_t nbytes));
  75  void    MD5_Final _((uint8_t *digest, MD5_CTX *pms));
  76  void    MD5_End _((MD5_CTX *pctx, uint8_t *hexdigest));
  77  int     MD5_Equal _((MD5_CTX *pctx1, MD5_CTX *pctx2));
  78  
  79  #define MD5_BLOCK_LENGTH                64
  80  #define MD5_DIGEST_LENGTH               16
  81  #define MD5_DIGEST_STRING_LENGTH        (MD5_DIGEST_LENGTH * 2 + 1)
  82  
  83  #endif /* MD5_INCLUDED */