Blame include/apr_sha1.h

Packit 383869
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 383869
 * contributor license agreements.  See the NOTICE file distributed with
Packit 383869
 * this work for additional information regarding copyright ownership.
Packit 383869
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 383869
 * (the "License"); you may not use this file except in compliance with
Packit 383869
 * the License.  You may obtain a copy of the License at
Packit 383869
 *
Packit 383869
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 383869
 *
Packit 383869
 * Unless required by applicable law or agreed to in writing, software
Packit 383869
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 383869
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 383869
 * See the License for the specific language governing permissions and
Packit 383869
 * limitations under the License.
Packit 383869
 */
Packit 383869
/* NIST Secure Hash Algorithm
Packit 383869
 * 	heavily modified by Uwe Hollerbach uh@alumni.caltech edu
Packit 383869
 * 	from Peter C. Gutmann's implementation as found in
Packit 383869
 * 	Applied Cryptography by Bruce Schneier
Packit 383869
 * 	This code is hereby placed in the public domain
Packit 383869
 */
Packit 383869
Packit 383869
#ifndef APR_SHA1_H
Packit 383869
#define APR_SHA1_H
Packit 383869
Packit 383869
#include "apu.h"
Packit 383869
#include "apr_general.h"
Packit 383869
Packit 383869
#ifdef __cplusplus
Packit 383869
extern "C" {
Packit 383869
#endif
Packit 383869
Packit 383869
/**
Packit 383869
 * @file apr_sha1.h
Packit 383869
 * @brief APR-UTIL SHA1 library
Packit 383869
 */
Packit 383869
Packit 383869
/** size of the SHA1 DIGEST */
Packit 383869
#define APR_SHA1_DIGESTSIZE 20
Packit 383869
Packit 383869
/**
Packit 383869
 * Define the Magic String prefix that identifies a password as being
Packit 383869
 * hashed using our algorithm.
Packit 383869
 */
Packit 383869
#define APR_SHA1PW_ID "{SHA}"
Packit 383869
Packit 383869
/** length of the SHA Password */
Packit 383869
#define APR_SHA1PW_IDLEN 5
Packit 383869
Packit 383869
/** @see apr_sha1_ctx_t */
Packit 383869
typedef struct apr_sha1_ctx_t apr_sha1_ctx_t;
Packit 383869
Packit 383869
/** 
Packit 383869
 * SHA1 context structure
Packit 383869
 */
Packit 383869
struct apr_sha1_ctx_t {
Packit 383869
    /** message digest */
Packit 383869
    apr_uint32_t digest[5];
Packit 383869
    /** 64-bit bit counts */
Packit 383869
    apr_uint32_t count_lo, count_hi;
Packit 383869
    /** SHA data buffer */
Packit 383869
    apr_uint32_t data[16];
Packit 383869
    /** unprocessed amount in data */
Packit 383869
    int local;
Packit 383869
};
Packit 383869
Packit 383869
/**
Packit 383869
 * Provide a means to SHA1 crypt/encode a plaintext password in a way which
Packit 383869
 * makes password file compatible with those commonly use in netscape web
Packit 383869
 * and ldap installations.
Packit 383869
 * @param clear The plaintext password
Packit 383869
 * @param len The length of the plaintext password
Packit 383869
 * @param out The encrypted/encoded password
Packit 383869
 * @note SHA1 support is useful for migration purposes, but is less
Packit 383869
 *     secure than Apache's password format, since Apache's (MD5)
Packit 383869
 *     password format uses a random eight character salt to generate
Packit 383869
 *     one of many possible hashes for the same password.  Netscape
Packit 383869
 *     uses plain SHA1 without a salt, so the same password
Packit 383869
 *     will always generate the same hash, making it easier
Packit 383869
 *     to break since the search space is smaller.
Packit 383869
 */
Packit 383869
APU_DECLARE(void) apr_sha1_base64(const char *clear, int len, char *out);
Packit 383869
Packit 383869
/**
Packit 383869
 * Initialize the SHA digest
Packit 383869
 * @param context The SHA context to initialize
Packit 383869
 */
Packit 383869
APU_DECLARE(void) apr_sha1_init(apr_sha1_ctx_t *context);
Packit 383869
Packit 383869
/**
Packit 383869
 * Update the SHA digest
Packit 383869
 * @param context The SHA1 context to update
Packit 383869
 * @param input The buffer to add to the SHA digest
Packit 383869
 * @param inputLen The length of the input buffer
Packit 383869
 */
Packit 383869
APU_DECLARE(void) apr_sha1_update(apr_sha1_ctx_t *context, const char *input,
Packit 383869
                                unsigned int inputLen);
Packit 383869
Packit 383869
/**
Packit 383869
 * Update the SHA digest with binary data
Packit 383869
 * @param context The SHA1 context to update
Packit 383869
 * @param input The buffer to add to the SHA digest
Packit 383869
 * @param inputLen The length of the input buffer
Packit 383869
 */
Packit 383869
APU_DECLARE(void) apr_sha1_update_binary(apr_sha1_ctx_t *context,
Packit 383869
                                       const unsigned char *input,
Packit 383869
                                       unsigned int inputLen);
Packit 383869
Packit 383869
/**
Packit 383869
 * Finish computing the SHA digest
Packit 383869
 * @param digest the output buffer in which to store the digest
Packit 383869
 * @param context The context to finalize
Packit 383869
 */
Packit 383869
APU_DECLARE(void) apr_sha1_final(unsigned char digest[APR_SHA1_DIGESTSIZE],
Packit 383869
                               apr_sha1_ctx_t *context);
Packit 383869
Packit 383869
#ifdef __cplusplus
Packit 383869
}
Packit 383869
#endif
Packit 383869
Packit 383869
#endif	/* APR_SHA1_H */