summaryrefslogtreecommitdiffhomepage
path: root/libtomcrypt/src/hashes/sha2/sha224.c
diff options
context:
space:
mode:
Diffstat (limited to 'libtomcrypt/src/hashes/sha2/sha224.c')
-rw-r--r--libtomcrypt/src/hashes/sha2/sha224.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/libtomcrypt/src/hashes/sha2/sha224.c b/libtomcrypt/src/hashes/sha2/sha224.c
index 5d7dfb2..773a2c5 100644
--- a/libtomcrypt/src/hashes/sha2/sha224.c
+++ b/libtomcrypt/src/hashes/sha2/sha224.c
@@ -5,14 +5,16 @@
*
* The library is free for all purposes without any express
* guarantee it works.
- *
- * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
*/
/**
@param sha224.c
LTC_SHA-224 new NIST standard based off of LTC_SHA-256 truncated to 224 bits (Tom St Denis)
*/
+#include "tomcrypt.h"
+
+#if defined(LTC_SHA224) && defined(LTC_SHA256)
+
const struct ltc_hash_descriptor sha224_desc =
{
"sha224",
@@ -72,21 +74,21 @@ int sha224_done(hash_state * md, unsigned char *out)
XMEMCPY(out, buf, 28);
#ifdef LTC_CLEAN_STACK
zeromem(buf, sizeof(buf));
-#endif
+#endif
return err;
}
/**
Self-test the hash
@return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled
-*/
+*/
int sha224_test(void)
{
#ifndef LTC_TEST
return CRYPT_NOP;
- #else
+ #else
static const struct {
- char *msg;
+ const char *msg;
unsigned char hash[28];
} tests[] = {
{ "abc",
@@ -111,7 +113,7 @@ int sha224_test(void)
sha224_init(&md);
sha224_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg));
sha224_done(&md, tmp);
- if (XMEMCMP(tmp, tests[i].hash, 28) != 0) {
+ if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA224", i)) {
return CRYPT_FAIL_TESTVECTOR;
}
}
@@ -119,7 +121,9 @@ int sha224_test(void)
#endif
}
+#endif /* defined(LTC_SHA224) && defined(LTC_SHA256) */
+
-/* $Source$ */
-/* $Revision$ */
-/* $Date$ */
+/* ref: $Format:%D$ */
+/* git commit: $Format:%H$ */
+/* commit time: $Format:%ai$ */