74 #define SHA1_ROTL(bits,word) \ 75 (((word) << (bits)) | ((word) >> (32-(bits)))) 82 #define SHA1AddLength(context, length) \ 83 (addTemp = (context)->Length_Low, \ 84 (context)->Corrupted = \ 85 (((context)->Length_Low += (length)) < addTemp) && \ 86 (++(context)->Length_High == 0) ? shaInputTooLong \ 87 : (context)->Corrupted ) 134 const uint8_t *message_array,
unsigned length)
142 if (!message_array) {
182 static uint8_t masks[8] = {
189 static uint8_t markbit[8] = {
209 (uint8_t) ((message_bits & masks[length]) |
233 if (!Message_Digest) {
246 >> (8 * (3 - (i & 0x03))));
263 const uint32_t K[4] = {
264 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
269 uint32_t A, B, C, D, E;
274 for (t = 0; t < 16; t++) {
276 W[t] |= ((uint32_t) context->
Message_Block[t * 4 + 1]) << 16;
281 for (t = 16; t < 80; t++) {
282 W[t] =
SHA1_ROTL(1, W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16]);
291 for (t = 0; t < 20; t++) {
300 for (t = 20; t < 40; t++) {
309 for (t = 40; t < 60; t++) {
318 for (t = 60; t < 80; t++) {
static void SHA1ProcessMessageBlock(SHA1Context *context)
Process the next 512 bits of the message stored in the Message_Block array.
int SHA1FinalBits(SHA1Context *context, uint8_t message_bits, unsigned int length)
SHA1FinalBits Add in any final bits of the message.
uint32_t Intermediate_Hash[SHA1HashSize/4]
int SHA1Result(SHA1Context *context, uint8_t Message_Digest[SHA1HashSize])
int SHA1Reset(SHA1Context *context)
SHA1Reset.
int_least16_t Message_Block_Index
static void SHA1PadMessage(SHA1Context *context, uint8_t Pad_Byte)
Pad message to be 512 bits.
#define SHA1AddLength(context, length)
int SHA1Input(SHA1Context *context, const uint8_t *message_array, unsigned length)
SHA1Input.
#define SHA1_ROTL(bits, word)
uint8_t Message_Block[SHA1_Message_Block_Size]
static char context[AST_MAX_CONTEXT]
#define SHA_Parity(x, y, z)
static void SHA1Finalize(SHA1Context *context, uint8_t Pad_Byte)
This helper function finishes off the digest calculations.