00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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
00033 #define SHA256_BLOCK_LENGTH 64
00034 #define SHA256_DIGEST_LENGTH 32
00035 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1)
00036 #define SHA384_BLOCK_LENGTH 128
00037 #define SHA384_DIGEST_LENGTH 48
00038 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1)
00039 #define SHA512_BLOCK_LENGTH 128
00040 #define SHA512_DIGEST_LENGTH 64
00041 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1)
00042
00043
00044
00045 typedef struct _SHA256_CTX {
00046 apr_uint32_t state[8];
00047 apr_uint64_t bitcount;
00048 apr_byte_t buffer[SHA256_BLOCK_LENGTH];
00049 } SHA256_CTX;
00050 typedef struct _SHA512_CTX {
00051 apr_uint64_t state[8];
00052 apr_uint64_t bitcount[2];
00053 apr_byte_t buffer[SHA512_BLOCK_LENGTH];
00054 } SHA512_CTX;
00055
00056 typedef SHA512_CTX SHA384_CTX;
00057
00058
00059
00060 void apr__SHA256_Init(SHA256_CTX *);
00061 void apr__SHA256_Update(SHA256_CTX *, const apr_byte_t *, size_t);
00062 void apr__SHA256_Final(apr_byte_t [SHA256_DIGEST_LENGTH], SHA256_CTX *);
00063 char* apr__SHA256_End(SHA256_CTX *, char [SHA256_DIGEST_STRING_LENGTH]);
00064 char* apr__SHA256_Data(const apr_byte_t *, size_t,
00065 char [SHA256_DIGEST_STRING_LENGTH]);
00066
00067 void apr__SHA384_Init(SHA384_CTX *);
00068 void apr__SHA384_Update(SHA384_CTX *, const apr_byte_t *, size_t);
00069 void apr__SHA384_Final(apr_byte_t [SHA384_DIGEST_LENGTH], SHA384_CTX *);
00070 char* apr__SHA384_End(SHA384_CTX *, char [SHA384_DIGEST_STRING_LENGTH]);
00071 char* apr__SHA384_Data(const apr_byte_t *, size_t,
00072 char [SHA384_DIGEST_STRING_LENGTH]);
00073
00074 void apr__SHA512_Init(SHA512_CTX *);
00075 void apr__SHA512_Update(SHA512_CTX *, const apr_byte_t *, size_t);
00076 void apr__SHA512_Final(apr_byte_t [SHA512_DIGEST_LENGTH], SHA512_CTX *);
00077 char* apr__SHA512_End(SHA512_CTX *, char [SHA512_DIGEST_STRING_LENGTH]);
00078 char* apr__SHA512_Data(const apr_byte_t *, size_t,
00079 char [SHA512_DIGEST_STRING_LENGTH]);
00080
00081 #ifdef __cplusplus
00082 }
00083 #endif
00084
00085 #endif
00086