source: lib/sha1.h @ ebaebfe

Last change on this file since ebaebfe was 77bfd07, checked in by Wilmer van der Gaast <wilmer@…>, at 2007-11-23T23:07:44Z

Replaced GPL-incompatible SHA1 hashing code (and renamed the files in case
I ever need SHA256 ;-)).

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[77bfd07]1/*
2 * SHA1 hashing code copied from Lepton's crack <http://usuarios.lycos.es/reinob/>
3 *
4 * Adapted to be API-compatible with the previous (GPL-incompatible) code.
5 */
6
7/*
8 *  sha1.h
9 *
10 *  Description:
11 *      This is the header file for code which implements the Secure
12 *      Hashing Algorithm 1 as defined in FIPS PUB 180-1 published
13 *      April 17, 1995.
14 *
15 *      Many of the variable names in this code, especially the
16 *      single character names, were used because those were the names
17 *      used in the publication.
18 *
19 *      Please read the file sha1.c for more information.
20 *
21 */
22
23#ifndef _SHA1_H_
24#define _SHA1_H_
25
26#include <stdint.h>
27#include <gmodule.h>
28
29#ifndef _SHA_enum_
30#define _SHA_enum_
31enum {
32        shaSuccess = 0,
33        shaNull,                /* Null pointer parameter */
34        shaInputTooLong,        /* input data too long */
35        shaStateError           /* called Input after Result */
36};
37#endif
38#define sha1_hash_size 20
39
40/*
41 *  This structure will hold context information for the SHA-1
42 *  hashing operation
43 */
44typedef struct SHA1Context {
45        uint32_t Intermediate_Hash[sha1_hash_size/4];   /* Message Digest   */
46
47        uint32_t Length_Low;            /* Message length in bits           */
48        uint32_t Length_High;           /* Message length in bits           */
49
50        /* Index into message block array   */
51        int_least16_t Message_Block_Index;
52        uint8_t Message_Block[64];      /* 512-bit message blocks           */
53
54        int Computed;                   /* Is the digest computed?          */
55        int Corrupted;                  /* Is the message digest corrupted? */
56} sha1_state_t;
57
58/*
59 *  Function Prototypes
60 */
61
62G_MODULE_EXPORT int sha1_init(sha1_state_t *);
63G_MODULE_EXPORT int sha1_append(sha1_state_t *, const uint8_t *, unsigned int);
64G_MODULE_EXPORT int sha1_finish(sha1_state_t *, uint8_t Message_Digest[sha1_hash_size]);
65
66#endif
Note: See TracBrowser for help on using the repository browser.