Botan
1.11.15
|
00001 /* 00002 * The Skein-512 hash function 00003 * (C) 2009,2014 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_SKEIN_512_H__ 00009 #define BOTAN_SKEIN_512_H__ 00010 00011 #include <botan/hash.h> 00012 #include <botan/threefish.h> 00013 #include <string> 00014 #include <memory> 00015 00016 namespace Botan { 00017 00018 /** 00019 * Skein-512, a SHA-3 candidate 00020 */ 00021 class BOTAN_DLL Skein_512 : public HashFunction 00022 { 00023 public: 00024 /** 00025 * @param output_bits the output size of Skein in bits 00026 * @param personalization is a string that will paramaterize the 00027 * hash output 00028 */ 00029 Skein_512(size_t output_bits = 512, 00030 const std::string& personalization = ""); 00031 00032 size_t hash_block_size() const { return 64; } 00033 size_t output_length() const { return output_bits / 8; } 00034 00035 static Skein_512* make(const Spec& spec); 00036 00037 HashFunction* clone() const; 00038 std::string name() const; 00039 void clear(); 00040 private: 00041 enum type_code { 00042 SKEIN_KEY = 0, 00043 SKEIN_CONFIG = 4, 00044 SKEIN_PERSONALIZATION = 8, 00045 SKEIN_PUBLIC_KEY = 12, 00046 SKEIN_KEY_IDENTIFIER = 16, 00047 SKEIN_NONCE = 20, 00048 SKEIN_MSG = 48, 00049 SKEIN_OUTPUT = 63 00050 }; 00051 00052 void add_data(const byte input[], size_t length); 00053 void final_result(byte out[]); 00054 00055 void ubi_512(const byte msg[], size_t msg_len); 00056 00057 void initial_block(); 00058 void reset_tweak(type_code type, bool final); 00059 00060 std::string personalization; 00061 size_t output_bits; 00062 00063 std::unique_ptr<Threefish_512> m_threefish; 00064 secure_vector<u64bit> T; 00065 secure_vector<byte> buffer; 00066 size_t buf_pos; 00067 }; 00068 00069 } 00070 00071 #endif