michael@0: /*- michael@0: * Copyright 2005,2007,2009 Colin Percival michael@0: * All rights reserved. michael@0: * michael@0: * Redistribution and use in source and binary forms, with or without michael@0: * modification, are permitted provided that the following conditions michael@0: * are met: michael@0: * 1. Redistributions of source code must retain the above copyright michael@0: * notice, this list of conditions and the following disclaimer. michael@0: * 2. Redistributions in binary form must reproduce the above copyright michael@0: * notice, this list of conditions and the following disclaimer in the michael@0: * documentation and/or other materials provided with the distribution. michael@0: * michael@0: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND michael@0: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE michael@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE michael@0: * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE michael@0: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL michael@0: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS michael@0: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) michael@0: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT michael@0: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY michael@0: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF michael@0: * SUCH DAMAGE. michael@0: * michael@0: * $FreeBSD: src/lib/libmd/sha256.h,v 1.2 2006/01/17 15:35:56 phk Exp $ michael@0: */ michael@0: michael@0: #ifndef _SHA256_H_ michael@0: #define _SHA256_H_ michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: #include michael@0: michael@0: #include michael@0: michael@0: typedef struct SHA256Context { michael@0: uint32_t state[8]; michael@0: uint32_t count[2]; michael@0: unsigned char buf[64]; michael@0: } SHA256_CTX; michael@0: michael@0: typedef struct HMAC_SHA256Context { michael@0: SHA256_CTX ictx; michael@0: SHA256_CTX octx; michael@0: } HMAC_SHA256_CTX; michael@0: michael@0: void SHA256_Init(SHA256_CTX *); michael@0: void SHA256_Update(SHA256_CTX *, const void *, size_t); michael@0: void SHA256_Final(unsigned char [32], SHA256_CTX *); michael@0: void HMAC_SHA256_Init(HMAC_SHA256_CTX *, const void *, size_t); michael@0: void HMAC_SHA256_Update(HMAC_SHA256_CTX *, const void *, size_t); michael@0: void HMAC_SHA256_Final(unsigned char [32], HMAC_SHA256_CTX *); michael@0: michael@0: /** michael@0: * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): michael@0: * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and michael@0: * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). michael@0: */ michael@0: void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t, michael@0: uint64_t, uint8_t *, size_t); michael@0: michael@0: #ifdef __cplusplus michael@0: } michael@0: #endif michael@0: michael@0: #endif /* !_SHA256_H_ */