mozglue/android/pbkdf2_sha256.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*-
michael@0 2 * Copyright 2005,2007,2009 Colin Percival
michael@0 3 * All rights reserved.
michael@0 4 *
michael@0 5 * Redistribution and use in source and binary forms, with or without
michael@0 6 * modification, are permitted provided that the following conditions
michael@0 7 * are met:
michael@0 8 * 1. Redistributions of source code must retain the above copyright
michael@0 9 * notice, this list of conditions and the following disclaimer.
michael@0 10 * 2. Redistributions in binary form must reproduce the above copyright
michael@0 11 * notice, this list of conditions and the following disclaimer in the
michael@0 12 * documentation and/or other materials provided with the distribution.
michael@0 13 *
michael@0 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
michael@0 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
michael@0 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
michael@0 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
michael@0 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
michael@0 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
michael@0 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
michael@0 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
michael@0 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
michael@0 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@0 24 * SUCH DAMAGE.
michael@0 25 *
michael@0 26 * $FreeBSD: src/lib/libmd/sha256.h,v 1.2 2006/01/17 15:35:56 phk Exp $
michael@0 27 */
michael@0 28
michael@0 29 #ifndef _SHA256_H_
michael@0 30 #define _SHA256_H_
michael@0 31
michael@0 32 #ifdef __cplusplus
michael@0 33 extern "C" {
michael@0 34 #endif
michael@0 35
michael@0 36 #include <sys/types.h>
michael@0 37
michael@0 38 #include <stdint.h>
michael@0 39
michael@0 40 typedef struct SHA256Context {
michael@0 41 uint32_t state[8];
michael@0 42 uint32_t count[2];
michael@0 43 unsigned char buf[64];
michael@0 44 } SHA256_CTX;
michael@0 45
michael@0 46 typedef struct HMAC_SHA256Context {
michael@0 47 SHA256_CTX ictx;
michael@0 48 SHA256_CTX octx;
michael@0 49 } HMAC_SHA256_CTX;
michael@0 50
michael@0 51 void SHA256_Init(SHA256_CTX *);
michael@0 52 void SHA256_Update(SHA256_CTX *, const void *, size_t);
michael@0 53 void SHA256_Final(unsigned char [32], SHA256_CTX *);
michael@0 54 void HMAC_SHA256_Init(HMAC_SHA256_CTX *, const void *, size_t);
michael@0 55 void HMAC_SHA256_Update(HMAC_SHA256_CTX *, const void *, size_t);
michael@0 56 void HMAC_SHA256_Final(unsigned char [32], HMAC_SHA256_CTX *);
michael@0 57
michael@0 58 /**
michael@0 59 * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen):
michael@0 60 * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and
michael@0 61 * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1).
michael@0 62 */
michael@0 63 void PBKDF2_SHA256(const uint8_t *, size_t, const uint8_t *, size_t,
michael@0 64 uint64_t, uint8_t *, size_t);
michael@0 65
michael@0 66 #ifdef __cplusplus
michael@0 67 }
michael@0 68 #endif
michael@0 69
michael@0 70 #endif /* !_SHA256_H_ */

mercurial