00001 /* Licensed to the Apache Software Foundation (ASF) under one or more 00002 * contributor license agreements. See the NOTICE file distributed with 00003 * this work for additional information regarding copyright ownership. 00004 * The ASF licenses this file to You under the Apache License, Version 2.0 00005 * (the "License"); you may not use this file except in compliance with 00006 * the License. You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 /* 00017 * FILE: sha2.h 00018 * AUTHOR: Aaron D. Gifford <me@aarongifford.com> 00019 * 00020 * A licence was granted to the ASF by Aaron on 4 November 2003. 00021 */ 00022 00023 #ifndef __SHA2_H__ 00024 #define __SHA2_H__ 00025 00026 #ifdef __cplusplus 00027 extern "C" { 00028 #endif 00029 00030 #include "apr.h" 00031 00032 /*** SHA-256 Various Length Definitions ***********************/ 00033 #define SHA256_BLOCK_LENGTH 64 00034 #define SHA256_DIGEST_LENGTH 32 00035 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) 00036 00037 00038 /*** SHA-256/384/512 Context Structures *******************************/ 00039 typedef struct _SHA256_CTX { 00040 apr_uint32_t state[8]; 00041 apr_uint64_t bitcount; 00042 apr_byte_t buffer[SHA256_BLOCK_LENGTH]; 00043 } SHA256_CTX; 00044 00045 00046 /*** SHA-256/384/512 Function Prototypes ******************************/ 00047 void apr__SHA256_Init(SHA256_CTX *); 00048 void apr__SHA256_Update(SHA256_CTX *, const apr_byte_t *, size_t); 00049 void apr__SHA256_Final(apr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *); 00050 char* apr__SHA256_End(SHA256_CTX *, char [SHA256_DIGEST_STRING_LENGTH]); 00051 char* apr__SHA256_Data(const apr_byte_t *, size_t, 00052 char [SHA256_DIGEST_STRING_LENGTH]); 00053 00054 #ifdef __cplusplus 00055 } 00056 #endif /* __cplusplus */ 00057 00058 #endif /* __SHA2_H__ */ 00059