Sha2Impl.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00022 //----------------------------------------------------------------------
00023 #ifndef ICL_CORE_CRYPT_SHA2_IMPL_H_INCLUDED
00024 #define ICL_CORE_CRYPT_SHA2_IMPL_H_INCLUDED
00025 
00026 #include <icl_core/BaseTypes.h>
00027 
00028 namespace icl_core {
00029 namespace crypt {
00030 
00051 template <typename T, T t_h0, T t_h1, T t_h2, T t_h3, T t_h4, T t_h5, T t_h6, T t_h7, size_t t_len>
00052 class Sha2Impl
00053 {
00054 public:
00056   static const size_t cMESSAGE_BLOCK_SIZE = 64;
00060   static const size_t cMESSAGE_PAD_POSITION = 56;
00061 
00063   Sha2Impl();
00064 
00066   void clear();
00067 
00069   ::icl_core::String getHexDigest() const;
00070 
00071 protected:
00075   void processBuffer();
00076 
00078   T m_digest[8];
00080   uint64_t m_message_size;
00084   uint8_t m_buffer[cMESSAGE_BLOCK_SIZE];
00086   size_t m_buffer_fill;
00087 };
00088 
00104 template <uint64_t t_h0, uint64_t t_h1, uint64_t t_h2, uint64_t t_h3, uint64_t t_h4, uint64_t t_h5, uint64_t t_h6, uint64_t t_h7, size_t t_len>
00105 class Sha2Impl<uint64_t, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len>
00106 {
00107 public:
00109   static const size_t cMESSAGE_BLOCK_SIZE = 128;
00113   static const size_t cMESSAGE_PAD_POSITION = 112;
00114 
00116   Sha2Impl();
00117 
00119   void clear();
00120 
00122   ::icl_core::String getHexDigest() const;
00123 
00124 protected:
00128   void processBuffer();
00129 
00133   void finalizeBuffer(size_t size);
00134 
00136   uint64_t m_digest[8];
00138   uint64_t m_message_size;
00142   uint8_t m_buffer[cMESSAGE_BLOCK_SIZE];
00144   size_t m_buffer_fill;
00145 };
00146 
00147 }
00148 }
00149 
00150 #include "icl_core_crypt/Sha2Impl.hpp"
00151 
00152 #endif


fzi_icl_core
Author(s):
autogenerated on Thu Jun 6 2019 20:22:24