/*************************************************
* SHA2-256 Header File                           *
* (C) 1999-2002 The OpenCL Project               *
*************************************************/

#ifndef OPENCL_SHA2_256_H__
#define OPENCL_SHA2_256_H__

#include <opencl/opencl.h>

namespace OpenCL {

class SHA2_256 : public HashFunction
   {
   public:
      static const u32bit BLOCKSIZE = 64, HASHLENGTH = 32;

      void clear() throw();
      std::string name() const { return "SHA2-256"; }
      HashFunction* clone() const { return new SHA2_256; }
      SHA2_256() : HashFunction(32, 64) { clear(); }
   private:
      void add_data(const byte[], u32bit);
      void final_result(byte[]);
      void hash(const byte[]);
      static void F1(u32bit, u32bit, u32bit, u32bit&, u32bit,
                     u32bit, u32bit, u32bit&, u32bit, u32bit);
      static u32bit rho(u32bit, u32bit, u32bit, u32bit);
      static u32bit sigma(u32bit, u32bit, u32bit, u32bit);
      SecureBuffer<byte, 64> buffer;
      SecureBuffer<u32bit, 64> W;
      SecureBuffer<u32bit, 8> digest;
      u64bit count, position;
   };

}

#endif
