1 /*
2  *  sha1.h
3  *
4  *  Copyright (C) 1998, 2009
5  *  Paul E. Jones <paulej@packetizer.com>
6  *  All Rights Reserved
7  *
8  *****************************************************************************
9  *  $Id: sha1.h 12 2009-06-22 19:34:25Z paulej $
10  *****************************************************************************
11  *
12  *  Description:
13  *      This class implements the Secure Hashing Standard as defined
14  *      in FIPS PUB 180-1 published April 17, 1995.
15  *
16  *      Many of the variable names in the SHA1Context, especially the
17  *      single character names, were used because those were the names
18  *      used in the publication.
19  *
20  *      Please read the file sha1.c for more information.
21  *
22  *
23  * Freeware Public License (FPL)
24  *
25  * This software is licensed as "freeware."  Permission to distribute
26  * this software in source and binary forms, including incorporation
27  * into other products, is hereby granted without a fee.  THIS SOFTWARE
28  * IS PROVIDED 'AS IS' AND WITHOUT ANY EXPRESSED OR IMPLIED WARRANTIES,
29  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
30  * AND FITNESS FOR A PARTICULAR PURPOSE.  THE AUTHOR SHALL NOT BE HELD
31  * LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE, EITHER
32  * DIRECTLY OR INDIRECTLY, INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA
33  * OR DATA BEING RENDERED INACCURATE.
34  */
35 
36 #pragma once
37 
38 #include "../shared/ufotypes.h"
39 
40 /**
41  * This structure will hold context information for the hashing operation
42  */
43 typedef struct SHA1Context {
44 	unsigned Message_Digest[5]; /* Message Digest (output) */
45 
46 	unsigned Length_Low; /* Message length in bits */
47 	unsigned Length_High; /* Message length in bits */
48 
49 	unsigned char Message_Block[64]; /* 512-bit message blocks */
50 	int Message_Block_Index; /* Index into message block array */
51 
52 	int Computed; /* Is the digest computed? */
53 	int Corrupted; /* Is the message digest corrupted? */
54 } SHA1Context;
55 
56 /*
57  *  Function Prototypes
58  */
59 void Com_SHA1Reset (SHA1Context *);
60 bool Com_SHA1Result (SHA1Context *);
61 void Com_SHA1Input (SHA1Context *, const unsigned char *, unsigned);
62 
63 bool Com_SHA1File (const char *filename, char digest[41]);
64 bool Com_SHA1Buffer (const unsigned char *buf, unsigned int len, char digest[41]);
65