Belle II Software  release-05-02-19
Hash.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <vector>
14 
16 struct KeccakHashInstance;
17 
18 namespace Belle2 {
25  class SHA3Hash {
26  public:
28  enum EHashMode {
29  c_SHA3_224 = 224 / 8,
30  c_SHA3_256 = 256 / 8,
31  c_SHA3_384 = 384 / 8,
32  c_SHA3_512 = 512 / 8
33  };
35  explicit SHA3Hash(EHashMode length);
37  SHA3Hash(const SHA3Hash&) = delete;
39  ~SHA3Hash();
41  void clear();
43  void update(int n, unsigned char* buff);
48  void getHash(unsigned char* buff);
50  std::vector<unsigned char> getHash();
51  private:
56  };
57 
60  class ShakeHash {
61  public:
63  enum EHashMode {
66  };
68  explicit ShakeHash(EHashMode mode);
70  ShakeHash(const ShakeHash&) = delete;
72  ~ShakeHash();
74  void clear();
76  void update(int n, unsigned char* buff);
78  void getHash(int n, unsigned char* buff);
79  private:
84  };
86 } //Belle2 namespace
Belle2::ShakeHash::c_SHAKE256
@ c_SHAKE256
variable hash size with up to 256 bit collision resistance
Definition: Hash.h:65
KeccakHashInstance
Since we cannot forward declare the memory structure directly due to some typedeffing we inherit from...
Definition: Hash.cc:19
Belle2::SHA3Hash::update
void update(int n, unsigned char *buff)
update the internal state by adding n bytes of data from buff
Definition: Hash.cc:59
Belle2::ShakeHash::EHashMode
EHashMode
Available hash modes according to FIPS 202 draft.
Definition: Hash.h:63
Belle2::SHA3Hash::c_SHA3_512
@ c_SHA3_512
384bit output size
Definition: Hash.h:32
Belle2::ShakeHash::getHash
void getHash(int n, unsigned char *buff)
obtain the hash value with a length of n bytes into buff
Definition: Hash.cc:107
Belle2::SHA3Hash
Simple interface to calculate SHA3 hash sum (FIPS 202 draft) with fixed size from given data inputs.
Definition: Hash.h:25
Belle2::SHA3Hash::EHashMode
EHashMode
Available hash modes according to FIPS 202 draft.
Definition: Hash.h:28
Belle2::ShakeHash::~ShakeHash
~ShakeHash()
destructor freeing the memory
Definition: Hash.cc:82
Belle2::ShakeHash
Simple interface to calculate SHAKE256 hash sum (FIPS 202 draft) with variable size from given data i...
Definition: Hash.h:60
Belle2::SHA3Hash::clear
void clear()
reinit the hash structure to create a new hash sum
Definition: Hash.cc:38
Belle2::SHA3Hash::c_SHA3_256
@ c_SHA3_256
224bit output size
Definition: Hash.h:30
Belle2::ShakeHash::m_instance
KeccakHashInstance * m_instance
memory structure to calculate the hash value
Definition: Hash.h:81
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SHA3Hash::m_instance
KeccakHashInstance * m_instance
memory structure to calculate the hash value
Definition: Hash.h:53
Belle2::SHA3Hash::m_mode
EHashMode m_mode
chosen hash mode
Definition: Hash.h:55
Belle2::ShakeHash::ShakeHash
ShakeHash(EHashMode mode)
constructor initializing the hash structure
Definition: Hash.cc:76
Belle2::SHA3Hash::SHA3Hash
SHA3Hash(EHashMode length)
Constructor initializing the hash structure with a given output size.
Definition: Hash.cc:27
Belle2::SHA3Hash::c_SHA3_384
@ c_SHA3_384
256bit output size
Definition: Hash.h:31
Belle2::SHA3Hash::~SHA3Hash
~SHA3Hash()
destructor freeing the memory
Definition: Hash.cc:33
Belle2::ShakeHash::c_SHAKE128
@ c_SHAKE128
variable hash size with up to 128 bit collision resistance
Definition: Hash.h:64
Belle2::ShakeHash::m_mode
EHashMode m_mode
chosen hash mode
Definition: Hash.h:83
Belle2::SHA3Hash::getHash
std::vector< unsigned char > getHash()
obtain the hash value as a vector of unsigned char
Definition: Hash.cc:69