1/*- 2 * Copyright (c) 2001, 2002 Allan Saddi <allan@saddi.com> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 * $Id: sha256.h,v 1.3 2009/10/27 20:15:39 andreas_kupries Exp $ 27 */ 28 29#ifndef _SHA256_H 30#define _SHA256_H 31 32#if HAVE_INTTYPES_H 33# include <inttypes.h> 34#else 35# if HAVE_STDINT_H 36# include <stdint.h> 37# endif 38#endif 39 40#define SHA256_HASH_SIZE 32 41 42/* Hash size in 32-bit words */ 43#define SHA256_HASH_WORDS 8 44 45#ifdef _MSC_VER 46typedef unsigned __int64 uint64_t; 47#elif !(defined(__hpux) && defined(__ia64)) 48typedef unsigned long long uint64_t; 49#endif 50 51#if !(defined(__hpux) && defined(__ia64)) 52typedef unsigned int uint32_t; 53typedef unsigned char uint8_t; 54#endif 55 56struct _SHA256Context { 57 uint64_t totalLength; 58 uint32_t hash[SHA256_HASH_WORDS]; 59 uint32_t bufferLength; 60 union { 61 uint32_t words[16]; 62 uint8_t bytes[64]; 63 } buffer; 64}; 65 66typedef struct _SHA256Context SHA256Context; 67typedef struct _SHA256Context SHA256_CTX; 68 69#ifdef __cplusplus 70extern "C" { 71#endif 72 73void SHA256Init (SHA256Context *sc); 74void SHA256Update (SHA256Context *sc, const void *data, uint32_t len); 75void SHA256Final (SHA256Context *sc, uint8_t hash[SHA256_HASH_SIZE]); 76 77void SHA224Init (SHA256Context *sc); 78 79#ifdef __cplusplus 80} 81#endif 82 83#endif /* !_SHA256_H */ 84