mozglue/android/pbkdf2_sha256.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mozglue/android/pbkdf2_sha256.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,70 @@
     1.4 +/*-
     1.5 + * Copyright 2005,2007,2009 Colin Percival
     1.6 + * All rights reserved.
     1.7 + *
     1.8 + * Redistribution and use in source and binary forms, with or without
     1.9 + * modification, are permitted provided that the following conditions
    1.10 + * are met:
    1.11 + * 1. Redistributions of source code must retain the above copyright
    1.12 + *    notice, this list of conditions and the following disclaimer.
    1.13 + * 2. Redistributions in binary form must reproduce the above copyright
    1.14 + *    notice, this list of conditions and the following disclaimer in the
    1.15 + *    documentation and/or other materials provided with the distribution.
    1.16 + *
    1.17 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
    1.18 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.20 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    1.21 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.22 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.23 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.24 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.25 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.26 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.27 + * SUCH DAMAGE.
    1.28 + *
    1.29 + * $FreeBSD: src/lib/libmd/sha256.h,v 1.2 2006/01/17 15:35:56 phk Exp $
    1.30 + */
    1.31 +
    1.32 +#ifndef _SHA256_H_
    1.33 +#define _SHA256_H_
    1.34 +
    1.35 +#ifdef __cplusplus
    1.36 +extern "C" {
    1.37 +#endif
    1.38 +
    1.39 +#include <sys/types.h>
    1.40 +
    1.41 +#include <stdint.h>
    1.42 +
    1.43 +typedef struct SHA256Context {
    1.44 +	uint32_t state[8];
    1.45 +	uint32_t count[2];
    1.46 +	unsigned char buf[64];
    1.47 +} SHA256_CTX;
    1.48 +
    1.49 +typedef struct HMAC_SHA256Context {
    1.50 +	SHA256_CTX ictx;
    1.51 +	SHA256_CTX octx;
    1.52 +} HMAC_SHA256_CTX;
    1.53 +
    1.54 +void	SHA256_Init(SHA256_CTX *);
    1.55 +void	SHA256_Update(SHA256_CTX *, const void *, size_t);
    1.56 +void	SHA256_Final(unsigned char [32], SHA256_CTX *);
    1.57 +void	HMAC_SHA256_Init(HMAC_SHA256_CTX *, const void *, size_t);
    1.58 +void	HMAC_SHA256_Update(HMAC_SHA256_CTX *, const void *, size_t);
    1.59 +void	HMAC_SHA256_Final(unsigned char [32], HMAC_SHA256_CTX *);
    1.60 +
    1.61 +/**
    1.62 + * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
    1.63 + * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
    1.64 + * write the output to buf.  The value dkLen must be at most 32 * (2^32 - 1).
    1.65 + */
    1.66 +void	PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t,
    1.67 +    uint64_t, uint8_t *, size_t);
    1.68 +
    1.69 +#ifdef __cplusplus
    1.70 +}
    1.71 +#endif
    1.72 +
    1.73 +#endif /* !_SHA256_H_ */

mercurial