diff --git a/indra/llcommon/llmd5.cpp b/indra/llcommon/llmd5.cpp index f942a976b7ecba321780038b53000b595be329e7..9ea96cb2cb2075602ff4d7609c61897d8e207d48 100755 --- a/indra/llcommon/llmd5.cpp +++ b/indra/llcommon/llmd5.cpp @@ -101,19 +101,19 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) { uint4 input_index, buffer_index; uint4 buffer_space; // how much space is left in buffer - if (finalized){ // so we can't update! + if (mFinalized){ // so we can't update! std::cerr << "LLMD5::update: Can't update a finalized digest!" << std::endl; return; } // Compute number of bytes mod 64 - buffer_index = (unsigned int)((count[0] >> 3) & 0x3F); + buffer_index = (unsigned int)((mCount[0] >> 3) & 0x3F); // Update number of bits - if ( (count[0] += ((uint4) input_length << 3))<((uint4) input_length << 3) ) - count[1]++; + if ( (mCount[0] += ((uint4) input_length << 3))<((uint4) input_length << 3) ) + mCount[1]++; - count[1] += ((uint4)input_length >> 29); + mCount[1] += ((uint4)input_length >> 29); buffer_space = 64 - buffer_index; // how much space is left in buffer @@ -128,10 +128,10 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) { if (input_length >= buffer_space) { // ie. we have enough to fill the buffer // fill the rest of the buffer and transform memcpy( /* Flawfinder: ignore */ - buffer + buffer_index, + mBuffer + buffer_index, input, buffer_space); - transform (buffer); + transform (mBuffer); for (input_index = buffer_space; input_index + 63 < input_length; input_index += 64) @@ -144,7 +144,7 @@ void LLMD5::update (const uint1 *input, const uint4 input_length) { // and here we do the buffering: - memcpy(buffer+buffer_index, input+input_index, input_length-input_index); /* Flawfinder: ignore */ + memcpy(mBuffer+buffer_index, input+input_index, input_length-input_index); /* Flawfinder: ignore */ } @@ -199,16 +199,16 @@ void LLMD5::finalize (){ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (finalized){ + if (mFinalized){ std::cerr << "LLMD5::finalize: Already finalized this digest!" << std::endl; return; } // Save number of bits - encode (bits, count, 8); + encode (bits, mCount, 8); // Pad out to 56 mod 64. - index = (uint4) ((count[0] >> 3) & 0x3f); + index = (uint4) ((mCount[0] >> 3) & 0x3f); padLen = (index < 56) ? (56 - index) : (120 - index); update (PADDING, padLen); @@ -216,12 +216,12 @@ void LLMD5::finalize (){ update (bits, 8); // Store state in digest - encode (digest, state, 16); + encode (mDigest, mState, 16); // Zeroize sensitive information - memset (buffer, 0, sizeof(*buffer)); + memset (mBuffer, 0, sizeof(*mBuffer)); - finalized=1; + mFinalized=true; } @@ -268,7 +268,7 @@ LLMD5::LLMD5(const unsigned char *s) void LLMD5::raw_digest(unsigned char *s) const { - if (!finalized) + if (!mFinalized) { std::cerr << "LLMD5::raw_digest: Can't get digest if you haven't "<< "finalized the digest!" << std::endl; @@ -276,7 +276,7 @@ void LLMD5::raw_digest(unsigned char *s) const return; } - memcpy(s, digest, 16); /* Flawfinder: ignore */ + memcpy(s, mDigest, 16); /* Flawfinder: ignore */ return; } @@ -286,7 +286,7 @@ void LLMD5::hex_digest(char *s) const { int i; - if (!finalized) + if (!mFinalized) { std::cerr << "LLMD5::hex_digest: Can't get digest if you haven't "<< "finalized the digest!" <<std::endl; @@ -296,7 +296,7 @@ void LLMD5::hex_digest(char *s) const for (i=0; i<16; i++) { - sprintf(s+i*2, "%02x", digest[i]); /* Flawfinder: ignore */ + sprintf(s+i*2, "%02x", mDigest[i]); /* Flawfinder: ignore */ } s[32]='\0'; @@ -337,17 +337,17 @@ bool operator!=(const LLMD5& a, const LLMD5& b) // PRIVATE METHODS: void LLMD5::init(){ - finalized=0; // we just started! + mFinalized=false; // we just started! // Nothing counted, so count=0 - count[0] = 0; - count[1] = 0; + mCount[0] = 0; + mCount[1] = 0; // Load magic initialization constants. - state[0] = 0x67452301; - state[1] = 0xefcdab89; - state[2] = 0x98badcfe; - state[3] = 0x10325476; + mState[0] = 0x67452301; + mState[1] = 0xefcdab89; + mState[2] = 0x98badcfe; + mState[3] = 0x10325476; } @@ -414,13 +414,14 @@ Rotation is separate from addition to prevent recomputation. // LLMD5 basic transformation. Transforms state based on block. -void LLMD5::transform (const U8 block[64]){ +void LLMD5::transform (const uint1 *buffer) +{ - uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + uint4 a = mState[0], b = mState[1], c = mState[2], d = mState[3], x[16]; - decode (x, block, 64); + decode (x, buffer, 64); - assert(!finalized); // not just a user error, since the method is private + assert(!mFinalized); // not just a user error, since the method is private /* Round 1 */ FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ @@ -494,10 +495,10 @@ void LLMD5::transform (const U8 block[64]){ II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; + mState[0] += a; + mState[1] += b; + mState[2] += c; + mState[3] += d; // Zeroize sensitive information. memset ( (uint1 *) x, 0, sizeof(x)); diff --git a/indra/llcommon/llmd5.h b/indra/llcommon/llmd5.h index 1526e6ac3c0d5ea50b3c0d0862ac491e5f3c6972..b13571751cdfdbe069293417d57ecccd5655dab2 100755 --- a/indra/llcommon/llmd5.h +++ b/indra/llcommon/llmd5.h @@ -109,11 +109,11 @@ private: // next, the private data: - uint4 state[4]; - uint4 count[2]; // number of *bits*, mod 2^64 - uint1 buffer[64]; // input buffer - uint1 digest[16]; - uint1 finalized; + uint4 mState[4]; + uint4 mCount[2]; // number of *bits*, mod 2^64 + uint1 mBuffer[64]; // input buffer + uint1 mDigest[16]; + bool mFinalized; // last, the private methods, mostly static: void init (); // called by all constructors