Bug #2459 ยป ruby_static_fix_sha2_multiple_definitions.patch
| ruby-1.8.6-p383/ext/digest/sha2/sha2.c 2009-11-13 14:56:56.000000000 +0000 | ||
|---|---|---|
|
* only.
|
||
|
*/
|
||
|
void SHA512_Last(SHA512_CTX*);
|
||
|
void SHA256_Transform(SHA256_CTX*, const sha2_word32*);
|
||
|
void SHA512_Transform(SHA512_CTX*, const sha2_word64*);
|
||
|
void My_SHA256_Transform(SHA256_CTX*, const sha2_word32*);
|
||
|
void My_SHA512_Transform(SHA512_CTX*, const sha2_word64*);
|
||
|
/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/
|
||
| ... | ... | |
|
(h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \
|
||
|
j++
|
||
|
void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
|
||
|
void My_SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
|
||
|
sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
|
||
|
sha2_word32 T1, *W256;
|
||
|
int j;
|
||
| ... | ... | |
|
#else /* SHA2_UNROLL_TRANSFORM */
|
||
|
void SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
|
||
|
void My_SHA256_Transform(SHA256_CTX* context, const sha2_word32* data) {
|
||
|
sha2_word32 a, b, c, d, e, f, g, h, s0, s1;
|
||
|
sha2_word32 T1, T2, *W256;
|
||
|
int j;
|
||
| ... | ... | |
|
context->bitcount += freespace << 3;
|
||
|
len -= freespace;
|
||
|
data += freespace;
|
||
|
SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||
|
My_SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||
|
} else {
|
||
|
/* The buffer is not yet full */
|
||
|
MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
|
||
| ... | ... | |
|
}
|
||
|
while (len >= SHA256_BLOCK_LENGTH) {
|
||
|
/* Process as many complete blocks as we can */
|
||
|
SHA256_Transform(context, (const sha2_word32*)data);
|
||
|
My_SHA256_Transform(context, (const sha2_word32*)data);
|
||
|
context->bitcount += SHA256_BLOCK_LENGTH << 3;
|
||
|
len -= SHA256_BLOCK_LENGTH;
|
||
|
data += SHA256_BLOCK_LENGTH;
|
||
| ... | ... | |
|
MEMSET_BZERO(&context->buffer[usedspace], SHA256_BLOCK_LENGTH - usedspace);
|
||
|
}
|
||
|
/* Do second-to-last transform: */
|
||
|
SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||
|
My_SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||
|
/* And set-up for the last transform: */
|
||
|
MEMSET_BZERO(context->buffer, SHA256_SHORT_BLOCK_LENGTH);
|
||
| ... | ... | |
|
*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
|
||
|
/* Final transform: */
|
||
|
SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||
|
My_SHA256_Transform(context, (sha2_word32*)context->buffer);
|
||
|
#ifndef WORDS_BIGENDIAN
|
||
|
{
|
||
| ... | ... | |
|
(h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \
|
||
|
j++
|
||
|
void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
|
||
|
void My_SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
|
||
|
sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
|
||
|
sha2_word64 T1, *W512 = (sha2_word64*)context->buffer;
|
||
|
int j;
|
||
| ... | ... | |
|
#else /* SHA2_UNROLL_TRANSFORM */
|
||
|
void SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
|
||
|
void My_SHA512_Transform(SHA512_CTX* context, const sha2_word64* data) {
|
||
|
sha2_word64 a, b, c, d, e, f, g, h, s0, s1;
|
||
|
sha2_word64 T1, T2, *W512 = (sha2_word64*)context->buffer;
|
||
|
int j;
|
||
| ... | ... | |
|
ADDINC128(context->bitcount, freespace << 3);
|
||
|
len -= freespace;
|
||
|
data += freespace;
|
||
|
SHA512_Transform(context, (const sha2_word64*)context->buffer);
|
||
|
My_SHA512_Transform(context, (const sha2_word64*)context->buffer);
|
||
|
} else {
|
||
|
/* The buffer is not yet full */
|
||
|
MEMCPY_BCOPY(&context->buffer[usedspace], data, len);
|
||
| ... | ... | |
|
}
|
||
|
while (len >= SHA512_BLOCK_LENGTH) {
|
||
|
/* Process as many complete blocks as we can */
|
||
|
SHA512_Transform(context, (const sha2_word64*)data);
|
||
|
My_SHA512_Transform(context, (const sha2_word64*)data);
|
||
|
ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3);
|
||
|
len -= SHA512_BLOCK_LENGTH;
|
||
|
data += SHA512_BLOCK_LENGTH;
|
||
| ... | ... | |
|
MEMSET_BZERO(&context->buffer[usedspace], SHA512_BLOCK_LENGTH - usedspace);
|
||
|
}
|
||
|
/* Do second-to-last transform: */
|
||
|
SHA512_Transform(context, (const sha2_word64*)context->buffer);
|
||
|
My_SHA512_Transform(context, (const sha2_word64*)context->buffer);
|
||
|
/* And set-up for the last transform: */
|
||
|
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH - 2);
|
||
| ... | ... | |
|
*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
|
||
|
/* Final transform: */
|
||
|
SHA512_Transform(context, (const sha2_word64*)context->buffer);
|
||
|
My_SHA512_Transform(context, (const sha2_word64*)context->buffer);
|
||
|
}
|
||
|
void SHA512_Finish(SHA512_CTX* context, sha2_byte digest[]) {
|
||