xref: /freebsd/sys/crypto/sha1.h (revision 6a800098cc0778c9618a89f858021624722374bd)
16a800098SYoshinobu Inoue /*
26a800098SYoshinobu Inoue  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
36a800098SYoshinobu Inoue  * All rights reserved.
46a800098SYoshinobu Inoue  *
56a800098SYoshinobu Inoue  * Redistribution and use in source and binary forms, with or without
66a800098SYoshinobu Inoue  * modification, are permitted provided that the following conditions
76a800098SYoshinobu Inoue  * are met:
86a800098SYoshinobu Inoue  * 1. Redistributions of source code must retain the above copyright
96a800098SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer.
106a800098SYoshinobu Inoue  * 2. Redistributions in binary form must reproduce the above copyright
116a800098SYoshinobu Inoue  *    notice, this list of conditions and the following disclaimer in the
126a800098SYoshinobu Inoue  *    documentation and/or other materials provided with the distribution.
136a800098SYoshinobu Inoue  * 3. Neither the name of the project nor the names of its contributors
146a800098SYoshinobu Inoue  *    may be used to endorse or promote products derived from this software
156a800098SYoshinobu Inoue  *    without specific prior written permission.
166a800098SYoshinobu Inoue  *
176a800098SYoshinobu Inoue  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
186a800098SYoshinobu Inoue  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
196a800098SYoshinobu Inoue  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
206a800098SYoshinobu Inoue  * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
216a800098SYoshinobu Inoue  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
226a800098SYoshinobu Inoue  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
236a800098SYoshinobu Inoue  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
246a800098SYoshinobu Inoue  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
256a800098SYoshinobu Inoue  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
266a800098SYoshinobu Inoue  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
276a800098SYoshinobu Inoue  * SUCH DAMAGE.
286a800098SYoshinobu Inoue  *
296a800098SYoshinobu Inoue  * $FreeBSD$
306a800098SYoshinobu Inoue  */
316a800098SYoshinobu Inoue /*
326a800098SYoshinobu Inoue  * FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
336a800098SYoshinobu Inoue  * based on: http://csrc.nist.gov/fips/fip180-1.txt
346a800098SYoshinobu Inoue  * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
356a800098SYoshinobu Inoue  */
366a800098SYoshinobu Inoue 
376a800098SYoshinobu Inoue #ifndef _NETINET6_SHA1_H_
386a800098SYoshinobu Inoue #define	_NETINET6_SHA1_H_
396a800098SYoshinobu Inoue 
406a800098SYoshinobu Inoue struct sha1_ctxt {
416a800098SYoshinobu Inoue 	union {
426a800098SYoshinobu Inoue 		u_int8_t	b8[20];
436a800098SYoshinobu Inoue 		u_int32_t	b32[5];
446a800098SYoshinobu Inoue 	} h;
456a800098SYoshinobu Inoue 	union {
466a800098SYoshinobu Inoue 		u_int8_t	b8[8];
476a800098SYoshinobu Inoue 		u_int64_t	b64[1];
486a800098SYoshinobu Inoue 	} c;
496a800098SYoshinobu Inoue 	union {
506a800098SYoshinobu Inoue 		u_int8_t	b8[64];
516a800098SYoshinobu Inoue 		u_int32_t	b32[16];
526a800098SYoshinobu Inoue 	} m;
536a800098SYoshinobu Inoue 	u_int8_t	count;
546a800098SYoshinobu Inoue };
556a800098SYoshinobu Inoue 
566a800098SYoshinobu Inoue #if defined(KERNEL) || defined(_KERNEL)
576a800098SYoshinobu Inoue extern void sha1_init __P((struct sha1_ctxt *));
586a800098SYoshinobu Inoue extern void sha1_pad __P((struct sha1_ctxt *));
596a800098SYoshinobu Inoue extern void sha1_loop __P((struct sha1_ctxt *, caddr_t, size_t));
606a800098SYoshinobu Inoue extern void sha1_result __P((struct sha1_ctxt *, caddr_t));
616a800098SYoshinobu Inoue 
626a800098SYoshinobu Inoue /* compatibilty with other SHA1 source codes */
636a800098SYoshinobu Inoue typedef struct sha1_ctxt SHA1_CTX;
646a800098SYoshinobu Inoue #define	SHA1Init(x)		sha1_init((x))
656a800098SYoshinobu Inoue #define	SHA1Update(x, y, z)	sha1_loop((x), (y), (z))
666a800098SYoshinobu Inoue #define	SHA1Final(x, y)		sha1_result((y), (x))
676a800098SYoshinobu Inoue #endif
686a800098SYoshinobu Inoue 
696a800098SYoshinobu Inoue #define	SHA1_RESULTLEN	(160/8)
706a800098SYoshinobu Inoue 
716a800098SYoshinobu Inoue #endif /*_NETINET6_SHA1_H_*/
72