Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages

sha2.h

00001 /* Copyright 2003-2004 The Apache Software Foundation 00002 * 00003 * Licensed under the Apache License, Version 2.0 (the "License"); 00004 * you may not use this file except in compliance with the License. 00005 * You may obtain a copy of the License at 00006 * 00007 * http://www.apache.org/licenses/LICENSE-2.0 00008 * 00009 * Unless required by applicable law or agreed to in writing, software 00010 * distributed under the License is distributed on an "AS IS" BASIS, 00011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00012 * See the License for the specific language governing permissions and 00013 * limitations under the License. 00014 */ 00015 /* 00016 * FILE: sha2.h 00017 * AUTHOR: Aaron D. Gifford <me@aarongifford.com> 00018 * 00019 * A licence was granted to the ASF by Aaron on 4 November 2003. 00020 */ 00021 00022 #ifndef __SHA2_H__ 00023 #define __SHA2_H__ 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00029 #include "apr.h" 00030 00031 /*** SHA-256/384/512 Various Length Definitions ***********************/ 00032 #define SHA256_BLOCK_LENGTH 64 00033 #define SHA256_DIGEST_LENGTH 32 00034 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) 00035 #define SHA384_BLOCK_LENGTH 128 00036 #define SHA384_DIGEST_LENGTH 48 00037 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) 00038 #define SHA512_BLOCK_LENGTH 128 00039 #define SHA512_DIGEST_LENGTH 64 00040 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) 00041 00042 00043 /*** SHA-256/384/512 Context Structures *******************************/ 00044 typedef struct _SHA256_CTX { 00045 apr_uint32_t state[8]; 00046 apr_uint64_t bitcount; 00047 apr_byte_t buffer[SHA256_BLOCK_LENGTH]; 00048 } SHA256_CTX; 00049 typedef struct _SHA512_CTX { 00050 apr_uint64_t state[8]; 00051 apr_uint64_t bitcount[2]; 00052 apr_byte_t buffer[SHA512_BLOCK_LENGTH]; 00053 } SHA512_CTX; 00054 00055 typedef SHA512_CTX SHA384_CTX; 00056 00057 00058 /*** SHA-256/384/512 Function Prototypes ******************************/ 00059 void SHA256_Init(SHA256_CTX *); 00060 void SHA256_Update(SHA256_CTX *, const apr_byte_t *, size_t); 00061 void SHA256_Final(apr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *); 00062 char* SHA256_End(SHA256_CTX *, char [SHA256_DIGEST_STRING_LENGTH]); 00063 char* SHA256_Data(const apr_byte_t *, size_t, 00064 char [SHA256_DIGEST_STRING_LENGTH]); 00065 00066 void SHA384_Init(SHA384_CTX *); 00067 void SHA384_Update(SHA384_CTX *, const apr_byte_t *, size_t); 00068 void SHA384_Final(apr_byte_t [SHA384_DIGEST_LENGTH], SHA384_CTX *); 00069 char* SHA384_End(SHA384_CTX *, char [SHA384_DIGEST_STRING_LENGTH]); 00070 char* SHA384_Data(const apr_byte_t *, size_t, 00071 char [SHA384_DIGEST_STRING_LENGTH]); 00072 00073 void SHA512_Init(SHA512_CTX *); 00074 void SHA512_Update(SHA512_CTX *, const apr_byte_t *, size_t); 00075 void SHA512_Final(apr_byte_t [SHA512_DIGEST_LENGTH], SHA512_CTX *); 00076 char* SHA512_End(SHA512_CTX *, char [SHA512_DIGEST_STRING_LENGTH]); 00077 char* SHA512_Data(const apr_byte_t *, size_t, 00078 char [SHA512_DIGEST_STRING_LENGTH]); 00079 00080 #ifdef __cplusplus 00081 } 00082 #endif /* __cplusplus */ 00083 00084 #endif /* __SHA2_H__ */ 00085

Generated on Thu Sep 16 13:47:10 2004 for Apache Portable Runtime by doxygen 1.3.7