162587Sitojun/* $FreeBSD: stable/11/sys/crypto/sha1.h 309023 2016-11-22 20:28:17Z asomers $ */ 262587Sitojun/* $KAME: sha1.h,v 1.5 2000/03/27 04:36:23 sumikawa Exp $ */ 362587Sitojun 4331722Seadler/* 555009Sshin * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 655009Sshin * All rights reserved. 755009Sshin * 855009Sshin * Redistribution and use in source and binary forms, with or without 955009Sshin * modification, are permitted provided that the following conditions 1055009Sshin * are met: 1155009Sshin * 1. Redistributions of source code must retain the above copyright 1255009Sshin * notice, this list of conditions and the following disclaimer. 1355009Sshin * 2. Redistributions in binary form must reproduce the above copyright 1455009Sshin * notice, this list of conditions and the following disclaimer in the 1555009Sshin * documentation and/or other materials provided with the distribution. 1655009Sshin * 3. Neither the name of the project nor the names of its contributors 1755009Sshin * may be used to endorse or promote products derived from this software 1855009Sshin * without specific prior written permission. 1955009Sshin * 2055009Sshin * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 2155009Sshin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2255009Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2355009Sshin * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 2455009Sshin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2555009Sshin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2655009Sshin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2755009Sshin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2855009Sshin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2955009Sshin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3055009Sshin * SUCH DAMAGE. 3155009Sshin */ 3255009Sshin/* 3355009Sshin * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) 3455009Sshin * based on: http://csrc.nist.gov/fips/fip180-1.txt 3555009Sshin * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> 3655009Sshin */ 3755009Sshin 38300773Scem#ifndef _CRYPTO_SHA1_H_ 39300773Scem#define _CRYPTO_SHA1_H_ 4055009Sshin 4155009Sshinstruct sha1_ctxt { 4255009Sshin union { 4355009Sshin u_int8_t b8[20]; 4455009Sshin u_int32_t b32[5]; 4555009Sshin } h; 4655009Sshin union { 4755009Sshin u_int8_t b8[8]; 4855009Sshin u_int64_t b64[1]; 4955009Sshin } c; 5055009Sshin union { 5155009Sshin u_int8_t b8[64]; 5255009Sshin u_int32_t b32[16]; 5355009Sshin } m; 5455009Sshin u_int8_t count; 5555009Sshin}; 56292963Sallanjudetypedef struct sha1_ctxt SHA1_CTX; 5755009Sshin 58300773Scem#define SHA1_RESULTLEN (160/8) 59300773Scem 6055206Speter#ifdef _KERNEL 6192756Salfredextern void sha1_init(struct sha1_ctxt *); 6292756Salfredextern void sha1_pad(struct sha1_ctxt *); 6392756Salfredextern void sha1_loop(struct sha1_ctxt *, const u_int8_t *, size_t); 64309023Sasomersextern void sha1_result(struct sha1_ctxt *, char[__min_size(SHA1_RESULTLEN)]); 6555009Sshin 6655009Sshin/* compatibilty with other SHA1 source codes */ 6762587Sitojun#define SHA1Init(x) sha1_init((x)) 6862587Sitojun#define SHA1Update(x, y, z) sha1_loop((x), (y), (z)) 6962587Sitojun#define SHA1Final(x, y) sha1_result((y), (x)) 7066890Sarchie#endif /* _KERNEL */ 7155009Sshin 72300773Scem#endif /*_CRYPTO_SHA1_H_*/ 73