MCPcopy Create free account
hub / github.com/HumbleNet/HumbleNet / SHA1Input

Function SHA1Input

3rdparty/sha1/sha1.c:159–209  ·  view source on GitHub ↗

* SHA1Input * * Description: * This function accepts an array of octets as the next portion * of the message. * * Parameters: * context: [in/out] * The SHA context to update * message_array: [in] * An array of characters representing the next portion of * the message. * length: [in] * The length of the message in message_

Source from the content-addressed store, hash-verified

157 *
158 */
159int SHA1Input( SHA1Context *context,
160 const uint8_t *message_array,
161 unsigned length)
162{
163 if (!length)
164 {
165 return shaSuccess;
166 }
167
168 if (!context || !message_array)
169 {
170 return shaNull;
171 }
172
173 if (context->Computed)
174 {
175 context->Corrupted = shaStateError;
176
177 return shaStateError;
178 }
179
180 if (context->Corrupted)
181 {
182 return context->Corrupted;
183 }
184 while(length-- && !context->Corrupted)
185 {
186 context->Message_Block[context->Message_Block_Index++] =
187 (*message_array & 0xFF);
188
189 context->Length_Low += 8;
190 if (context->Length_Low == 0)
191 {
192 context->Length_High++;
193 if (context->Length_High == 0)
194 {
195 /* Message is too long */
196 context->Corrupted = 1;
197 }
198 }
199
200 if (context->Message_Block_Index == 64)
201 {
202 SHA1ProcessMessageBlock(context);
203 }
204
205 message_array++;
206 }
207
208 return shaSuccess;
209}
210
211/*
212 * SHA1ProcessMessageBlock

Callers 3

HMACInitFunction · 0.85
HMACInputFunction · 0.85
HMACResultFunction · 0.85

Calls 1

SHA1ProcessMessageBlockFunction · 0.85

Tested by

no test coverage detected