Botan  1.11.15
src/lib/hash/sha2_64/sha2_64.h
Go to the documentation of this file.
00001 /*
00002 * SHA-{384,512}
00003 * (C) 1999-2010,2015 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_SHA_64BIT_H__
00009 #define BOTAN_SHA_64BIT_H__
00010 
00011 #include <botan/mdx_hash.h>
00012 
00013 namespace Botan {
00014 
00015 /**
00016 * SHA-384
00017 */
00018 class BOTAN_DLL SHA_384 : public MDx_HashFunction
00019    {
00020    public:
00021       std::string name() const { return "SHA-384"; }
00022       size_t output_length() const { return 48; }
00023       HashFunction* clone() const { return new SHA_384; }
00024 
00025       void clear();
00026 
00027       SHA_384() : MDx_HashFunction(128, true, true, 16), m_digest(8)
00028          { clear(); }
00029    private:
00030       void compress_n(const byte[], size_t blocks);
00031       void copy_out(byte[]);
00032 
00033       secure_vector<u64bit> m_digest;
00034    };
00035 
00036 /**
00037 * SHA-512
00038 */
00039 class BOTAN_DLL SHA_512 : public MDx_HashFunction
00040    {
00041    public:
00042       std::string name() const { return "SHA-512"; }
00043       size_t output_length() const { return 64; }
00044       HashFunction* clone() const { return new SHA_512; }
00045 
00046       void clear();
00047 
00048       SHA_512() : MDx_HashFunction(128, true, true, 16), m_digest(8)
00049          { clear(); }
00050    private:
00051       void compress_n(const byte[], size_t blocks);
00052       void copy_out(byte[]);
00053 
00054       secure_vector<u64bit> m_digest;
00055    };
00056 
00057 /**
00058 * SHA-512/256
00059 */
00060 class BOTAN_DLL SHA_512_256 : public MDx_HashFunction
00061    {
00062    public:
00063       std::string name() const { return "SHA-512/256"; }
00064       size_t output_length() const { return 32; }
00065       HashFunction* clone() const { return new SHA_512_256; }
00066 
00067       void clear();
00068 
00069       SHA_512_256() : MDx_HashFunction(128, true, true, 16), m_digest(8) { clear(); }
00070    private:
00071       void compress_n(const byte[], size_t blocks);
00072       void copy_out(byte[]);
00073 
00074       secure_vector<u64bit> m_digest;
00075    };
00076 
00077 }
00078 
00079 #endif