summaryrefslogtreecommitdiff
path: root/ext/digest/sha2
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-11 12:43:58 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-11 12:43:58 +0000
commit945a76d97b00f9c0d24b6d14da86b18284316000 (patch)
tree081ca1d78f2303a682f338b2605a2da30d19b96f /ext/digest/sha2
parent76f721470b854fca0139f8aeab472341aade62c9 (diff)
* ext/digest/digest.c (rb_digest_base_alloc,
rb_digest_base_equal): Simplify the equality check and just compare resulted digests since state-level equality should not be significant. * ext/digest/digest.h: Ditto. * ext/digest/*/*.[ch]: Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/digest/sha2')
-rw-r--r--ext/digest/sha2/sha2.c18
-rw-r--r--ext/digest/sha2/sha2.h6
-rw-r--r--ext/digest/sha2/sha2init.c1
3 files changed, 0 insertions, 25 deletions
diff --git a/ext/digest/sha2/sha2.c b/ext/digest/sha2/sha2.c
index 1dd69c4..aca9ee9 100644
--- a/ext/digest/sha2/sha2.c
+++ b/ext/digest/sha2/sha2.c
@@ -578,12 +578,6 @@ void SHA256_Finish(SHA256_CTX* context, sha2_byte digest[]) {
usedspace = 0;
}
-int SHA256_Equal(SHA256_CTX* pctx1, SHA256_CTX* pctx2) {
- return pctx1->bitcount == pctx2->bitcount
- && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
- && memcmp(pctx1->buffer, pctx2->buffer, sizeof(pctx1->buffer)) == 0;
-}
-
/*** SHA-512: *********************************************************/
void SHA512_Init(SHA512_CTX* context) {
if (context == (SHA512_CTX*)0) {
@@ -881,12 +875,6 @@ void SHA512_Finish(SHA512_CTX* context, sha2_byte digest[]) {
MEMSET_BZERO(context, sizeof(SHA512_CTX));
}
-int SHA512_Equal(SHA512_CTX* pctx1, SHA512_CTX* pctx2) {
- return memcmp(pctx1->bitcount, pctx2->bitcount, sizeof(pctx1->bitcount)) == 0
- && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
- && memcmp(pctx1->buffer, pctx2->buffer, sizeof(pctx1->buffer)) == 0;
-}
-
/*** SHA-384: *********************************************************/
void SHA384_Init(SHA384_CTX* context) {
if (context == (SHA384_CTX*)0) {
@@ -929,9 +917,3 @@ void SHA384_Finish(SHA384_CTX* context, sha2_byte digest[]) {
/* Zero out state data */
MEMSET_BZERO(context, sizeof(SHA384_CTX));
}
-
-int SHA384_Equal(SHA384_CTX* pctx1, SHA384_CTX* pctx2) {
- return memcmp(pctx1->bitcount, pctx2->bitcount, sizeof(pctx1->bitcount)) == 0
- && memcmp(pctx1->state, pctx2->state, sizeof(pctx1->state)) == 0
- && memcmp(pctx1->buffer, pctx2->buffer, sizeof(pctx1->buffer)) == 0;
-}
diff --git a/ext/digest/sha2/sha2.h b/ext/digest/sha2/sha2.h
index db72cbb..917d415 100644
--- a/ext/digest/sha2/sha2.h
+++ b/ext/digest/sha2/sha2.h
@@ -78,34 +78,28 @@ typedef SHA512_CTX SHA384_CTX;
#define SHA256_Init rb_Digest_SHA256_Init
#define SHA256_Update rb_Digest_SHA256_Update
#define SHA256_Finish rb_Digest_SHA256_Finish
-#define SHA256_Equal rb_Digest_SHA256_Equal
#define SHA384_Init rb_Digest_SHA384_Init
#define SHA384_Update rb_Digest_SHA384_Update
#define SHA384_Finish rb_Digest_SHA384_Finish
-#define SHA384_Equal rb_Digest_SHA384_Equal
#define SHA512_Init rb_Digest_SHA512_Init
#define SHA512_Update rb_Digest_SHA512_Update
#define SHA512_Finish rb_Digest_SHA512_Finish
-#define SHA512_Equal rb_Digest_SHA512_Equal
#endif
/*** SHA-256/384/512 Function Prototypes ******************************/
void SHA256_Init _((SHA256_CTX *));
void SHA256_Update _((SHA256_CTX*, const uint8_t*, size_t));
void SHA256_Finish _((SHA256_CTX*, uint8_t[SHA256_DIGEST_LENGTH]));
-int SHA256_Equal _((SHA256_CTX*, SHA256_CTX*));
void SHA384_Init _((SHA384_CTX*));
void SHA384_Update _((SHA384_CTX*, const uint8_t*, size_t));
void SHA384_Finish _((SHA384_CTX*, uint8_t[SHA384_DIGEST_LENGTH]));
-int SHA384_Equal _((SHA384_CTX*, SHA384_CTX*));
void SHA512_Init _((SHA512_CTX*));
void SHA512_Update _((SHA512_CTX*, const uint8_t*, size_t));
void SHA512_Finish _((SHA512_CTX*, uint8_t[SHA512_DIGEST_LENGTH]));
-int SHA512_Equal _((SHA512_CTX*, SHA512_CTX*));
#ifdef __cplusplus
}
diff --git a/ext/digest/sha2/sha2init.c b/ext/digest/sha2/sha2init.c
index 4fb845c..cc815e7 100644
--- a/ext/digest/sha2/sha2init.c
+++ b/ext/digest/sha2/sha2init.c
@@ -13,7 +13,6 @@ static algo_t sha##bitlen = { \
(hash_init_func_t)SHA##bitlen##_Init, \
(hash_update_func_t)SHA##bitlen##_Update, \
(hash_finish_func_t)SHA##bitlen##_Finish, \
- (hash_equal_func_t)SHA##bitlen##_Equal, \
};
FOREACH_BITLEN(DEFINE_ALGO_METADATA)