Sha2Impl.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 #ifndef ICL_CORE_CRYPT_SHA2_IMPL_H_INCLUDED
24 #define ICL_CORE_CRYPT_SHA2_IMPL_H_INCLUDED
25 
26 #include <icl_core/BaseTypes.h>
27 
28 namespace icl_core {
29 namespace crypt {
30 
51 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>
52 class Sha2Impl
53 {
54 public:
56  static const size_t cMESSAGE_BLOCK_SIZE = 64;
60  static const size_t cMESSAGE_PAD_POSITION = 56;
61 
63  Sha2Impl();
64 
66  void clear();
67 
70 
71 protected:
75  void processBuffer();
76 
78  T m_digest[8];
86  size_t m_buffer_fill;
87 };
88 
104 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>
105 class Sha2Impl<uint64_t, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len>
106 {
107 public:
109  static const size_t cMESSAGE_BLOCK_SIZE = 128;
113  static const size_t cMESSAGE_PAD_POSITION = 112;
114 
116  Sha2Impl();
117 
119  void clear();
120 
123 
124 protected:
128  void processBuffer();
129 
133  void finalizeBuffer(size_t size);
134 
145 };
146 
147 }
148 }
149 
151 
152 #endif
size_t m_buffer_fill
The amount of bytes currently stored in the internal buffer.
Definition: Sha2Impl.h:144
uint8_t m_buffer[cMESSAGE_BLOCK_SIZE]
Definition: Sha2Impl.h:84
::icl_core::String getHexDigest() const
Returns the message digest as a hex string.
T m_digest[8]
The whole message digest.
Definition: Sha2Impl.h:78
uint64_t m_message_size
The size of the message so far, in bytes.
Definition: Sha2Impl.h:80
size_t m_buffer_fill
The amount of bytes currently stored in the internal buffer.
Definition: Sha2Impl.h:86
unsigned __int64 uint64_t
Definition: msvc_stdint.h:103
unsigned char uint8_t
Definition: msvc_stdint.h:91
Sha2Impl()
Initializes the internal state.
static const size_t cMESSAGE_BLOCK_SIZE
The message block size in bytes.
Definition: Sha2Impl.h:56
std::string String
Definition: BaseTypes.h:43
void clear()
Clears the internal state. A new hash can then be calculated.
Contains Interface base classes and base types.
static const size_t cMESSAGE_PAD_POSITION
Definition: Sha2Impl.h:60


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58