"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libcanlock/src/sha1.c" between
tin-2.4.2.tar.xz and tin-2.4.3.tar.xz

About: TIN is a threaded NNTP and spool based UseNet newsreader.

sha1.c  (tin-2.4.2.tar.xz):sha1.c  (tin-2.4.3.tar.xz)
skipping to change at line 39 skipping to change at line 39
* appropriate. * appropriate.
* *
* Caveats: * Caveats:
* SHA-1 is designed to work with messages less than 2^64 bits * SHA-1 is designed to work with messages less than 2^64 bits
* long. This implementation uses SHA1Input() to hash the bits * long. This implementation uses SHA1Input() to hash the bits
* that are a multiple of the size of an 8-bit octet, and then * that are a multiple of the size of an 8-bit octet, and then
* optionally uses SHA1FinalBits() to hash the final few bits of * optionally uses SHA1FinalBits() to hash the final few bits of
* the input. * the input.
*/ */
#include "canlock-private.h"
#include "sha.h" #include "sha.h"
#include "sha-private.h" #include "sha-private.h"
/* /*
* Define the SHA1 circular left shift macro * Define the SHA1 circular left shift macro
*/ */
#define SHA1_ROTL(bits,word) \ #define SHA1_ROTL(bits,word) \
(((word) << (bits)) | ((word) >> (32-(bits)))) (((word) << (bits)) | ((word) >> (32-(bits))))
/* /*
skipping to change at line 258 skipping to change at line 259
* names used in the Secure Hash Standard. * names used in the Secure Hash Standard.
*/ */
static void SHA1ProcessMessageBlock(SHA1Context *context) static void SHA1ProcessMessageBlock(SHA1Context *context)
{ {
/* Constants defined in FIPS 180-3, section 4.2.1 */ /* Constants defined in FIPS 180-3, section 4.2.1 */
const uint32_t K[4] = { const uint32_t K[4] = {
0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xCA62C1D6
}; };
int t; /* Loop counter */ int t; /* Loop counter */
uint32_t temp; /* Temporary word value */ uint32_t temp; /* Temporary word value */
uint32_t W[80]; /* Word sequence */ uint32_t W[80]; /* Word sequence. Security review: Location L4 */
uint32_t A, B, C, D, E; /* Word buffers */ uint32_t A, B, C, D, E; /* Word buffers */
/* /*
* Initialize the first 16 words in the array W * Initialize the first 16 words in the array W
*/ */
for (t = 0; t < 16; t++) { for (t = 0; t < 16; t++) {
W[t] = ((uint32_t)context->Message_Block[t * 4]) << 24; W[t] = ((uint32_t)context->Message_Block[t * 4]) << 24;
W[t] |= ((uint32_t)context->Message_Block[t * 4 + 1]) << 16; W[t] |= ((uint32_t)context->Message_Block[t * 4 + 1]) << 16;
W[t] |= ((uint32_t)context->Message_Block[t * 4 + 2]) << 8; W[t] |= ((uint32_t)context->Message_Block[t * 4 + 2]) << 8;
W[t] |= ((uint32_t)context->Message_Block[t * 4 + 3]); W[t] |= ((uint32_t)context->Message_Block[t * 4 + 3]);
skipping to change at line 316 skipping to change at line 317
for (t = 60; t < 80; t++) { for (t = 60; t < 80; t++) {
temp = SHA1_ROTL(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[3]; temp = SHA1_ROTL(5,A) + SHA_Parity(B, C, D) + E + W[t] + K[3];
E = D; E = D;
D = C; D = C;
C = SHA1_ROTL(30,B); C = SHA1_ROTL(30,B);
B = A; B = A;
A = temp; A = temp;
} }
cl_clear_secret((void *) W, sizeof(W), sizeof(W));
context->Intermediate_Hash[0] += A; context->Intermediate_Hash[0] += A;
context->Intermediate_Hash[1] += B; context->Intermediate_Hash[1] += B;
context->Intermediate_Hash[2] += C; context->Intermediate_Hash[2] += C;
context->Intermediate_Hash[3] += D; context->Intermediate_Hash[3] += D;
context->Intermediate_Hash[4] += E; context->Intermediate_Hash[4] += E;
context->Message_Block_Index = 0; context->Message_Block_Index = 0;
} }
/* /*
* SHA1Finalize * SHA1Finalize
 End of changes. 3 change blocks. 
1 lines changed or deleted 4 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)