summaryrefslogtreecommitdiff
path: root/ext/digest/md5
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-15 14:59:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-15 14:59:20 +0000
commitaadebb29da14b65f47cf3e08ac164e6fe191febe (patch)
tree24a6148536d413890c668b7ce50e10942188711a /ext/digest/md5
parent6046b9f149ec748a11d7b23c6cf485fb3e079e5a (diff)
ext/digest: return values of init and final
* ext/digest: make built-in digest function implementations indicate success or failure of init and final functions. [ruby-core:61614] [Bug #9659] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest/md5')
-rw-r--r--ext/digest/md5/md5.c6
-rw-r--r--ext/digest/md5/md5.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/ext/digest/md5/md5.c b/ext/digest/md5/md5.c
index 8d7d33c..4ff280b 100644
--- a/ext/digest/md5/md5.c
+++ b/ext/digest/md5/md5.c
@@ -350,7 +350,7 @@ md5_process(MD5_CTX *pms, const uint8_t *data /*[64]*/)
pms->state[3] += d;
}
-void
+int
MD5_Init(MD5_CTX *pms)
{
pms->count[0] = pms->count[1] = 0;
@@ -358,6 +358,7 @@ MD5_Init(MD5_CTX *pms)
pms->state[1] = /*0xefcdab89*/ T_MASK ^ 0x10325476;
pms->state[2] = /*0x98badcfe*/ T_MASK ^ 0x67452301;
pms->state[3] = 0x10325476;
+ return 1;
}
void
@@ -398,7 +399,7 @@ MD5_Update(MD5_CTX *pms, const uint8_t *data, size_t nbytes)
memcpy(pms->buffer, p, left);
}
-void
+int
MD5_Finish(MD5_CTX *pms, uint8_t *digest)
{
static const uint8_t pad[64] = {
@@ -419,4 +420,5 @@ MD5_Finish(MD5_CTX *pms, uint8_t *digest)
MD5_Update(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (uint8_t)(pms->state[i >> 2] >> ((i & 3) << 3));
+ return 1;
}
diff --git a/ext/digest/md5/md5.h b/ext/digest/md5/md5.h
index f4580ef..a0faa25 100644
--- a/ext/digest/md5/md5.h
+++ b/ext/digest/md5/md5.h
@@ -69,9 +69,9 @@ typedef struct md5_state_s {
#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