diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/asn1/oid_lookup/default.cpp | 1 | ||||
-rw-r--r-- | src/lib/hash/has160/has160.cpp | 162 | ||||
-rw-r--r-- | src/lib/hash/has160/has160.h | 39 | ||||
-rw-r--r-- | src/lib/hash/has160/info.txt | 5 | ||||
-rw-r--r-- | src/lib/hash/hash.cpp | 24 | ||||
-rw-r--r-- | src/lib/hash/md2/info.txt | 1 | ||||
-rw-r--r-- | src/lib/hash/md2/md2.cpp | 112 | ||||
-rw-r--r-- | src/lib/hash/md2/md2.h | 41 | ||||
-rw-r--r-- | src/lib/hash/rmd128/info.txt | 5 | ||||
-rw-r--r-- | src/lib/hash/rmd128/rmd128.cpp | 173 | ||||
-rw-r--r-- | src/lib/hash/rmd128/rmd128.h | 38 | ||||
-rw-r--r-- | src/lib/pk_pad/hash_id/hash_id.cpp | 17 | ||||
-rw-r--r-- | src/lib/prov/openssl/openssl_hash.cpp | 4 |
13 files changed, 0 insertions, 622 deletions
diff --git a/src/lib/asn1/oid_lookup/default.cpp b/src/lib/asn1/oid_lookup/default.cpp index 0d64a8bef..8b9d97e38 100644 --- a/src/lib/asn1/oid_lookup/default.cpp +++ b/src/lib/asn1/oid_lookup/default.cpp @@ -93,7 +93,6 @@ const char* default_oid_list() "1.2.840.113549.1.9.16.3.8 = Compression.Zlib" "\n" "1.2.840.113549.1.1.1 = RSA/EME-PKCS1-v1_5" "\n" - "1.2.840.113549.1.1.2 = RSA/EMSA3(MD2)" "\n" "1.2.840.113549.1.1.4 = RSA/EMSA3(MD5)" "\n" "1.2.840.113549.1.1.5 = RSA/EMSA3(SHA-160)" "\n" "1.2.840.113549.1.1.11 = RSA/EMSA3(SHA-256)" "\n" diff --git a/src/lib/hash/has160/has160.cpp b/src/lib/hash/has160/has160.cpp deleted file mode 100644 index 114b5f8b5..000000000 --- a/src/lib/hash/has160/has160.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -* HAS-160 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/has160.h> - -namespace Botan { - -namespace HAS_160_F { - -/* -* HAS-160 F1 Function -*/ -inline void F1(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, - u32bit msg, u32bit rot) - { - E += rotate_left(A, rot) + (D ^ (B & (C ^ D))) + msg; - B = rotate_left(B, 10); - } - -/* -* HAS-160 F2 Function -*/ -inline void F2(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, - u32bit msg, u32bit rot) - { - E += rotate_left(A, rot) + (B ^ C ^ D) + msg + 0x5A827999; - B = rotate_left(B, 17); - } - -/* -* HAS-160 F3 Function -*/ -inline void F3(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, - u32bit msg, u32bit rot) - { - E += rotate_left(A, rot) + (C ^ (B | ~D)) + msg + 0x6ED9EBA1; - B = rotate_left(B, 25); - } - -/* -* HAS-160 F4 Function -*/ -inline void F4(u32bit A, u32bit& B, u32bit C, u32bit D, u32bit& E, - u32bit msg, u32bit rot) - { - E += rotate_left(A, rot) + (B ^ C ^ D) + msg + 0x8F1BBCDC; - B = rotate_left(B, 30); - } - -} - -/* -* HAS-160 Compression Function -*/ -void HAS_160::compress_n(const byte input[], size_t blocks) - { - using namespace HAS_160_F; - - u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2], - D = m_digest[3], E = m_digest[4]; - - for(size_t i = 0; i != blocks; ++i) - { - load_le(m_X.data(), input, 16); - - m_X[16] = m_X[ 0] ^ m_X[ 1] ^ m_X[ 2] ^ m_X[ 3]; - m_X[17] = m_X[ 4] ^ m_X[ 5] ^ m_X[ 6] ^ m_X[ 7]; - m_X[18] = m_X[ 8] ^ m_X[ 9] ^ m_X[10] ^ m_X[11]; - m_X[19] = m_X[12] ^ m_X[13] ^ m_X[14] ^ m_X[15]; - F1(A,B,C,D,E,m_X[18], 5); F1(E,A,B,C,D,m_X[ 0],11); - F1(D,E,A,B,C,m_X[ 1], 7); F1(C,D,E,A,B,m_X[ 2],15); - F1(B,C,D,E,A,m_X[ 3], 6); F1(A,B,C,D,E,m_X[19],13); - F1(E,A,B,C,D,m_X[ 4], 8); F1(D,E,A,B,C,m_X[ 5],14); - F1(C,D,E,A,B,m_X[ 6], 7); F1(B,C,D,E,A,m_X[ 7],12); - F1(A,B,C,D,E,m_X[16], 9); F1(E,A,B,C,D,m_X[ 8],11); - F1(D,E,A,B,C,m_X[ 9], 8); F1(C,D,E,A,B,m_X[10],15); - F1(B,C,D,E,A,m_X[11], 6); F1(A,B,C,D,E,m_X[17],12); - F1(E,A,B,C,D,m_X[12], 9); F1(D,E,A,B,C,m_X[13],14); - F1(C,D,E,A,B,m_X[14], 5); F1(B,C,D,E,A,m_X[15],13); - - m_X[16] = m_X[ 3] ^ m_X[ 6] ^ m_X[ 9] ^ m_X[12]; - m_X[17] = m_X[ 2] ^ m_X[ 5] ^ m_X[ 8] ^ m_X[15]; - m_X[18] = m_X[ 1] ^ m_X[ 4] ^ m_X[11] ^ m_X[14]; - m_X[19] = m_X[ 0] ^ m_X[ 7] ^ m_X[10] ^ m_X[13]; - F2(A,B,C,D,E,m_X[18], 5); F2(E,A,B,C,D,m_X[ 3],11); - F2(D,E,A,B,C,m_X[ 6], 7); F2(C,D,E,A,B,m_X[ 9],15); - F2(B,C,D,E,A,m_X[12], 6); F2(A,B,C,D,E,m_X[19],13); - F2(E,A,B,C,D,m_X[15], 8); F2(D,E,A,B,C,m_X[ 2],14); - F2(C,D,E,A,B,m_X[ 5], 7); F2(B,C,D,E,A,m_X[ 8],12); - F2(A,B,C,D,E,m_X[16], 9); F2(E,A,B,C,D,m_X[11],11); - F2(D,E,A,B,C,m_X[14], 8); F2(C,D,E,A,B,m_X[ 1],15); - F2(B,C,D,E,A,m_X[ 4], 6); F2(A,B,C,D,E,m_X[17],12); - F2(E,A,B,C,D,m_X[ 7], 9); F2(D,E,A,B,C,m_X[10],14); - F2(C,D,E,A,B,m_X[13], 5); F2(B,C,D,E,A,m_X[ 0],13); - - m_X[16] = m_X[ 5] ^ m_X[ 7] ^ m_X[12] ^ m_X[14]; - m_X[17] = m_X[ 0] ^ m_X[ 2] ^ m_X[ 9] ^ m_X[11]; - m_X[18] = m_X[ 4] ^ m_X[ 6] ^ m_X[13] ^ m_X[15]; - m_X[19] = m_X[ 1] ^ m_X[ 3] ^ m_X[ 8] ^ m_X[10]; - F3(A,B,C,D,E,m_X[18], 5); F3(E,A,B,C,D,m_X[12],11); - F3(D,E,A,B,C,m_X[ 5], 7); F3(C,D,E,A,B,m_X[14],15); - F3(B,C,D,E,A,m_X[ 7], 6); F3(A,B,C,D,E,m_X[19],13); - F3(E,A,B,C,D,m_X[ 0], 8); F3(D,E,A,B,C,m_X[ 9],14); - F3(C,D,E,A,B,m_X[ 2], 7); F3(B,C,D,E,A,m_X[11],12); - F3(A,B,C,D,E,m_X[16], 9); F3(E,A,B,C,D,m_X[ 4],11); - F3(D,E,A,B,C,m_X[13], 8); F3(C,D,E,A,B,m_X[ 6],15); - F3(B,C,D,E,A,m_X[15], 6); F3(A,B,C,D,E,m_X[17],12); - F3(E,A,B,C,D,m_X[ 8], 9); F3(D,E,A,B,C,m_X[ 1],14); - F3(C,D,E,A,B,m_X[10], 5); F3(B,C,D,E,A,m_X[ 3],13); - - m_X[16] = m_X[ 2] ^ m_X[ 7] ^ m_X[ 8] ^ m_X[13]; - m_X[17] = m_X[ 3] ^ m_X[ 4] ^ m_X[ 9] ^ m_X[14]; - m_X[18] = m_X[ 0] ^ m_X[ 5] ^ m_X[10] ^ m_X[15]; - m_X[19] = m_X[ 1] ^ m_X[ 6] ^ m_X[11] ^ m_X[12]; - F4(A,B,C,D,E,m_X[18], 5); F4(E,A,B,C,D,m_X[ 7],11); - F4(D,E,A,B,C,m_X[ 2], 7); F4(C,D,E,A,B,m_X[13],15); - F4(B,C,D,E,A,m_X[ 8], 6); F4(A,B,C,D,E,m_X[19],13); - F4(E,A,B,C,D,m_X[ 3], 8); F4(D,E,A,B,C,m_X[14],14); - F4(C,D,E,A,B,m_X[ 9], 7); F4(B,C,D,E,A,m_X[ 4],12); - F4(A,B,C,D,E,m_X[16], 9); F4(E,A,B,C,D,m_X[15],11); - F4(D,E,A,B,C,m_X[10], 8); F4(C,D,E,A,B,m_X[ 5],15); - F4(B,C,D,E,A,m_X[ 0], 6); F4(A,B,C,D,E,m_X[17],12); - F4(E,A,B,C,D,m_X[11], 9); F4(D,E,A,B,C,m_X[ 6],14); - F4(C,D,E,A,B,m_X[ 1], 5); F4(B,C,D,E,A,m_X[12],13); - - A = (m_digest[0] += A); - B = (m_digest[1] += B); - C = (m_digest[2] += C); - D = (m_digest[3] += D); - E = (m_digest[4] += E); - - input += hash_block_size(); - } - } - -/* -* Copy out the digest -*/ -void HAS_160::copy_out(byte output[]) - { - copy_out_vec_le(output, output_length(), m_digest); - } - -/* -* Clear memory of sensitive data -*/ -void HAS_160::clear() - { - MDx_HashFunction::clear(); - zeroise(m_X); - m_digest[0] = 0x67452301; - m_digest[1] = 0xEFCDAB89; - m_digest[2] = 0x98BADCFE; - m_digest[3] = 0x10325476; - m_digest[4] = 0xC3D2E1F0; - } - -} diff --git a/src/lib/hash/has160/has160.h b/src/lib/hash/has160/has160.h deleted file mode 100644 index 7ef090eb7..000000000 --- a/src/lib/hash/has160/has160.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -* HAS-160 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_HAS_160_H__ -#define BOTAN_HAS_160_H__ - -#include <botan/mdx_hash.h> - -namespace Botan { - -/** -* HAS-160, a Korean hash function standardized in -* TTAS.KO-12.0011/R1. Used in conjunction with KCDSA -*/ -class BOTAN_DLL HAS_160 final : public MDx_HashFunction - { - public: - std::string name() const override { return "HAS-160"; } - size_t output_length() const override { return 20; } - HashFunction* clone() const override { return new HAS_160; } - - void clear() override; - - HAS_160() : MDx_HashFunction(64, false, true), m_X(20), m_digest(5) - { clear(); } - private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; - - secure_vector<u32bit> m_X, m_digest; - }; - -} - -#endif diff --git a/src/lib/hash/has160/info.txt b/src/lib/hash/has160/info.txt deleted file mode 100644 index cf403dad5..000000000 --- a/src/lib/hash/has160/info.txt +++ /dev/null @@ -1,5 +0,0 @@ -define HAS_160 20131128 - -<requires> -mdx_hash -</requires> diff --git a/src/lib/hash/hash.cpp b/src/lib/hash/hash.cpp index 9a15c7998..42a7666b6 100644 --- a/src/lib/hash/hash.cpp +++ b/src/lib/hash/hash.cpp @@ -25,18 +25,10 @@ #include <botan/gost_3411.h> #endif -#if defined(BOTAN_HAS_HAS_160) - #include <botan/has160.h> -#endif - #if defined(BOTAN_HAS_KECCAK) #include <botan/keccak.h> #endif -#if defined(BOTAN_HAS_MD2) - #include <botan/md2.h> -#endif - #if defined(BOTAN_HAS_MD4) #include <botan/md4.h> #endif @@ -45,10 +37,6 @@ #include <botan/md5.h> #endif -#if defined(BOTAN_HAS_RIPEMD_128) - #include <botan/rmd128.h> -#endif - #if defined(BOTAN_HAS_RIPEMD_160) #include <botan/rmd160.h> #endif @@ -147,18 +135,10 @@ BOTAN_REGISTER_NAMED_T(HashFunction, "Parallel", Parallel, Parallel::make); BOTAN_REGISTER_HASH_NAMED_NOARGS(GOST_34_11, "GOST-R-34.11-94"); #endif -#if defined(BOTAN_HAS_HAS_160) -BOTAN_REGISTER_HASH_NAMED_NOARGS(HAS_160, "HAS-160"); -#endif - #if defined(BOTAN_HAS_KECCAK) BOTAN_REGISTER_HASH_NAMED_1LEN(Keccak_1600, "Keccak-1600", 512); #endif -#if defined(BOTAN_HAS_MD2) -BOTAN_REGISTER_HASH_NOARGS(MD2); -#endif - #if defined(BOTAN_HAS_MD4) BOTAN_REGISTER_HASH_NOARGS(MD4); #endif @@ -167,10 +147,6 @@ BOTAN_REGISTER_HASH_NOARGS(MD4); BOTAN_REGISTER_HASH_NOARGS(MD5); #endif -#if defined(BOTAN_HAS_RIPEMD_128) -BOTAN_REGISTER_HASH_NAMED_NOARGS(RIPEMD_128, "RIPEMD-128"); -#endif - #if defined(BOTAN_HAS_RIPEMD_160) BOTAN_REGISTER_HASH_NAMED_NOARGS(RIPEMD_160, "RIPEMD-160"); #endif diff --git a/src/lib/hash/md2/info.txt b/src/lib/hash/md2/info.txt deleted file mode 100644 index 8ea7dc393..000000000 --- a/src/lib/hash/md2/info.txt +++ /dev/null @@ -1 +0,0 @@ -define MD2 20131128 diff --git a/src/lib/hash/md2/md2.cpp b/src/lib/hash/md2/md2.cpp deleted file mode 100644 index f5e222610..000000000 --- a/src/lib/hash/md2/md2.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* -* MD2 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/md2.h> - -namespace Botan { - -/** -* MD2 Compression Function -*/ -void MD2::hash(const byte input[]) - { - static const byte SBOX[256] = { - 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, 0x54, 0xA1, - 0xEC, 0xF0, 0x06, 0x13, 0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, - 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA, 0x1E, 0x9B, 0x57, 0x3C, - 0xFD, 0xD4, 0xE0, 0x16, 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12, - 0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, 0xA0, 0xFB, 0xF5, 0x8E, - 0xBB, 0x2F, 0xEE, 0x7A, 0xA9, 0x68, 0x79, 0x91, 0x15, 0xB2, 0x07, 0x3F, - 0x94, 0xC2, 0x10, 0x89, 0x0B, 0x22, 0x5F, 0x21, 0x80, 0x7F, 0x5D, 0x9A, - 0x5A, 0x90, 0x32, 0x27, 0x35, 0x3E, 0xCC, 0xE7, 0xBF, 0xF7, 0x97, 0x03, - 0xFF, 0x19, 0x30, 0xB3, 0x48, 0xA5, 0xB5, 0xD1, 0xD7, 0x5E, 0x92, 0x2A, - 0xAC, 0x56, 0xAA, 0xC6, 0x4F, 0xB8, 0x38, 0xD2, 0x96, 0xA4, 0x7D, 0xB6, - 0x76, 0xFC, 0x6B, 0xE2, 0x9C, 0x74, 0x04, 0xF1, 0x45, 0x9D, 0x70, 0x59, - 0x64, 0x71, 0x87, 0x20, 0x86, 0x5B, 0xCF, 0x65, 0xE6, 0x2D, 0xA8, 0x02, - 0x1B, 0x60, 0x25, 0xAD, 0xAE, 0xB0, 0xB9, 0xF6, 0x1C, 0x46, 0x61, 0x69, - 0x34, 0x40, 0x7E, 0x0F, 0x55, 0x47, 0xA3, 0x23, 0xDD, 0x51, 0xAF, 0x3A, - 0xC3, 0x5C, 0xF9, 0xCE, 0xBA, 0xC5, 0xEA, 0x26, 0x2C, 0x53, 0x0D, 0x6E, - 0x85, 0x28, 0x84, 0x09, 0xD3, 0xDF, 0xCD, 0xF4, 0x41, 0x81, 0x4D, 0x52, - 0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, 0x24, 0xE1, 0x7B, 0x08, - 0x0C, 0xBD, 0xB1, 0x4A, 0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, - 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39, 0xF2, 0xEF, 0xB7, 0x0E, - 0x66, 0x58, 0xD0, 0xE4, 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A, - 0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, 0xDB, 0x99, 0x8D, 0x33, - 0x9F, 0x11, 0x83, 0x14 }; - - buffer_insert(m_X, 16, input, hash_block_size()); - xor_buf(&m_X[32], m_X.data(), &m_X[16], hash_block_size()); - byte T = 0; - - for(size_t i = 0; i != 18; ++i) - { - for(size_t k = 0; k != 48; k += 8) - { - T = m_X[k ] ^= SBOX[T]; T = m_X[k+1] ^= SBOX[T]; - T = m_X[k+2] ^= SBOX[T]; T = m_X[k+3] ^= SBOX[T]; - T = m_X[k+4] ^= SBOX[T]; T = m_X[k+5] ^= SBOX[T]; - T = m_X[k+6] ^= SBOX[T]; T = m_X[k+7] ^= SBOX[T]; - } - - T += static_cast<byte>(i); - } - - T = m_checksum[15]; - for(size_t i = 0; i != hash_block_size(); ++i) - T = m_checksum[i] ^= SBOX[input[i] ^ T]; - } - -/** -* Update the hash -*/ -void MD2::add_data(const byte input[], size_t length) - { - buffer_insert(m_buffer, m_position, input, length); - - if(m_position + length >= hash_block_size()) - { - hash(m_buffer.data()); - input += (hash_block_size() - m_position); - length -= (hash_block_size() - m_position); - while(length >= hash_block_size()) - { - hash(input); - input += hash_block_size(); - length -= hash_block_size(); - } - copy_mem(m_buffer.data(), input, length); - m_position = 0; - } - m_position += length; - } - -/** -* Finalize a MD2 Hash -*/ -void MD2::final_result(byte output[]) - { - for(size_t i = m_position; i != hash_block_size(); ++i) - m_buffer[i] = static_cast<byte>(hash_block_size() - m_position); - - hash(m_buffer.data()); - hash(m_checksum.data()); - copy_mem(output, m_X.data(), output_length()); - clear(); - } - -/** -* Clear memory of sensitive data -*/ -void MD2::clear() - { - zeroise(m_X); - zeroise(m_checksum); - zeroise(m_buffer); - m_position = 0; - } - -} diff --git a/src/lib/hash/md2/md2.h b/src/lib/hash/md2/md2.h deleted file mode 100644 index 58629495a..000000000 --- a/src/lib/hash/md2/md2.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -* MD2 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_MD2_H__ -#define BOTAN_MD2_H__ - -#include <botan/hash.h> - -namespace Botan { - -/** -* MD2 -*/ -class BOTAN_DLL MD2 final : public HashFunction - { - public: - std::string name() const override { return "MD2"; } - size_t output_length() const override { return 16; } - size_t hash_block_size() const override { return 16; } - HashFunction* clone() const override { return new MD2; } - - void clear() override; - - MD2() : m_X(48), m_checksum(16), m_buffer(16), m_position(0) - { clear(); } - private: - void add_data(const byte[], size_t) override; - void hash(const byte[]); - void final_result(byte[]) override; - - secure_vector<byte> m_X, m_checksum, m_buffer; - size_t m_position; - }; - -} - -#endif diff --git a/src/lib/hash/rmd128/info.txt b/src/lib/hash/rmd128/info.txt deleted file mode 100644 index 7d2a4eacd..000000000 --- a/src/lib/hash/rmd128/info.txt +++ /dev/null @@ -1,5 +0,0 @@ -define RIPEMD_128 20131128 - -<requires> -mdx_hash -</requires> diff --git a/src/lib/hash/rmd128/rmd128.cpp b/src/lib/hash/rmd128/rmd128.cpp deleted file mode 100644 index e520fa0c3..000000000 --- a/src/lib/hash/rmd128/rmd128.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/* -* RIPEMD-128 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#include <botan/rmd128.h> - -namespace Botan { - -namespace RIPEMD_128_F { - -/* -* RIPEMD-128 F1 Function -*/ -inline void F1(u32bit& A, u32bit B, u32bit C, u32bit D, - u32bit msg, u32bit shift) - { - A += (B ^ C ^ D) + msg; - A = rotate_left(A, shift); - } - -/* -* RIPEMD-128 F2 Function -*/ -inline void F2(u32bit& A, u32bit B, u32bit C, u32bit D, - u32bit msg, u32bit shift, u32bit magic) - { - A += (D ^ (B & (C ^ D))) + msg + magic; - A = rotate_left(A, shift); - } - -/* -* RIPEMD-128 F3 Function -*/ -inline void F3(u32bit& A, u32bit B, u32bit C, u32bit D, - u32bit msg, u32bit shift, u32bit magic) - { - A += (D ^ (B | ~C)) + msg + magic; - A = rotate_left(A, shift); - } - -/* -* RIPEMD-128 F4 Function -*/ -inline void F4(u32bit& A, u32bit B, u32bit C, u32bit D, - u32bit msg, u32bit shift, u32bit magic) - { - A += (C ^ (D & (B ^ C))) + msg + magic; - A = rotate_left(A, shift); - } - -} - -/* -* RIPEMD-128 Compression Function -*/ -void RIPEMD_128::compress_n(const byte input[], size_t blocks) - { - using namespace RIPEMD_128_F; - - const u32bit MAGIC2 = 0x5A827999, MAGIC3 = 0x6ED9EBA1, - MAGIC4 = 0x8F1BBCDC, MAGIC5 = 0x50A28BE6, - MAGIC6 = 0x5C4DD124, MAGIC7 = 0x6D703EF3; - - for(size_t i = 0; i != blocks; ++i) - { - load_le(m_M.data(), input, m_M.size()); - - u32bit A1 = m_digest[0], A2 = A1, B1 = m_digest[1], B2 = B1, - C1 = m_digest[2], C2 = C1, D1 = m_digest[3], D2 = D1; - - F1(A1,B1,C1,D1,m_M[ 0],11 ); F4(A2,B2,C2,D2,m_M[ 5], 8,MAGIC5); - F1(D1,A1,B1,C1,m_M[ 1],14 ); F4(D2,A2,B2,C2,m_M[14], 9,MAGIC5); - F1(C1,D1,A1,B1,m_M[ 2],15 ); F4(C2,D2,A2,B2,m_M[ 7], 9,MAGIC5); - F1(B1,C1,D1,A1,m_M[ 3],12 ); F4(B2,C2,D2,A2,m_M[ 0],11,MAGIC5); - F1(A1,B1,C1,D1,m_M[ 4], 5 ); F4(A2,B2,C2,D2,m_M[ 9],13,MAGIC5); - F1(D1,A1,B1,C1,m_M[ 5], 8 ); F4(D2,A2,B2,C2,m_M[ 2],15,MAGIC5); - F1(C1,D1,A1,B1,m_M[ 6], 7 ); F4(C2,D2,A2,B2,m_M[11],15,MAGIC5); - F1(B1,C1,D1,A1,m_M[ 7], 9 ); F4(B2,C2,D2,A2,m_M[ 4], 5,MAGIC5); - F1(A1,B1,C1,D1,m_M[ 8],11 ); F4(A2,B2,C2,D2,m_M[13], 7,MAGIC5); - F1(D1,A1,B1,C1,m_M[ 9],13 ); F4(D2,A2,B2,C2,m_M[ 6], 7,MAGIC5); - F1(C1,D1,A1,B1,m_M[10],14 ); F4(C2,D2,A2,B2,m_M[15], 8,MAGIC5); - F1(B1,C1,D1,A1,m_M[11],15 ); F4(B2,C2,D2,A2,m_M[ 8],11,MAGIC5); - F1(A1,B1,C1,D1,m_M[12], 6 ); F4(A2,B2,C2,D2,m_M[ 1],14,MAGIC5); - F1(D1,A1,B1,C1,m_M[13], 7 ); F4(D2,A2,B2,C2,m_M[10],14,MAGIC5); - F1(C1,D1,A1,B1,m_M[14], 9 ); F4(C2,D2,A2,B2,m_M[ 3],12,MAGIC5); - F1(B1,C1,D1,A1,m_M[15], 8 ); F4(B2,C2,D2,A2,m_M[12], 6,MAGIC5); - - F2(A1,B1,C1,D1,m_M[ 7], 7,MAGIC2); F3(A2,B2,C2,D2,m_M[ 6], 9,MAGIC6); - F2(D1,A1,B1,C1,m_M[ 4], 6,MAGIC2); F3(D2,A2,B2,C2,m_M[11],13,MAGIC6); - F2(C1,D1,A1,B1,m_M[13], 8,MAGIC2); F3(C2,D2,A2,B2,m_M[ 3],15,MAGIC6); - F2(B1,C1,D1,A1,m_M[ 1],13,MAGIC2); F3(B2,C2,D2,A2,m_M[ 7], 7,MAGIC6); - F2(A1,B1,C1,D1,m_M[10],11,MAGIC2); F3(A2,B2,C2,D2,m_M[ 0],12,MAGIC6); - F2(D1,A1,B1,C1,m_M[ 6], 9,MAGIC2); F3(D2,A2,B2,C2,m_M[13], 8,MAGIC6); - F2(C1,D1,A1,B1,m_M[15], 7,MAGIC2); F3(C2,D2,A2,B2,m_M[ 5], 9,MAGIC6); - F2(B1,C1,D1,A1,m_M[ 3],15,MAGIC2); F3(B2,C2,D2,A2,m_M[10],11,MAGIC6); - F2(A1,B1,C1,D1,m_M[12], 7,MAGIC2); F3(A2,B2,C2,D2,m_M[14], 7,MAGIC6); - F2(D1,A1,B1,C1,m_M[ 0],12,MAGIC2); F3(D2,A2,B2,C2,m_M[15], 7,MAGIC6); - F2(C1,D1,A1,B1,m_M[ 9],15,MAGIC2); F3(C2,D2,A2,B2,m_M[ 8],12,MAGIC6); - F2(B1,C1,D1,A1,m_M[ 5], 9,MAGIC2); F3(B2,C2,D2,A2,m_M[12], 7,MAGIC6); - F2(A1,B1,C1,D1,m_M[ 2],11,MAGIC2); F3(A2,B2,C2,D2,m_M[ 4], 6,MAGIC6); - F2(D1,A1,B1,C1,m_M[14], 7,MAGIC2); F3(D2,A2,B2,C2,m_M[ 9],15,MAGIC6); - F2(C1,D1,A1,B1,m_M[11],13,MAGIC2); F3(C2,D2,A2,B2,m_M[ 1],13,MAGIC6); - F2(B1,C1,D1,A1,m_M[ 8],12,MAGIC2); F3(B2,C2,D2,A2,m_M[ 2],11,MAGIC6); - - F3(A1,B1,C1,D1,m_M[ 3],11,MAGIC3); F2(A2,B2,C2,D2,m_M[15], 9,MAGIC7); - F3(D1,A1,B1,C1,m_M[10],13,MAGIC3); F2(D2,A2,B2,C2,m_M[ 5], 7,MAGIC7); - F3(C1,D1,A1,B1,m_M[14], 6,MAGIC3); F2(C2,D2,A2,B2,m_M[ 1],15,MAGIC7); - F3(B1,C1,D1,A1,m_M[ 4], 7,MAGIC3); F2(B2,C2,D2,A2,m_M[ 3],11,MAGIC7); - F3(A1,B1,C1,D1,m_M[ 9],14,MAGIC3); F2(A2,B2,C2,D2,m_M[ 7], 8,MAGIC7); - F3(D1,A1,B1,C1,m_M[15], 9,MAGIC3); F2(D2,A2,B2,C2,m_M[14], 6,MAGIC7); - F3(C1,D1,A1,B1,m_M[ 8],13,MAGIC3); F2(C2,D2,A2,B2,m_M[ 6], 6,MAGIC7); - F3(B1,C1,D1,A1,m_M[ 1],15,MAGIC3); F2(B2,C2,D2,A2,m_M[ 9],14,MAGIC7); - F3(A1,B1,C1,D1,m_M[ 2],14,MAGIC3); F2(A2,B2,C2,D2,m_M[11],12,MAGIC7); - F3(D1,A1,B1,C1,m_M[ 7], 8,MAGIC3); F2(D2,A2,B2,C2,m_M[ 8],13,MAGIC7); - F3(C1,D1,A1,B1,m_M[ 0],13,MAGIC3); F2(C2,D2,A2,B2,m_M[12], 5,MAGIC7); - F3(B1,C1,D1,A1,m_M[ 6], 6,MAGIC3); F2(B2,C2,D2,A2,m_M[ 2],14,MAGIC7); - F3(A1,B1,C1,D1,m_M[13], 5,MAGIC3); F2(A2,B2,C2,D2,m_M[10],13,MAGIC7); - F3(D1,A1,B1,C1,m_M[11],12,MAGIC3); F2(D2,A2,B2,C2,m_M[ 0],13,MAGIC7); - F3(C1,D1,A1,B1,m_M[ 5], 7,MAGIC3); F2(C2,D2,A2,B2,m_M[ 4], 7,MAGIC7); - F3(B1,C1,D1,A1,m_M[12], 5,MAGIC3); F2(B2,C2,D2,A2,m_M[13], 5,MAGIC7); - - F4(A1,B1,C1,D1,m_M[ 1],11,MAGIC4); F1(A2,B2,C2,D2,m_M[ 8],15 ); - F4(D1,A1,B1,C1,m_M[ 9],12,MAGIC4); F1(D2,A2,B2,C2,m_M[ 6], 5 ); - F4(C1,D1,A1,B1,m_M[11],14,MAGIC4); F1(C2,D2,A2,B2,m_M[ 4], 8 ); - F4(B1,C1,D1,A1,m_M[10],15,MAGIC4); F1(B2,C2,D2,A2,m_M[ 1],11 ); - F4(A1,B1,C1,D1,m_M[ 0],14,MAGIC4); F1(A2,B2,C2,D2,m_M[ 3],14 ); - F4(D1,A1,B1,C1,m_M[ 8],15,MAGIC4); F1(D2,A2,B2,C2,m_M[11],14 ); - F4(C1,D1,A1,B1,m_M[12], 9,MAGIC4); F1(C2,D2,A2,B2,m_M[15], 6 ); - F4(B1,C1,D1,A1,m_M[ 4], 8,MAGIC4); F1(B2,C2,D2,A2,m_M[ 0],14 ); - F4(A1,B1,C1,D1,m_M[13], 9,MAGIC4); F1(A2,B2,C2,D2,m_M[ 5], 6 ); - F4(D1,A1,B1,C1,m_M[ 3],14,MAGIC4); F1(D2,A2,B2,C2,m_M[12], 9 ); - F4(C1,D1,A1,B1,m_M[ 7], 5,MAGIC4); F1(C2,D2,A2,B2,m_M[ 2],12 ); - F4(B1,C1,D1,A1,m_M[15], 6,MAGIC4); F1(B2,C2,D2,A2,m_M[13], 9 ); - F4(A1,B1,C1,D1,m_M[14], 8,MAGIC4); F1(A2,B2,C2,D2,m_M[ 9],12 ); - F4(D1,A1,B1,C1,m_M[ 5], 6,MAGIC4); F1(D2,A2,B2,C2,m_M[ 7], 5 ); - F4(C1,D1,A1,B1,m_M[ 6], 5,MAGIC4); F1(C2,D2,A2,B2,m_M[10],15 ); - F4(B1,C1,D1,A1,m_M[ 2],12,MAGIC4); F1(B2,C2,D2,A2,m_M[14], 8 ); - - D2 = m_digest[1] + C1 + D2; - m_digest[1] = m_digest[2] + D1 + A2; - m_digest[2] = m_digest[3] + A1 + B2; - m_digest[3] = m_digest[0] + B1 + C2; - m_digest[0] = D2; - - input += hash_block_size(); - } - } - -/* -* Copy out the digest -*/ -void RIPEMD_128::copy_out(byte output[]) - { - copy_out_vec_le(output, output_length(), m_digest); - } - -/* -* Clear memory of sensitive data -*/ -void RIPEMD_128::clear() - { - MDx_HashFunction::clear(); - zeroise(m_M); - m_digest[0] = 0x67452301; - m_digest[1] = 0xEFCDAB89; - m_digest[2] = 0x98BADCFE; - m_digest[3] = 0x10325476; - } - -} diff --git a/src/lib/hash/rmd128/rmd128.h b/src/lib/hash/rmd128/rmd128.h deleted file mode 100644 index ba36ab902..000000000 --- a/src/lib/hash/rmd128/rmd128.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -* RIPEMD-128 -* (C) 1999-2007 Jack Lloyd -* -* Botan is released under the Simplified BSD License (see license.txt) -*/ - -#ifndef BOTAN_RIPEMD_128_H__ -#define BOTAN_RIPEMD_128_H__ - -#include <botan/mdx_hash.h> - -namespace Botan { - -/** -* RIPEMD-128 -*/ -class BOTAN_DLL RIPEMD_128 final : public MDx_HashFunction - { - public: - std::string name() const override { return "RIPEMD-128"; } - size_t output_length() const override { return 16; } - HashFunction* clone() const override { return new RIPEMD_128; } - - void clear() override; - - RIPEMD_128() : MDx_HashFunction(64, false, true), m_M(16), m_digest(4) - { clear(); } - private: - void compress_n(const byte[], size_t blocks) override; - void copy_out(byte[]) override; - - secure_vector<u32bit> m_M, m_digest; - }; - -} - -#endif diff --git a/src/lib/pk_pad/hash_id/hash_id.cpp b/src/lib/pk_pad/hash_id/hash_id.cpp index 882c30a4c..2af0f6878 100644 --- a/src/lib/pk_pad/hash_id/hash_id.cpp +++ b/src/lib/pk_pad/hash_id/hash_id.cpp @@ -12,18 +12,10 @@ namespace Botan { namespace { -const byte MD2_PKCS_ID[] = { -0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, -0xF7, 0x0D, 0x02, 0x02, 0x05, 0x00, 0x04, 0x10 }; - const byte MD5_PKCS_ID[] = { 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10 }; -const byte RIPEMD_128_PKCS_ID[] = { -0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 0x03, 0x02, -0x02, 0x05, 0x00, 0x04, 0x14 }; - const byte RIPEMD_160_PKCS_ID[] = { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24, 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14 }; @@ -67,18 +59,10 @@ std::vector<byte> pkcs_hash_id(const std::string& name) if(name == "Parallel(MD5,SHA-160)") return std::vector<byte>(); - if(name == "MD2") - return std::vector<byte>(MD2_PKCS_ID, - MD2_PKCS_ID + sizeof(MD2_PKCS_ID)); - if(name == "MD5") return std::vector<byte>(MD5_PKCS_ID, MD5_PKCS_ID + sizeof(MD5_PKCS_ID)); - if(name == "RIPEMD-128") - return std::vector<byte>(RIPEMD_128_PKCS_ID, - RIPEMD_128_PKCS_ID + sizeof(RIPEMD_128_PKCS_ID)); - if(name == "RIPEMD-160") return std::vector<byte>(RIPEMD_160_PKCS_ID, RIPEMD_160_PKCS_ID + sizeof(RIPEMD_160_PKCS_ID)); @@ -127,7 +111,6 @@ byte ieee1363_hash_id(const std::string& name) if(name == "SHA-512") return 0x35; if(name == "RIPEMD-160") return 0x31; - if(name == "RIPEMD-128") return 0x32; if(name == "Whirlpool") return 0x37; diff --git a/src/lib/prov/openssl/openssl_hash.cpp b/src/lib/prov/openssl/openssl_hash.cpp index 574cfed91..c14c551e4 100644 --- a/src/lib/prov/openssl/openssl_hash.cpp +++ b/src/lib/prov/openssl/openssl_hash.cpp @@ -96,10 +96,6 @@ make_evp_hash_maker(const EVP_MD* md, const char* algo) BOTAN_REGISTER_OPENSSL_EVP_HASH("SHA-512", EVP_sha512); #endif -#if !defined(OPENSSL_NO_MD2) - BOTAN_REGISTER_OPENSSL_EVP_HASH("MD2", EVP_md2); -#endif - #if !defined(OPENSSL_NO_MD4) BOTAN_REGISTER_OPENSSL_EVP_HASH("MD4", EVP_md4); #endif |