home *** CD-ROM | disk | FTP | other *** search
/ PC World Plus! (NZ) 2001 October / PCW1001.iso / Linux / apache / apache_1.3.20-win32-no_src-r2.msi / Data.Cab / F160725_ap_md5.h < prev    next >
C/C++ Source or Header  |  2001-05-15  |  5KB  |  132 lines

  1. /*
  2.  * This is work is derived from material Copyright RSA Data Security, Inc.
  3.  *
  4.  * The RSA copyright statement and Licence for that original material is
  5.  * included below. This is followed by the Apache copyright statement and
  6.  * licence for the modifications made to that material.
  7.  */
  8.  
  9. /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  10.    rights reserved.
  11.  
  12.    License to copy and use this software is granted provided that it
  13.    is identified as the "RSA Data Security, Inc. MD5 Message-Digest
  14.    Algorithm" in all material mentioning or referencing this software
  15.    or this function.
  16.  
  17.    License is also granted to make and use derivative works provided
  18.    that such works are identified as "derived from the RSA Data
  19.    Security, Inc. MD5 Message-Digest Algorithm" in all material
  20.    mentioning or referencing the derived work.
  21.  
  22.    RSA Data Security, Inc. makes no representations concerning either
  23.    the merchantability of this software or the suitability of this
  24.    software for any particular purpose. It is provided "as is"
  25.    without express or implied warranty of any kind.
  26.  
  27.    These notices must be retained in any copies of any part of this
  28.    documentation and/or software.
  29.  */
  30.  
  31. /* ====================================================================
  32.  * The Apache Software License, Version 1.1
  33.  *
  34.  * Copyright (c) 2000 The Apache Software Foundation.  All rights
  35.  * reserved.
  36.  *
  37.  * Redistribution and use in source and binary forms, with or without
  38.  * modification, are permitted provided that the following conditions
  39.  * are met:
  40.  *
  41.  * 1. Redistributions of source code must retain the above copyright
  42.  *    notice, this list of conditions and the following disclaimer.
  43.  *
  44.  * 2. Redistributions in binary form must reproduce the above copyright
  45.  *    notice, this list of conditions and the following disclaimer in
  46.  *    the documentation and/or other materials provided with the
  47.  *    distribution.
  48.  *
  49.  * 3. The end-user documentation included with the redistribution,
  50.  *    if any, must include the following acknowledgment:
  51.  *       "This product includes software developed by the
  52.  *        Apache Software Foundation (http://www.apache.org/)."
  53.  *    Alternately, this acknowledgment may appear in the software itself,
  54.  *    if and wherever such third-party acknowledgments normally appear.
  55.  *
  56.  * 4. The names "Apache" and "Apache Software Foundation" must
  57.  *    not be used to endorse or promote products derived from this
  58.  *    software without prior written permission. For written
  59.  *    permission, please contact apache@apache.org.
  60.  *
  61.  * 5. Products derived from this software may not be called "Apache",
  62.  *    nor may "Apache" appear in their name, without prior written
  63.  *    permission of the Apache Software Foundation.
  64.  *
  65.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  66.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  67.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  68.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  69.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  70.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  71.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  72.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  73.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  74.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  75.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  76.  * SUCH DAMAGE.
  77.  * ====================================================================
  78.  *
  79.  * This software consists of voluntary contributions made by many
  80.  * individuals on behalf of the Apache Software Foundation.  For more
  81.  * information on the Apache Software Foundation, please see
  82.  * <http://www.apache.org/>.
  83.  *
  84.  * Portions of this software are based upon public domain software
  85.  * originally written at the National Center for Supercomputing Applications,
  86.  * University of Illinois, Urbana-Champaign.
  87.  */
  88.  
  89. #ifndef APACHE_MD5_H
  90. #define APACHE_MD5_H
  91.  
  92. #ifdef __cplusplus
  93. extern "C" {
  94. #endif
  95.  
  96. /* MD5.H - header file for MD5C.C */
  97.  
  98. #define MD5_DIGESTSIZE 16
  99.  
  100. /* UINT4 defines a four byte word */
  101. typedef unsigned int UINT4;
  102.  
  103. /* MD5 context. */
  104. typedef struct {
  105.     UINT4 state[4];        /* state (ABCD) */
  106.     UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
  107.     unsigned char buffer[64];    /* input buffer */
  108. } AP_MD5_CTX;
  109.  
  110. /*
  111.  * Define the Magic String prefix that identifies a password as being
  112.  * hashed using our algorithm.
  113.  */
  114. #define AP_MD5PW_ID "$apr1$"
  115. #define AP_MD5PW_IDLEN 6
  116.  
  117. API_EXPORT(void) ap_MD5Init(AP_MD5_CTX *context);
  118. API_EXPORT(void) ap_MD5Update(AP_MD5_CTX *context, const unsigned char *input,
  119.                   unsigned int inputLen);
  120. API_EXPORT(void) ap_MD5Final(unsigned char digest[MD5_DIGESTSIZE],
  121.                  AP_MD5_CTX *context);
  122. API_EXPORT(void) ap_MD5Encode(const unsigned char *password,
  123.                   const unsigned char *salt,
  124.                   char *result, size_t nbytes);
  125. API_EXPORT(void) ap_to64(char *s, unsigned long v, int n);
  126.  
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130.  
  131. #endif    /* !APACHE_MD5_H */
  132.