Botan  1.11.15
src/lib/hash/sha1/sha160.h
Go to the documentation of this file.
00001 /*
00002 * SHA-160
00003 * (C) 1999-2007 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_SHA_160_H__
00009 #define BOTAN_SHA_160_H__
00010 
00011 #include <botan/mdx_hash.h>
00012 
00013 namespace Botan {
00014 
00015 /**
00016 * NIST's SHA-160
00017 */
00018 class BOTAN_DLL SHA_160 : public MDx_HashFunction
00019    {
00020    public:
00021       std::string name() const { return "SHA-160"; }
00022       size_t output_length() const { return 20; }
00023       HashFunction* clone() const { return new SHA_160; }
00024 
00025       void clear();
00026 
00027       SHA_160() : MDx_HashFunction(64, true, true), digest(5), W(80)
00028          {
00029          clear();
00030          }
00031    protected:
00032       /**
00033       * Set a custom size for the W array. Normally 80, but some
00034       * subclasses need slightly more for best performance/internal
00035       * constraints
00036       * @param W_size how big to make W
00037       */
00038       SHA_160(size_t W_size) :
00039          MDx_HashFunction(64, true, true), digest(5), W(W_size)
00040          {
00041          clear();
00042          }
00043 
00044       void compress_n(const byte[], size_t blocks);
00045       void copy_out(byte[]);
00046 
00047       /**
00048       * The digest value, exposed for use by subclasses (asm, SSE2)
00049       */
00050       secure_vector<u32bit> digest;
00051 
00052       /**
00053       * The message buffer, exposed for use by subclasses (asm, SSE2)
00054       */
00055       secure_vector<u32bit> W;
00056    };
00057 
00058 }
00059 
00060 #endif