Project

General

Profile

Bug #9659 » 002-builtin-indicate-digest-failure.patch

View differences:

ext/digest/md5/md5.c
pms->state[3] += d;
}
void
int
MD5_Init(MD5_CTX *pms)
{
pms->count[0] = pms->count[1] = 0;
......
pms->state[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
pms->state[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
pms->state[3] = 0x10325476;
return 1;
}
void
......
memcpy(pms->buffer, p, left);
}
void
int
MD5_Finish(MD5_CTX *pms, uint8_t *digest)
{
static const uint8_t pad[64] = {
......
MD5_Update(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (uint8_t)(pms->state[i >> 2] >> ((i & 3) << 3));
return 1;
}
ext/digest/md5/md5.h
#define MD5_Finish rb_Digest_MD5_Finish
#endif
void MD5_Init _((MD5_CTX *pms));
int MD5_Init _((MD5_CTX *pms));
void MD5_Update _((MD5_CTX *pms, const uint8_t *data, size_t nbytes));
void MD5_Finish _((MD5_CTX *pms, uint8_t *digest));
int MD5_Finish _((MD5_CTX *pms, uint8_t *digest));
#define MD5_BLOCK_LENGTH 64
#define MD5_DIGEST_LENGTH 16
ext/digest/rmd160/rmd160.c
/********************************************************************/
void
int
RMD160_Init(RMD160_CTX *context)
{
......
context->state[4] = 0xc3d2e1f0U;
context->length[0] = context->length[1] = 0;
context->buflen = 0;
return 1;
}
/********************************************************************/
......
/********************************************************************/
void
int
RMD160_Finish(RMD160_CTX *context, uint8_t digest[20])
{
uint32_t i;
......
digest[i + 3] = (context->state[i>>2] >> 24);
}
}
return 1;
}
/************************ end of file rmd160.c **********************/
ext/digest/rmd160/rmd160.h
#endif
__BEGIN_DECLS
void RMD160_Init _((RMD160_CTX *));
int RMD160_Init _((RMD160_CTX *));
void RMD160_Transform _((uint32_t[5], const uint32_t[16]));
void RMD160_Update _((RMD160_CTX *, const uint8_t *, size_t));
void RMD160_Finish _((RMD160_CTX *, uint8_t[20]));
int RMD160_Finish _((RMD160_CTX *, uint8_t[20]));
__END_DECLS
#define RMD160_BLOCK_LENGTH 64
ext/digest/sha1/sha1.c
/*
* SHA1_Init - Initialize new context
*/
void SHA1_Init(SHA1_CTX *context)
int SHA1_Init(SHA1_CTX *context)
{
_DIAGASSERT(context != 0);
......
context->state[3] = 0x10325476;
context->state[4] = 0xC3D2E1F0;
context->count[0] = context->count[1] = 0;
return 1;
}
......
/*
* Add padding and return the message digest.
*/
void SHA1_Finish(SHA1_CTX* context, uint8_t digest[20])
int SHA1_Finish(SHA1_CTX* context, uint8_t digest[20])
{
size_t i;
uint8_t finalcount[8];
......
digest[i] = (uint8_t)
((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
}
return 1;
}
ext/digest/sha1/sha1.h
#endif
void SHA1_Transform _((uint32_t state[5], const uint8_t buffer[64]));
void SHA1_Init _((SHA1_CTX *context));
int SHA1_Init _((SHA1_CTX *context));
void SHA1_Update _((SHA1_CTX *context, const uint8_t *data, size_t len));
void SHA1_Finish _((SHA1_CTX *context, uint8_t digest[20]));
int SHA1_Finish _((SHA1_CTX *context, uint8_t digest[20]));
#define SHA1_BLOCK_LENGTH 64
#define SHA1_DIGEST_LENGTH 20
ext/digest/sha2/sha2.c
/*** SHA-256: *********************************************************/
void SHA256_Init(SHA256_CTX* context) {
int SHA256_Init(SHA256_CTX* context) {
if (context == (SHA256_CTX*)0) {
return;
return 0;
}
MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH);
MEMSET_BZERO(context->buffer, SHA256_BLOCK_LENGTH);
context->bitcount = 0;
return 1;
}
#ifdef SHA2_UNROLL_TRANSFORM
......
usedspace = freespace = 0;
}
void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
int SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
sha2_word32 *d = (sha2_word32*)digest;
unsigned int usedspace;
......
/* Clean up state data: */
MEMSET_BZERO(context, sizeof(*context));
usedspace = 0;
return 1;
}
char *SHA256_End(SHA256_CTX* context, char buffer[]) {
......
/*** SHA-512: *********************************************************/
void SHA512_Init(SHA512_CTX* context) {
int SHA512_Init(SHA512_CTX* context) {
if (context == (SHA512_CTX*)0) {
return;
return 0;
}
MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH);
MEMSET_BZERO(context->buffer, SHA512_BLOCK_LENGTH);
context->bitcount[0] = context->bitcount[1] = 0;
return 1;
}
#ifdef SHA2_UNROLL_TRANSFORM
......
SHA512_Transform(context, (sha2_word64*)context->buffer);
}
void SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
int SHA512_Final(sha2_byte digest[], SHA512_CTX* context) {
sha2_word64 *d = (sha2_word64*)digest;
/* Sanity check: */
......
/* Zero out state data */
MEMSET_BZERO(context, sizeof(*context));
return 1;
}
char *SHA512_End(SHA512_CTX* context, char buffer[]) {
......
/*** SHA-384: *********************************************************/
void SHA384_Init(SHA384_CTX* context) {
int SHA384_Init(SHA384_CTX* context) {
if (context == (SHA384_CTX*)0) {
return;
return 0;
}
MEMCPY_BCOPY(context->state, sha384_initial_hash_value, SHA512_DIGEST_LENGTH);
MEMSET_BZERO(context->buffer, SHA384_BLOCK_LENGTH);
context->bitcount[0] = context->bitcount[1] = 0;
return 1;
}
void SHA384_Update(SHA384_CTX* context, const sha2_byte* data, size_t len) {
SHA512_Update((SHA512_CTX*)context, data, len);
}
void SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
int SHA384_Final(sha2_byte digest[], SHA384_CTX* context) {
sha2_word64 *d = (sha2_word64*)digest;
/* Sanity check: */
......
/* Zero out state data */
MEMSET_BZERO(context, sizeof(*context));
return 1;
}
char *SHA384_End(SHA384_CTX* context, char buffer[]) {
ext/digest/sha2/sha2.h
#ifndef NOPROTO
void SHA256_Init(SHA256_CTX *);
int SHA256_Init(SHA256_CTX *);
void SHA256_Update(SHA256_CTX*, const uint8_t*, size_t);
void SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
int SHA256_Final(uint8_t[SHA256_DIGEST_LENGTH], SHA256_CTX*);
char* SHA256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]);
char* SHA256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]);
void SHA384_Init(SHA384_CTX*);
int SHA384_Init(SHA384_CTX*);
void SHA384_Update(SHA384_CTX*, const uint8_t*, size_t);
void SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
int SHA384_Final(uint8_t[SHA384_DIGEST_LENGTH], SHA384_CTX*);
char* SHA384_End(SHA384_CTX*, char[SHA384_DIGEST_STRING_LENGTH]);
char* SHA384_Data(const uint8_t*, size_t, char[SHA384_DIGEST_STRING_LENGTH]);
void SHA512_Init(SHA512_CTX*);
int SHA512_Init(SHA512_CTX*);
void SHA512_Update(SHA512_CTX*, const uint8_t*, size_t);
void SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
int SHA512_Final(uint8_t[SHA512_DIGEST_LENGTH], SHA512_CTX*);
char* SHA512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]);
char* SHA512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]);
#else /* NOPROTO */
void SHA256_Init();
int SHA256_Init();
void SHA256_Update();
#ifdef RUBY
void SHA256_Finish();
int SHA256_Finish();
#else
void SHA256_Final();
int SHA256_Final();
#endif /* RUBY */
char* SHA256_End();
char* SHA256_Data();
void SHA384_Init();
int SHA384_Init();
void SHA384_Update();
#ifdef RUBY
void SHA384_Finish();
int SHA384_Finish();
#else
void SHA384_Final();
int SHA384_Final();
#endif /* RUBY */
char* SHA384_End();
char* SHA384_Data();
void SHA512_Init();
int SHA512_Init();
void SHA512_Update();
#ifdef RUBY
void SHA512_Finish();
int SHA512_Finish();
#else
void SHA512_Final();
int SHA512_Final();
#endif /* RUBY */
char* SHA512_End();
char* SHA512_Data();
(1-1/3)