diff options
author | Stefan Metzmacher <metze@samba.org> | 2006-08-11 08:02:43 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:15:28 -0500 |
commit | 0d235919fbb1430d52913df11da1f011a65ff319 (patch) | |
tree | 52f61b84020ad9ce5e0dc59d9f720c4e07b66fde /source4/lib/crypto/sha1.h | |
parent | b26f4472a71b2a60c8120bd1307dbbd1e499fcbe (diff) | |
download | samba-0d235919fbb1430d52913df11da1f011a65ff319.tar.gz samba-0d235919fbb1430d52913df11da1f011a65ff319.tar.bz2 samba-0d235919fbb1430d52913df11da1f011a65ff319.zip |
r17488: - add SHA1 and HMACSHA1 functions, based on rfc 2104,2202,3174
- and add torture tests also based on the rfc's
metze
(This used to be commit d48930a02f9560640697fd57e4bba03dc0abe284)
Diffstat (limited to 'source4/lib/crypto/sha1.h')
-rw-r--r-- | source4/lib/crypto/sha1.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/source4/lib/crypto/sha1.h b/source4/lib/crypto/sha1.h new file mode 100644 index 0000000000..4a2d448bfc --- /dev/null +++ b/source4/lib/crypto/sha1.h @@ -0,0 +1,62 @@ +/* + This file contains the reference implementation of SHA-1 + from http://www.ietf.org/rfc/rfc3174.txt +*/ +/* + * sha1.h + * + * Description: + * This is the header file for code which implements the Secure + * Hashing Algorithm 1 as defined in FIPS PUB 180-1 published + * April 17, 1995. + * + * Many of the variable names in this code, especially the + * single character names, were used because those were the names + * used in the publication. + * + * Please read the file sha1.c for more information. + * + */ +#ifndef _SHA1_H_ +#define _SHA1_H_ + +#ifndef _SHA_enum_ +#define _SHA_enum_ +enum +{ + shaSuccess = 0, + shaNull, /* Null pointer parameter */ + shaInputTooLong, /* input data too long */ + shaStateError /* called Input after Result */ +}; +#endif +#define SHA1HashSize 20 + +/* + * This structure will hold context information for the SHA-1 + * hashing operation + */ +struct SHA1Context +{ + uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */ + + uint32_t Length_Low; /* Message length in bits */ + uint32_t Length_High; /* Message length in bits */ + + /* Index into message block array */ + int16_t Message_Block_Index; + uint8_t Message_Block[64]; /* 512-bit message blocks */ + + int Computed; /* Is the digest computed? */ + int Corrupted; /* Is the message digest corrupted? */ +}; + +/* + * Function Prototypes + */ + +int SHA1Init(struct SHA1Context *); +int SHA1Update(struct SHA1Context *, const uint8_t *data, size_t data_len); +int SHA1Final(uint8_t Message_Digest[SHA1HashSize], struct SHA1Context *); + +#endif |