|
Packit |
383869 |
/*
|
|
Packit |
383869 |
* This is work is derived from material Copyright RSA Data Security, Inc.
|
|
Packit |
383869 |
*
|
|
Packit |
383869 |
* The RSA copyright statement and Licence for that original material is
|
|
Packit |
383869 |
* included below. This is followed by the Apache copyright statement and
|
|
Packit |
383869 |
* licence for the modifications made to that material.
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
|
Packit |
383869 |
rights reserved.
|
|
Packit |
383869 |
|
|
Packit |
383869 |
License to copy and use this software is granted provided that it
|
|
Packit |
383869 |
is identified as the "RSA Data Security, Inc. MD5 Message-Digest
|
|
Packit |
383869 |
Algorithm" in all material mentioning or referencing this software
|
|
Packit |
383869 |
or this function.
|
|
Packit |
383869 |
|
|
Packit |
383869 |
License is also granted to make and use derivative works provided
|
|
Packit |
383869 |
that such works are identified as "derived from the RSA Data
|
|
Packit |
383869 |
Security, Inc. MD5 Message-Digest Algorithm" in all material
|
|
Packit |
383869 |
mentioning or referencing the derived work.
|
|
Packit |
383869 |
|
|
Packit |
383869 |
RSA Data Security, Inc. makes no representations concerning either
|
|
Packit |
383869 |
the merchantability of this software or the suitability of this
|
|
Packit |
383869 |
software for any particular purpose. It is provided "as is"
|
|
Packit |
383869 |
without express or implied warranty of any kind.
|
|
Packit |
383869 |
|
|
Packit |
383869 |
These notices must be retained in any copies of any part of this
|
|
Packit |
383869 |
documentation and/or software.
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
|
|
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 |
|
|
Packit |
383869 |
#ifndef APR_MD5_H
|
|
Packit |
383869 |
#define APR_MD5_H
|
|
Packit |
383869 |
|
|
Packit |
383869 |
#include "apu.h"
|
|
Packit |
383869 |
#include "apr_xlate.h"
|
|
Packit |
383869 |
|
|
Packit |
383869 |
#ifdef __cplusplus
|
|
Packit |
383869 |
extern "C" {
|
|
Packit |
383869 |
#endif
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* @file apr_md5.h
|
|
Packit |
383869 |
* @brief APR MD5 Routines
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* @defgroup APR_MD5 MD5 Routines
|
|
Packit |
383869 |
* @ingroup APR
|
|
Packit |
383869 |
* @{
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/** The MD5 digest size */
|
|
Packit |
383869 |
#define APR_MD5_DIGESTSIZE 16
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/** @see apr_md5_ctx_t */
|
|
Packit |
383869 |
typedef struct apr_md5_ctx_t apr_md5_ctx_t;
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/** MD5 context. */
|
|
Packit |
383869 |
struct apr_md5_ctx_t {
|
|
Packit |
383869 |
/** state (ABCD) */
|
|
Packit |
383869 |
apr_uint32_t state[4];
|
|
Packit |
383869 |
/** number of bits, modulo 2^64 (lsb first) */
|
|
Packit |
383869 |
apr_uint32_t count[2];
|
|
Packit |
383869 |
/** input buffer */
|
|
Packit |
383869 |
unsigned char buffer[64];
|
|
Packit |
383869 |
/** translation handle
|
|
Packit |
383869 |
* ignored if xlate is unsupported
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
apr_xlate_t *xlate;
|
|
Packit |
383869 |
};
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* MD5 Initialize. Begins an MD5 operation, writing a new context.
|
|
Packit |
383869 |
* @param context The MD5 context to initialize.
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(apr_status_t) apr_md5_init(apr_md5_ctx_t *context);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* MD5 translation setup. Provides the APR translation handle to be used
|
|
Packit |
383869 |
* for translating the content before calculating the digest.
|
|
Packit |
383869 |
* @param context The MD5 content to set the translation for.
|
|
Packit |
383869 |
* @param xlate The translation handle to use for this MD5 context
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(apr_status_t) apr_md5_set_xlate(apr_md5_ctx_t *context,
|
|
Packit |
383869 |
apr_xlate_t *xlate);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* MD5 block update operation. Continue an MD5 message-digest operation,
|
|
Packit |
383869 |
* processing another message block, and updating the context.
|
|
Packit |
383869 |
* @param context The MD5 content to update.
|
|
Packit |
383869 |
* @param input next message block to update
|
|
Packit |
383869 |
* @param inputLen The length of the next message block
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(apr_status_t) apr_md5_update(apr_md5_ctx_t *context,
|
|
Packit |
383869 |
const void *input,
|
|
Packit |
383869 |
apr_size_t inputLen);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* MD5 finalization. Ends an MD5 message-digest operation, writing the
|
|
Packit |
383869 |
* message digest and zeroing the context
|
|
Packit |
383869 |
* @param digest The final MD5 digest
|
|
Packit |
383869 |
* @param context The MD5 content we are finalizing.
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(apr_status_t) apr_md5_final(unsigned char digest[APR_MD5_DIGESTSIZE],
|
|
Packit |
383869 |
apr_md5_ctx_t *context);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* MD5 in one step
|
|
Packit |
383869 |
* @param digest The final MD5 digest
|
|
Packit |
383869 |
* @param input The message block to use
|
|
Packit |
383869 |
* @param inputLen The length of the message block
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(apr_status_t) apr_md5(unsigned char digest[APR_MD5_DIGESTSIZE],
|
|
Packit |
383869 |
const void *input,
|
|
Packit |
383869 |
apr_size_t inputLen);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* Encode a password using an MD5 algorithm
|
|
Packit |
383869 |
* @param password The password to encode
|
|
Packit |
383869 |
* @param salt The salt string to use for the encoding
|
|
Packit |
383869 |
* @param result The string to store the encoded password in
|
|
Packit |
383869 |
* @param nbytes The size of the result buffer
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(apr_status_t) apr_md5_encode(const char *password, const char *salt,
|
|
Packit |
383869 |
char *result, apr_size_t nbytes);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* Encode a password using the bcrypt algorithm
|
|
Packit |
383869 |
* @param password The password to encode
|
|
Packit |
383869 |
* @param count The cost of the encoding, possible values are 4 to 31
|
|
Packit |
383869 |
* @param salt Pointer to binary data to be used as salt for the encoding
|
|
Packit |
383869 |
* @param salt_len The size of the salt data (must be >= 16)
|
|
Packit |
383869 |
* @param out The string to store the encoded password in
|
|
Packit |
383869 |
* @param out_len The size of the result buffer (must be >= 61)
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(apr_status_t) apr_bcrypt_encode(const char *pw,
|
|
Packit |
383869 |
unsigned int count,
|
|
Packit |
383869 |
const unsigned char *salt,
|
|
Packit |
383869 |
apr_size_t salt_len,
|
|
Packit |
383869 |
char *out, apr_size_t out_len);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/**
|
|
Packit |
383869 |
* Validate hashes created by APR-supported algorithms: md5, bcrypt, and sha1.
|
|
Packit |
383869 |
* hashes created by crypt are supported only on platforms that provide
|
|
Packit |
383869 |
* crypt(3), so don't rely on that function unless you know that your
|
|
Packit |
383869 |
* application will be run only on platforms that support it. On platforms
|
|
Packit |
383869 |
* that don't support crypt(3), this falls back to a clear text string
|
|
Packit |
383869 |
* comparison.
|
|
Packit |
383869 |
* @param passwd The password to validate
|
|
Packit |
383869 |
* @param hash The password to validate against
|
|
Packit |
383869 |
*/
|
|
Packit |
383869 |
APU_DECLARE(apr_status_t) apr_password_validate(const char *passwd,
|
|
Packit |
383869 |
const char *hash);
|
|
Packit |
383869 |
|
|
Packit |
383869 |
|
|
Packit |
383869 |
/** @} */
|
|
Packit |
383869 |
#ifdef __cplusplus
|
|
Packit |
383869 |
}
|
|
Packit |
383869 |
#endif
|
|
Packit |
383869 |
|
|
Packit |
383869 |
#endif /* !APR_MD5_H */
|