1/* contrib/pgcrypto/sha1.h */
2/* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30/*
31 * FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
32 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm
35 * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
36 */
37
38#ifndef _NETINET6_SHA1_H_
39#define _NETINET6_SHA1_H_
40
41#ifdef __cplusplus
42extern "C" {
43#endif
44
45#include <stdlib.h>
46#include "../../src/stdint.hpp"
47
48struct sha1_ctxt
49{
50 union
51 {
52 uint8_t b8[20];
53 uint32_t b32[5];
54 } h;
55 union
56 {
57 uint8_t b8[8];
58 uint64_t b64[1];
59 } c;
60 union
61 {
62 uint8_t b8[64];
63 uint32_t b32[16];
64 } m;
65 uint8_t count;
66};
67
68void sha1_init(struct sha1_ctxt *);
69void sha1_pad(struct sha1_ctxt *);
70void sha1_loop(struct sha1_ctxt *, const uint8_t *, size_t);
71void sha1_result(struct sha1_ctxt *, uint8_t *);
72
73// Compatibility with OpenSSL API
74#define SHA_DIGEST_LENGTH 20
75typedef struct sha1_ctxt SHA_CTX;
76
77#define SHA1_Init(x) sha1_init((x))
78#define SHA1_Update(x, y, z) sha1_loop((x), (y), (z))
79#define SHA1_Final(x, y) sha1_result((y), (x))
80
81#define SHA1_RESULTLEN (160/8)
82
83#ifdef __cplusplus
84}
85#endif
86
87#endif /* _NETINET6_SHA1_H_ */
88