Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygensha2.h
Go to the documentation of this file.
00001 /* 00002 * FILE: sha2.h 00003 * AUTHOR: Aaron D. Gifford - http://www.aarongifford.com/ 00004 * 00005 * Copyright (c) 2000-2001, Aaron D. Gifford 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. Neither the name of the copyright holder nor the names of contributors 00017 * may be used to endorse or promote products derived from this software 00018 * without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND 00021 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00022 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00023 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE 00024 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00025 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00026 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00027 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00028 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00029 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00030 * SUCH DAMAGE. 00031 */ 00032 00033 #ifndef __SHA2_H__ 00034 #define __SHA2_H__ 00035 00036 #include <basetsd.h> 00037 00038 /*** SHA-256/384/512 Various Length Definitions ***********************/ 00039 #define SHA256_BLOCK_LENGTH 64 00040 #define SHA256_DIGEST_LENGTH 32 00041 #define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) 00042 #define SHA384_BLOCK_LENGTH 128 00043 #define SHA384_DIGEST_LENGTH 48 00044 #define SHA384_DIGEST_STRING_LENGTH (SHA384_DIGEST_LENGTH * 2 + 1) 00045 #define SHA512_BLOCK_LENGTH 128 00046 #define SHA512_DIGEST_LENGTH 64 00047 #define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) 00048 00049 00050 /*** SHA-256/384/512 Context Structures *******************************/ 00051 typedef UINT8 sha2_byte; /* Exactly 1 byte */ 00052 typedef UINT32 sha2_word32; /* Exactly 4 bytes */ 00053 typedef UINT64 sha2_word64; /* Exactly 8 bytes */ 00054 00055 typedef struct _SHA256_CTX { 00056 sha2_word32 state[8]; 00057 sha2_word64 bitcount; 00058 sha2_byte buffer[SHA256_BLOCK_LENGTH]; 00059 } SHA256_CTX; 00060 typedef struct _SHA512_CTX { 00061 sha2_word64 state[8]; 00062 sha2_word64 bitcount[2]; 00063 sha2_byte buffer[SHA512_BLOCK_LENGTH]; 00064 } SHA512_CTX; 00065 00066 typedef SHA512_CTX SHA384_CTX; 00067 00068 00069 /*** SHA-256/384/512 Function Prototypes ******************************/ 00070 00071 void SHA256_Init(SHA256_CTX *); 00072 void SHA256_Update(SHA256_CTX*, const sha2_byte*, size_t); 00073 void SHA256_Final(sha2_byte[SHA256_DIGEST_LENGTH], SHA256_CTX*); 00074 char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); 00075 char* SHA256_Data(const sha2_byte*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); 00076 00077 void SHA384_Init(SHA384_CTX*); 00078 void SHA384_Update(SHA384_CTX*, const sha2_byte*, size_t); 00079 void SHA384_Final(sha2_byte[SHA384_DIGEST_LENGTH], SHA384_CTX*); 00080 char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]); 00081 char* SHA384_Data(const sha2_byte*, size_t, char[SHA384_DIGEST_STRING_LENGTH]); 00082 00083 void SHA512_Init(SHA512_CTX*); 00084 void SHA512_Update(SHA512_CTX*, const sha2_byte*, size_t); 00085 void SHA512_Final(sha2_byte[SHA512_DIGEST_LENGTH], SHA512_CTX*); 00086 char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); 00087 char* SHA512_Data(const sha2_byte*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); 00088 00089 #endif /* __SHA2_H__ */ Generated on Sun May 27 2012 04:26:09 for ReactOS by
1.7.6.1
|