From b110e6e4f51d136cd751029d43937517879d1dfb Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Sun, 7 Jul 2019 00:34:57 +0000 Subject: [PATCH] remove sha224 and sha512-224 --- Makefile | 3 - libtomcrypt/src/hashes/sha2/sha224.c | 129 ---------------------- libtomcrypt/src/hashes/sha2/sha512_224.c | 130 ----------------------- 3 files changed, 262 deletions(-) delete mode 100644 libtomcrypt/src/hashes/sha2/sha224.c delete mode 100644 libtomcrypt/src/hashes/sha2/sha512_224.c diff --git a/Makefile b/Makefile index 9bebb4b..62bbe12 100644 --- a/Makefile +++ b/Makefile @@ -411,11 +411,9 @@ LTCOBJ= \ hashes/rmd256.o \ hashes/rmd320.o \ hashes/sha1.o \ - hashes/sha2/sha224.o \ hashes/sha2/sha256.o \ hashes/sha2/sha384.o \ hashes/sha2/sha512.o \ - hashes/sha2/sha512_224.o \ hashes/sha2/sha512_256.o \ hashes/sha3.o \ hashes/sha3_test.o \ @@ -721,7 +719,6 @@ libtomcrypt/%.o: CFLAGS+= \ -DLTC_SHA512 \ -DLTC_SHA384 \ -DLTC_SHA256 \ - -DLTC_SHA224 \ -DLTC_HASH_HELPERS \ -DLTC_HMAC \ -DLTC_OMAC \ diff --git a/libtomcrypt/src/hashes/sha2/sha224.c b/libtomcrypt/src/hashes/sha2/sha224.c deleted file mode 100644 index 773a2c5..0000000 --- a/libtomcrypt/src/hashes/sha2/sha224.c +++ /dev/null @@ -1,129 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - */ -/** - @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", - 10, - 28, - 64, - - /* OID */ - { 2, 16, 840, 1, 101, 3, 4, 2, 4, }, - 9, - - &sha224_init, - &sha256_process, - &sha224_done, - &sha224_test, - NULL -}; - -/* init the sha256 er... sha224 state ;-) */ -/** - Initialize the hash state - @param md The hash state you wish to initialize - @return CRYPT_OK if successful -*/ -int sha224_init(hash_state * md) -{ - LTC_ARGCHK(md != NULL); - - md->sha256.curlen = 0; - md->sha256.length = 0; - md->sha256.state[0] = 0xc1059ed8UL; - md->sha256.state[1] = 0x367cd507UL; - md->sha256.state[2] = 0x3070dd17UL; - md->sha256.state[3] = 0xf70e5939UL; - md->sha256.state[4] = 0xffc00b31UL; - md->sha256.state[5] = 0x68581511UL; - md->sha256.state[6] = 0x64f98fa7UL; - md->sha256.state[7] = 0xbefa4fa4UL; - return CRYPT_OK; -} - -/** - Terminate the hash to get the digest - @param md The hash state - @param out [out] The destination of the hash (28 bytes) - @return CRYPT_OK if successful -*/ -int sha224_done(hash_state * md, unsigned char *out) -{ - unsigned char buf[32]; - int err; - - LTC_ARGCHK(md != NULL); - LTC_ARGCHK(out != NULL); - - err = sha256_done(md, buf); - XMEMCPY(out, buf, 28); -#ifdef LTC_CLEAN_STACK - zeromem(buf, sizeof(buf)); -#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 - static const struct { - const char *msg; - unsigned char hash[28]; - } tests[] = { - { "abc", - { 0x23, 0x09, 0x7d, 0x22, 0x34, 0x05, 0xd8, - 0x22, 0x86, 0x42, 0xa4, 0x77, 0xbd, 0xa2, - 0x55, 0xb3, 0x2a, 0xad, 0xbc, 0xe4, 0xbd, - 0xa0, 0xb3, 0xf7, 0xe3, 0x6c, 0x9d, 0xa7 } - }, - { "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", - { 0x75, 0x38, 0x8b, 0x16, 0x51, 0x27, 0x76, - 0xcc, 0x5d, 0xba, 0x5d, 0xa1, 0xfd, 0x89, - 0x01, 0x50, 0xb0, 0xc6, 0x45, 0x5c, 0xb4, - 0xf5, 0x8b, 0x19, 0x52, 0x52, 0x25, 0x25 } - }, - }; - - int i; - unsigned char tmp[28]; - hash_state md; - - for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { - sha224_init(&md); - sha224_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); - sha224_done(&md, tmp); - if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA224", i)) { - return CRYPT_FAIL_TESTVECTOR; - } - } - return CRYPT_OK; - #endif -} - -#endif /* defined(LTC_SHA224) && defined(LTC_SHA256) */ - - -/* ref: $Format:%D$ */ -/* git commit: $Format:%H$ */ -/* commit time: $Format:%ai$ */ diff --git a/libtomcrypt/src/hashes/sha2/sha512_224.c b/libtomcrypt/src/hashes/sha2/sha512_224.c deleted file mode 100644 index 48bb938..0000000 --- a/libtomcrypt/src/hashes/sha2/sha512_224.c +++ /dev/null @@ -1,130 +0,0 @@ -/* LibTomCrypt, modular cryptographic library -- Tom St Denis - * - * LibTomCrypt is a library that provides various cryptographic - * algorithms in a highly modular and flexible manner. - * - * The library is free for all purposes without any express - * guarantee it works. - */ -/** - @param sha512_224.c - SHA512/224 hash included in sha512.c -*/ - -#include "tomcrypt.h" - -#if defined(LTC_SHA512_224) && defined(LTC_SHA512) - -const struct ltc_hash_descriptor sha512_224_desc = -{ - "sha512-224", - 15, - 28, - 128, - - /* OID */ - { 2, 16, 840, 1, 101, 3, 4, 2, 5, }, - 9, - - &sha512_224_init, - &sha512_process, - &sha512_224_done, - &sha512_224_test, - NULL -}; - -/** - Initialize the hash state - @param md The hash state you wish to initialize - @return CRYPT_OK if successful -*/ -int sha512_224_init(hash_state * md) -{ - LTC_ARGCHK(md != NULL); - - md->sha512.curlen = 0; - md->sha512.length = 0; - md->sha512.state[0] = CONST64(0x8C3D37C819544DA2); - md->sha512.state[1] = CONST64(0x73E1996689DCD4D6); - md->sha512.state[2] = CONST64(0x1DFAB7AE32FF9C82); - md->sha512.state[3] = CONST64(0x679DD514582F9FCF); - md->sha512.state[4] = CONST64(0x0F6D2B697BD44DA8); - md->sha512.state[5] = CONST64(0x77E36F7304C48942); - md->sha512.state[6] = CONST64(0x3F9D85A86A1D36C8); - md->sha512.state[7] = CONST64(0x1112E6AD91D692A1); - return CRYPT_OK; -} - -/** - Terminate the hash to get the digest - @param md The hash state - @param out [out] The destination of the hash (48 bytes) - @return CRYPT_OK if successful -*/ -int sha512_224_done(hash_state * md, unsigned char *out) -{ - unsigned char buf[64]; - - LTC_ARGCHK(md != NULL); - LTC_ARGCHK(out != NULL); - - if (md->sha512.curlen >= sizeof(md->sha512.buf)) { - return CRYPT_INVALID_ARG; - } - - sha512_done(md, buf); - XMEMCPY(out, buf, 28); -#ifdef LTC_CLEAN_STACK - zeromem(buf, sizeof(buf)); -#endif - return CRYPT_OK; -} - -/** - Self-test the hash - @return CRYPT_OK if successful, CRYPT_NOP if self-tests have been disabled -*/ -int sha512_224_test(void) -{ - #ifndef LTC_TEST - return CRYPT_NOP; - #else - static const struct { - const char *msg; - unsigned char hash[28]; - } tests[] = { - { "abc", - { 0x46, 0x34, 0x27, 0x0F, 0x70, 0x7B, 0x6A, 0x54, - 0xDA, 0xAE, 0x75, 0x30, 0x46, 0x08, 0x42, 0xE2, - 0x0E, 0x37, 0xED, 0x26, 0x5C, 0xEE, 0xE9, 0xA4, - 0x3E, 0x89, 0x24, 0xAA } - }, - { "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", - { 0x23, 0xFE, 0xC5, 0xBB, 0x94, 0xD6, 0x0B, 0x23, - 0x30, 0x81, 0x92, 0x64, 0x0B, 0x0C, 0x45, 0x33, - 0x35, 0xD6, 0x64, 0x73, 0x4F, 0xE4, 0x0E, 0x72, - 0x68, 0x67, 0x4A, 0xF9 } - }, - }; - - int i; - unsigned char tmp[28]; - hash_state md; - - for (i = 0; i < (int)(sizeof(tests) / sizeof(tests[0])); i++) { - sha512_224_init(&md); - sha512_224_process(&md, (unsigned char*)tests[i].msg, (unsigned long)strlen(tests[i].msg)); - sha512_224_done(&md, tmp); - if (compare_testvector(tmp, sizeof(tmp), tests[i].hash, sizeof(tests[i].hash), "SHA512-224", i)) { - return CRYPT_FAIL_TESTVECTOR; - } - } - return CRYPT_OK; - #endif -} - -#endif /* defined(LTC_SHA384) && defined(LTC_SHA512) */ - -/* ref: $Format:%D$ */ -/* git commit: $Format:%H$ */ -/* commit time: $Format:%ai$ */ -- 2.40.0