4 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7 // Implementation of SHA1 hash function.
8 // Original author: Steve Reid <sreid@sea-to-sky.net>
9 // Contributions by: James H. Brown <jbrown@burgoyne.com>, Saul Kravitz <Saul.Kravitz@celera.com>,
10 // and Ralph Giles <giles@ghostscript.com>
11 // Modified by WaterJuice retaining Public Domain license.
13 // This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
14 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
18 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
20 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
25 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
27 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
29 // Sha1Context - This must be initialised using Sha1Initialised. Do not modify the contents of this structure directly.
37 #define SHA1_HASH_SIZE ( 160 / 8 )
41 uint8_t bytes [SHA1_HASH_SIZE];
44 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
46 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
48 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
51 // Initialises an SHA1 Context. Use this to initialise/reset a context.
52 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
56 Sha1Context* Context // [out]
59 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
62 // Adds data to the SHA1 context. This will process the data and update the internal state of the context. Keep on
63 // calling this function until all the data has been added. Then call Sha1Finalise to calculate the hash.
64 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
68 Sha1Context* Context, // [in out]
69 void const* Buffer, // [in]
70 uint32_t BufferSize // [in]
73 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
76 // Performs the final calculation of the hash and returns the digest (20 byte buffer containing 160bit hash). After
77 // calling this, Sha1Initialised must be used to reuse the context.
78 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
82 Sha1Context* Context, // [in out]
83 SHA1_HASH* Digest // [in]
86 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
89 // Combines Sha1Initialise, Sha1Update, and Sha1Finalise into one function. Calculates the SHA1 hash of the buffer.
90 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
94 void const* Buffer, // [in]
95 uint32_t BufferSize, // [in]
96 SHA1_HASH* Digest // [in]
99 #endif /* __SHA1_H__ */