842ae4bd224140319ae7feec1872b93dfd491143fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
842ae4bd224140319ae7feec1872b93dfd491143fielding * contributor license agreements. See the NOTICE file distributed with
842ae4bd224140319ae7feec1872b93dfd491143fielding * this work for additional information regarding copyright ownership.
842ae4bd224140319ae7feec1872b93dfd491143fielding * The ASF licenses this file to You under the Apache License, Version 2.0
842ae4bd224140319ae7feec1872b93dfd491143fielding * (the "License"); you may not use this file except in compliance with
842ae4bd224140319ae7feec1872b93dfd491143fielding * the License. You may obtain a copy of the License at
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * Unless required by applicable law or agreed to in writing, software
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * distributed under the License is distributed on an "AS IS" BASIS,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * See the License for the specific language governing permissions and
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * limitations under the License.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/************************************************************************
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * NCSA HTTPd Server
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Software Development Group
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * National Center for Supercomputing Applications
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * University of Illinois at Urbana-Champaign
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 605 E. Springfield, Champaign, IL 61820
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * httpd@ncsa.uiuc.edu
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Copyright (C) 1995, Board of Trustees of the University of Illinois
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ************************************************************************
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * md5.c: NCSA HTTPd code which uses the md5c.c RSA Code
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Original Code Copyright (C) 1994, Jeff Hostetler, Spyglass, Inc.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Portions of Content-MD5 code Copyright (C) 1993, 1994 by Carnegie Mellon
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * University (see Copyright below).
e8f95a682820a599fe41b22977010636be5c2717jim * Portions of Content-MD5 code Copyright (C) 1991 Bell Communications
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Research, Inc. (Bellcore) (see Copyright below).
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Portions extracted from mpack, John G. Myers - jgm+@cmu.edu
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Content-MD5 Code contributed by Martin Hamilton (martin@net.lut.ac.uk)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* md5.c --Module Interface to MD5. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Jeff Hostetler, Spyglass, Inc., 1994. */
3d96ee83babeec32482c9082c9426340cee8c44dwroweAP_DECLARE(char *) ap_md5_binary(apr_pool_t *p, const unsigned char *buf, int length)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Take the MD5 hash of the string argument.
d0ba3b97557d47323bd055fb4002ed7692f703b9jerenkrantz return apr_pstrndup(p, result, APR_MD5_DIGESTSIZE*2);
3d96ee83babeec32482c9082c9426340cee8c44dwroweAP_DECLARE(char *) ap_md5(apr_pool_t *p, const unsigned char *string)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding return ap_md5_binary(p, string, (int) strlen((char *)string));
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* these portions extracted from mpack, John G. Myers - jgm+@cmu.edu */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* (C) Copyright 1993,1994 by Carnegie Mellon University
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * All Rights Reserved.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Permission to use, copy, modify, distribute, and sell this software
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * and its documentation for any purpose is hereby granted without
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * fee, provided that the above copyright notice appear in all copies
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * and that both that copyright notice and this permission notice
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * appear in supporting documentation, and that the name of Carnegie
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Mellon University not be used in advertising or publicity
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * pertaining to distribution of the software without specific,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * written prior permission. Carnegie Mellon University makes no
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * representations about the suitability of this software for any
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * purpose. It is provided "as is" without express or implied
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * warranty.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * SOFTWARE.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Permission to use, copy, modify, and distribute this material
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * for any purpose and without fee is hereby granted, provided
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * that the above copyright notice and this permission notice
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * appear in all copies, and that the name of Bellcore not be
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * used in advertising or publicity pertaining to this
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * material without the specific, prior written permission
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * of an authorized representative of Bellcore. BELLCORE
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
e8f95a682820a599fe41b22977010636be5c2717jim * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
3d96ee83babeec32482c9082c9426340cee8c44dwroweAP_DECLARE(char *) ap_md5contextTo64(apr_pool_t *a, apr_md5_ctx_t *context)
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm encodedDigest = (char *) apr_pcalloc(a, 25 * sizeof(char));
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding digest[sizeof(digest) - 1] = digest[sizeof(digest) - 2] = 0;
43c3e6a4b559b76b750c245ee95e2782c15b4296jim *p++ = basis_64[((digest[i] & 0x3) << 4) | ((int) (digest[i + 1] & 0xF0) >> 4)];
43c3e6a4b559b76b750c245ee95e2782c15b4296jim *p++ = basis_64[((digest[i + 1] & 0xF) << 2) | ((int) (digest[i + 2] & 0xC0) >> 6)];
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *p-- = '\0';
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *p-- = '=';
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *p-- = '=';
3d96ee83babeec32482c9082c9426340cee8c44dwroweAP_DECLARE(char *) ap_md5digest(apr_pool_t *p, apr_file_t *infile)
fbe3307b402780c3e9300e49c95b990d906dd605jorton unsigned char buf[4096]; /* keep this a multiple of 64 */
066877f1a045103acfdd376d48cdd473c33f409bdougm while (apr_file_read(infile, buf, &nbytes) == APR_SUCCESS) {