Coverage Report

Created: 2024-11-21 07:03

/src/cryptopp/iterhash.cpp
Line
Count
Source (jump to first uncovered line)
1
// iterhash.cpp - originally written and placed in the public domain by Wei Dai
2
3
#ifndef __GNUC__
4
#define CRYPTOPP_MANUALLY_INSTANTIATE_TEMPLATES
5
#endif
6
7
#include "iterhash.h"
8
#include "misc.h"
9
#include "cpu.h"
10
11
NAMESPACE_BEGIN(CryptoPP)
12
13
template <class T, class BASE> void IteratedHashBase<T, BASE>::Update(const byte *input, size_t length)
14
1.06M
{
15
1.06M
  CRYPTOPP_ASSERT(!(input == NULLPTR && length != 0));
16
1.06M
  if (length == 0) { return; }
17
18
758k
  HashWordType oldCountLo = m_countLo, oldCountHi = m_countHi;
19
758k
  if ((m_countLo = oldCountLo + HashWordType(length)) < oldCountLo)
20
0
    m_countHi++;             // carry from low to high
21
758k
  m_countHi += (HashWordType)SafeRightShift<8*sizeof(HashWordType)>(length);
22
758k
  if (m_countHi < oldCountHi || SafeRightShift<2*8*sizeof(HashWordType)>(length) != 0)
23
0
    throw HashInputTooLong(this->AlgorithmName());
24
25
758k
  const unsigned int blockSize = this->BlockSize();
26
758k
  unsigned int num = ModPowerOf2(oldCountLo, blockSize);
27
28
758k
  T* dataBuf = this->DataBuf();
29
758k
  byte* data = (byte *)dataBuf;
30
31
758k
  if (num != 0)  // process left over data
32
259k
  {
33
259k
    if (num+length >= blockSize)
34
37.0k
    {
35
37.0k
      if (input)
36
37.0k
        {std::memcpy(data+num, input, blockSize-num);}
37
38
37.0k
      HashBlock(dataBuf);
39
37.0k
      input += (blockSize-num);
40
37.0k
      length -= (blockSize-num);
41
37.0k
      num = 0;
42
      // drop through and do the rest
43
37.0k
    }
44
222k
    else
45
222k
    {
46
222k
      if (input && length)
47
222k
        {std::memcpy(data+num, input, length);}
48
222k
      return;
49
222k
    }
50
259k
  }
51
52
  // now process the input data in blocks of blockSize bytes and save the leftovers to m_data
53
535k
  if (length >= blockSize)
54
320k
  {
55
320k
    if (input == data)
56
0
    {
57
0
      CRYPTOPP_ASSERT(length == blockSize);
58
0
      HashBlock(dataBuf);
59
0
      return;
60
0
    }
61
320k
    else if (IsAligned<T>(input))
62
320k
    {
63
320k
      size_t leftOver = HashMultipleBlocks((T *)(void*)input, length);
64
320k
      input += (length - leftOver);
65
320k
      length = leftOver;
66
320k
    }
67
25
    else
68
25
    {
69
25
      do
70
4.19k
      {   // copy input first if it's not aligned correctly
71
4.19k
        if (input)
72
4.19k
          { std::memcpy(data, input, blockSize); }
73
74
4.19k
        HashBlock(dataBuf);
75
4.19k
        input+=blockSize;
76
4.19k
        length-=blockSize;
77
4.19k
      } while (length >= blockSize);
78
25
    }
79
320k
  }
80
81
535k
  if (input && data != input)
82
535k
    std::memcpy(data, input, length);
83
535k
}
CryptoPP::IteratedHashBase<unsigned long, CryptoPP::HashTransformation>::Update(unsigned char const*, unsigned long)
Line
Count
Source
14
266k
{
15
266k
  CRYPTOPP_ASSERT(!(input == NULLPTR && length != 0));
16
266k
  if (length == 0) { return; }
17
18
150k
  HashWordType oldCountLo = m_countLo, oldCountHi = m_countHi;
19
150k
  if ((m_countLo = oldCountLo + HashWordType(length)) < oldCountLo)
20
0
    m_countHi++;             // carry from low to high
21
150k
  m_countHi += (HashWordType)SafeRightShift<8*sizeof(HashWordType)>(length);
22
150k
  if (m_countHi < oldCountHi || SafeRightShift<2*8*sizeof(HashWordType)>(length) != 0)
23
0
    throw HashInputTooLong(this->AlgorithmName());
24
25
150k
  const unsigned int blockSize = this->BlockSize();
26
150k
  unsigned int num = ModPowerOf2(oldCountLo, blockSize);
27
28
150k
  T* dataBuf = this->DataBuf();
29
150k
  byte* data = (byte *)dataBuf;
30
31
150k
  if (num != 0)  // process left over data
32
40.1k
  {
33
40.1k
    if (num+length >= blockSize)
34
9.77k
    {
35
9.77k
      if (input)
36
9.77k
        {std::memcpy(data+num, input, blockSize-num);}
37
38
9.77k
      HashBlock(dataBuf);
39
9.77k
      input += (blockSize-num);
40
9.77k
      length -= (blockSize-num);
41
9.77k
      num = 0;
42
      // drop through and do the rest
43
9.77k
    }
44
30.4k
    else
45
30.4k
    {
46
30.4k
      if (input && length)
47
30.4k
        {std::memcpy(data+num, input, length);}
48
30.4k
      return;
49
30.4k
    }
50
40.1k
  }
51
52
  // now process the input data in blocks of blockSize bytes and save the leftovers to m_data
53
120k
  if (length >= blockSize)
54
79.2k
  {
55
79.2k
    if (input == data)
56
0
    {
57
0
      CRYPTOPP_ASSERT(length == blockSize);
58
0
      HashBlock(dataBuf);
59
0
      return;
60
0
    }
61
79.2k
    else if (IsAligned<T>(input))
62
79.2k
    {
63
79.2k
      size_t leftOver = HashMultipleBlocks((T *)(void*)input, length);
64
79.2k
      input += (length - leftOver);
65
79.2k
      length = leftOver;
66
79.2k
    }
67
11
    else
68
11
    {
69
11
      do
70
1.66k
      {   // copy input first if it's not aligned correctly
71
1.66k
        if (input)
72
1.66k
          { std::memcpy(data, input, blockSize); }
73
74
1.66k
        HashBlock(dataBuf);
75
1.66k
        input+=blockSize;
76
1.66k
        length-=blockSize;
77
1.66k
      } while (length >= blockSize);
78
11
    }
79
79.2k
  }
80
81
120k
  if (input && data != input)
82
120k
    std::memcpy(data, input, length);
83
120k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned long, CryptoPP::MessageAuthenticationCode>::Update(unsigned char const*, unsigned long)
CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>::Update(unsigned char const*, unsigned long)
Line
Count
Source
14
803k
{
15
803k
  CRYPTOPP_ASSERT(!(input == NULLPTR && length != 0));
16
803k
  if (length == 0) { return; }
17
18
607k
  HashWordType oldCountLo = m_countLo, oldCountHi = m_countHi;
19
607k
  if ((m_countLo = oldCountLo + HashWordType(length)) < oldCountLo)
20
0
    m_countHi++;             // carry from low to high
21
607k
  m_countHi += (HashWordType)SafeRightShift<8*sizeof(HashWordType)>(length);
22
607k
  if (m_countHi < oldCountHi || SafeRightShift<2*8*sizeof(HashWordType)>(length) != 0)
23
0
    throw HashInputTooLong(this->AlgorithmName());
24
25
607k
  const unsigned int blockSize = this->BlockSize();
26
607k
  unsigned int num = ModPowerOf2(oldCountLo, blockSize);
27
28
607k
  T* dataBuf = this->DataBuf();
29
607k
  byte* data = (byte *)dataBuf;
30
31
607k
  if (num != 0)  // process left over data
32
219k
  {
33
219k
    if (num+length >= blockSize)
34
27.2k
    {
35
27.2k
      if (input)
36
27.2k
        {std::memcpy(data+num, input, blockSize-num);}
37
38
27.2k
      HashBlock(dataBuf);
39
27.2k
      input += (blockSize-num);
40
27.2k
      length -= (blockSize-num);
41
27.2k
      num = 0;
42
      // drop through and do the rest
43
27.2k
    }
44
192k
    else
45
192k
    {
46
192k
      if (input && length)
47
192k
        {std::memcpy(data+num, input, length);}
48
192k
      return;
49
192k
    }
50
219k
  }
51
52
  // now process the input data in blocks of blockSize bytes and save the leftovers to m_data
53
415k
  if (length >= blockSize)
54
240k
  {
55
240k
    if (input == data)
56
0
    {
57
0
      CRYPTOPP_ASSERT(length == blockSize);
58
0
      HashBlock(dataBuf);
59
0
      return;
60
0
    }
61
240k
    else if (IsAligned<T>(input))
62
240k
    {
63
240k
      size_t leftOver = HashMultipleBlocks((T *)(void*)input, length);
64
240k
      input += (length - leftOver);
65
240k
      length = leftOver;
66
240k
    }
67
14
    else
68
14
    {
69
14
      do
70
2.52k
      {   // copy input first if it's not aligned correctly
71
2.52k
        if (input)
72
2.52k
          { std::memcpy(data, input, blockSize); }
73
74
2.52k
        HashBlock(dataBuf);
75
2.52k
        input+=blockSize;
76
2.52k
        length-=blockSize;
77
2.52k
      } while (length >= blockSize);
78
14
    }
79
240k
  }
80
81
415k
  if (input && data != input)
82
415k
    std::memcpy(data, input, length);
83
415k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned int, CryptoPP::MessageAuthenticationCode>::Update(unsigned char const*, unsigned long)
84
85
template <class T, class BASE> byte * IteratedHashBase<T, BASE>::CreateUpdateSpace(size_t &size)
86
0
{
87
0
  unsigned int blockSize = this->BlockSize();
88
0
  unsigned int num = ModPowerOf2(m_countLo, blockSize);
89
0
  size = blockSize - num;
90
0
  return (byte *)DataBuf() + num;
91
0
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned long, CryptoPP::HashTransformation>::CreateUpdateSpace(unsigned long&)
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned long, CryptoPP::MessageAuthenticationCode>::CreateUpdateSpace(unsigned long&)
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>::CreateUpdateSpace(unsigned long&)
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned int, CryptoPP::MessageAuthenticationCode>::CreateUpdateSpace(unsigned long&)
92
93
template <class T, class BASE> size_t IteratedHashBase<T, BASE>::HashMultipleBlocks(const T *input, size_t length)
94
323k
{
95
323k
  const unsigned int blockSize = this->BlockSize();
96
323k
  bool noReverse = NativeByteOrderIs(this->GetByteOrder());
97
323k
  T* dataBuf = this->DataBuf();
98
99
  // Alignment checks due to http://github.com/weidai11/cryptopp/issues/690.
100
  // Sparc requires 8-byte aligned buffer when HashWordType is word64.
101
  // We also had to provide a GetAlignmentOf specialization for word64 on Sparc.
102
103
323k
  do
104
5.77M
  {
105
5.77M
    if (noReverse)
106
4.61M
    {
107
4.61M
      if (IsAligned<HashWordType>(input))
108
4.61M
      {
109
        // Sparc bus error with non-aligned input.
110
4.61M
        this->HashEndianCorrectedBlock(input);
111
4.61M
      }
112
0
      else
113
0
      {
114
0
        std::memcpy(dataBuf, input, blockSize);
115
0
        this->HashEndianCorrectedBlock(dataBuf);
116
0
      }
117
4.61M
    }
118
1.15M
    else
119
1.15M
    {
120
1.15M
      if (IsAligned<HashWordType>(input))
121
1.15M
      {
122
        // Sparc bus error with non-aligned input.
123
1.15M
        ByteReverse(dataBuf, input, blockSize);
124
1.15M
        this->HashEndianCorrectedBlock(dataBuf);
125
1.15M
      }
126
0
      else
127
0
      {
128
0
        std::memcpy(dataBuf, input, blockSize);
129
0
        ByteReverse(dataBuf, dataBuf, blockSize);
130
0
        this->HashEndianCorrectedBlock(dataBuf);
131
0
      }
132
1.15M
    }
133
134
5.77M
    input += blockSize/sizeof(T);
135
5.77M
    length -= blockSize;
136
5.77M
  }
137
5.77M
  while (length >= blockSize);
138
323k
  return length;
139
323k
}
CryptoPP::IteratedHashBase<unsigned long, CryptoPP::HashTransformation>::HashMultipleBlocks(unsigned long const*, unsigned long)
Line
Count
Source
94
124k
{
95
124k
  const unsigned int blockSize = this->BlockSize();
96
124k
  bool noReverse = NativeByteOrderIs(this->GetByteOrder());
97
124k
  T* dataBuf = this->DataBuf();
98
99
  // Alignment checks due to http://github.com/weidai11/cryptopp/issues/690.
100
  // Sparc requires 8-byte aligned buffer when HashWordType is word64.
101
  // We also had to provide a GetAlignmentOf specialization for word64 on Sparc.
102
103
124k
  do
104
1.72M
  {
105
1.72M
    if (noReverse)
106
562k
    {
107
562k
      if (IsAligned<HashWordType>(input))
108
562k
      {
109
        // Sparc bus error with non-aligned input.
110
562k
        this->HashEndianCorrectedBlock(input);
111
562k
      }
112
0
      else
113
0
      {
114
0
        std::memcpy(dataBuf, input, blockSize);
115
0
        this->HashEndianCorrectedBlock(dataBuf);
116
0
      }
117
562k
    }
118
1.15M
    else
119
1.15M
    {
120
1.15M
      if (IsAligned<HashWordType>(input))
121
1.15M
      {
122
        // Sparc bus error with non-aligned input.
123
1.15M
        ByteReverse(dataBuf, input, blockSize);
124
1.15M
        this->HashEndianCorrectedBlock(dataBuf);
125
1.15M
      }
126
0
      else
127
0
      {
128
0
        std::memcpy(dataBuf, input, blockSize);
129
0
        ByteReverse(dataBuf, dataBuf, blockSize);
130
0
        this->HashEndianCorrectedBlock(dataBuf);
131
0
      }
132
1.15M
    }
133
134
1.72M
    input += blockSize/sizeof(T);
135
1.72M
    length -= blockSize;
136
1.72M
  }
137
1.72M
  while (length >= blockSize);
138
124k
  return length;
139
124k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned long, CryptoPP::MessageAuthenticationCode>::HashMultipleBlocks(unsigned long const*, unsigned long)
CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>::HashMultipleBlocks(unsigned int const*, unsigned long)
Line
Count
Source
94
199k
{
95
199k
  const unsigned int blockSize = this->BlockSize();
96
199k
  bool noReverse = NativeByteOrderIs(this->GetByteOrder());
97
199k
  T* dataBuf = this->DataBuf();
98
99
  // Alignment checks due to http://github.com/weidai11/cryptopp/issues/690.
100
  // Sparc requires 8-byte aligned buffer when HashWordType is word64.
101
  // We also had to provide a GetAlignmentOf specialization for word64 on Sparc.
102
103
199k
  do
104
4.05M
  {
105
4.05M
    if (noReverse)
106
4.05M
    {
107
4.05M
      if (IsAligned<HashWordType>(input))
108
4.05M
      {
109
        // Sparc bus error with non-aligned input.
110
4.05M
        this->HashEndianCorrectedBlock(input);
111
4.05M
      }
112
0
      else
113
0
      {
114
0
        std::memcpy(dataBuf, input, blockSize);
115
0
        this->HashEndianCorrectedBlock(dataBuf);
116
0
      }
117
4.05M
    }
118
0
    else
119
0
    {
120
0
      if (IsAligned<HashWordType>(input))
121
0
      {
122
        // Sparc bus error with non-aligned input.
123
0
        ByteReverse(dataBuf, input, blockSize);
124
0
        this->HashEndianCorrectedBlock(dataBuf);
125
0
      }
126
0
      else
127
0
      {
128
0
        std::memcpy(dataBuf, input, blockSize);
129
0
        ByteReverse(dataBuf, dataBuf, blockSize);
130
0
        this->HashEndianCorrectedBlock(dataBuf);
131
0
      }
132
0
    }
133
134
4.05M
    input += blockSize/sizeof(T);
135
4.05M
    length -= blockSize;
136
4.05M
  }
137
4.05M
  while (length >= blockSize);
138
199k
  return length;
139
199k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned int, CryptoPP::MessageAuthenticationCode>::HashMultipleBlocks(unsigned int const*, unsigned long)
140
141
template <class T, class BASE> void IteratedHashBase<T, BASE>::PadLastBlock(unsigned int lastBlockSize, byte padFirst)
142
258k
{
143
258k
  unsigned int blockSize = this->BlockSize();
144
258k
  unsigned int num = ModPowerOf2(m_countLo, blockSize);
145
258k
  T* dataBuf = this->DataBuf();
146
258k
  byte* data = (byte *)dataBuf;
147
148
258k
  data[num++] = padFirst;
149
258k
  if (num <= lastBlockSize)
150
246k
    std::memset(data+num, 0, lastBlockSize-num);
151
12.0k
  else
152
12.0k
  {
153
12.0k
    std::memset(data+num, 0, blockSize-num);
154
12.0k
    HashBlock(dataBuf);
155
12.0k
    std::memset(data, 0, lastBlockSize);
156
12.0k
  }
157
258k
}
CryptoPP::IteratedHashBase<unsigned long, CryptoPP::HashTransformation>::PadLastBlock(unsigned int, unsigned char)
Line
Count
Source
142
55.7k
{
143
55.7k
  unsigned int blockSize = this->BlockSize();
144
55.7k
  unsigned int num = ModPowerOf2(m_countLo, blockSize);
145
55.7k
  T* dataBuf = this->DataBuf();
146
55.7k
  byte* data = (byte *)dataBuf;
147
148
55.7k
  data[num++] = padFirst;
149
55.7k
  if (num <= lastBlockSize)
150
50.8k
    std::memset(data+num, 0, lastBlockSize-num);
151
4.97k
  else
152
4.97k
  {
153
4.97k
    std::memset(data+num, 0, blockSize-num);
154
4.97k
    HashBlock(dataBuf);
155
4.97k
    std::memset(data, 0, lastBlockSize);
156
4.97k
  }
157
55.7k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned long, CryptoPP::MessageAuthenticationCode>::PadLastBlock(unsigned int, unsigned char)
CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>::PadLastBlock(unsigned int, unsigned char)
Line
Count
Source
142
203k
{
143
203k
  unsigned int blockSize = this->BlockSize();
144
203k
  unsigned int num = ModPowerOf2(m_countLo, blockSize);
145
203k
  T* dataBuf = this->DataBuf();
146
203k
  byte* data = (byte *)dataBuf;
147
148
203k
  data[num++] = padFirst;
149
203k
  if (num <= lastBlockSize)
150
196k
    std::memset(data+num, 0, lastBlockSize-num);
151
7.08k
  else
152
7.08k
  {
153
7.08k
    std::memset(data+num, 0, blockSize-num);
154
7.08k
    HashBlock(dataBuf);
155
7.08k
    std::memset(data, 0, lastBlockSize);
156
7.08k
  }
157
203k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned int, CryptoPP::MessageAuthenticationCode>::PadLastBlock(unsigned int, unsigned char)
158
159
template <class T, class BASE> void IteratedHashBase<T, BASE>::Restart()
160
258k
{
161
258k
  m_countLo = m_countHi = 0;
162
258k
  Init();
163
258k
}
CryptoPP::IteratedHashBase<unsigned long, CryptoPP::HashTransformation>::Restart()
Line
Count
Source
160
55.7k
{
161
55.7k
  m_countLo = m_countHi = 0;
162
55.7k
  Init();
163
55.7k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned long, CryptoPP::MessageAuthenticationCode>::Restart()
CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>::Restart()
Line
Count
Source
160
203k
{
161
203k
  m_countLo = m_countHi = 0;
162
203k
  Init();
163
203k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned int, CryptoPP::MessageAuthenticationCode>::Restart()
164
165
template <class T, class BASE> void IteratedHashBase<T, BASE>::TruncatedFinal(byte *digest, size_t size)
166
231k
{
167
231k
  CRYPTOPP_ASSERT(digest != NULLPTR);
168
231k
  this->ThrowIfInvalidTruncatedSize(size);
169
170
231k
  T* dataBuf = this->DataBuf();
171
231k
  T* stateBuf = this->StateBuf();
172
231k
  unsigned int blockSize = this->BlockSize();
173
231k
  ByteOrder order = this->GetByteOrder();
174
175
231k
  PadLastBlock(blockSize - 2*sizeof(HashWordType));
176
231k
  dataBuf[blockSize/sizeof(T)-2+order] = ConditionalByteReverse(order, this->GetBitCountLo());
177
231k
  dataBuf[blockSize/sizeof(T)-1-order] = ConditionalByteReverse(order, this->GetBitCountHi());
178
179
231k
  HashBlock(dataBuf);
180
181
231k
  if (IsAligned<HashWordType>(digest) && size%sizeof(HashWordType)==0)
182
231k
    ConditionalByteReverse<HashWordType>(order, (HashWordType *)(void*)digest, stateBuf, size);
183
0
  else
184
0
  {
185
0
    ConditionalByteReverse<HashWordType>(order, stateBuf, stateBuf, this->DigestSize());
186
0
    std::memcpy(digest, stateBuf, size);
187
0
  }
188
189
231k
  this->Restart();    // reinit for next use
190
231k
}
CryptoPP::IteratedHashBase<unsigned long, CryptoPP::HashTransformation>::TruncatedFinal(unsigned char*, unsigned long)
Line
Count
Source
166
28.6k
{
167
28.6k
  CRYPTOPP_ASSERT(digest != NULLPTR);
168
28.6k
  this->ThrowIfInvalidTruncatedSize(size);
169
170
28.6k
  T* dataBuf = this->DataBuf();
171
28.6k
  T* stateBuf = this->StateBuf();
172
28.6k
  unsigned int blockSize = this->BlockSize();
173
28.6k
  ByteOrder order = this->GetByteOrder();
174
175
28.6k
  PadLastBlock(blockSize - 2*sizeof(HashWordType));
176
28.6k
  dataBuf[blockSize/sizeof(T)-2+order] = ConditionalByteReverse(order, this->GetBitCountLo());
177
28.6k
  dataBuf[blockSize/sizeof(T)-1-order] = ConditionalByteReverse(order, this->GetBitCountHi());
178
179
28.6k
  HashBlock(dataBuf);
180
181
28.6k
  if (IsAligned<HashWordType>(digest) && size%sizeof(HashWordType)==0)
182
28.6k
    ConditionalByteReverse<HashWordType>(order, (HashWordType *)(void*)digest, stateBuf, size);
183
0
  else
184
0
  {
185
0
    ConditionalByteReverse<HashWordType>(order, stateBuf, stateBuf, this->DigestSize());
186
0
    std::memcpy(digest, stateBuf, size);
187
0
  }
188
189
28.6k
  this->Restart();    // reinit for next use
190
28.6k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned long, CryptoPP::MessageAuthenticationCode>::TruncatedFinal(unsigned char*, unsigned long)
CryptoPP::IteratedHashBase<unsigned int, CryptoPP::HashTransformation>::TruncatedFinal(unsigned char*, unsigned long)
Line
Count
Source
166
203k
{
167
203k
  CRYPTOPP_ASSERT(digest != NULLPTR);
168
203k
  this->ThrowIfInvalidTruncatedSize(size);
169
170
203k
  T* dataBuf = this->DataBuf();
171
203k
  T* stateBuf = this->StateBuf();
172
203k
  unsigned int blockSize = this->BlockSize();
173
203k
  ByteOrder order = this->GetByteOrder();
174
175
203k
  PadLastBlock(blockSize - 2*sizeof(HashWordType));
176
203k
  dataBuf[blockSize/sizeof(T)-2+order] = ConditionalByteReverse(order, this->GetBitCountLo());
177
203k
  dataBuf[blockSize/sizeof(T)-1-order] = ConditionalByteReverse(order, this->GetBitCountHi());
178
179
203k
  HashBlock(dataBuf);
180
181
203k
  if (IsAligned<HashWordType>(digest) && size%sizeof(HashWordType)==0)
182
203k
    ConditionalByteReverse<HashWordType>(order, (HashWordType *)(void*)digest, stateBuf, size);
183
0
  else
184
0
  {
185
0
    ConditionalByteReverse<HashWordType>(order, stateBuf, stateBuf, this->DigestSize());
186
0
    std::memcpy(digest, stateBuf, size);
187
0
  }
188
189
203k
  this->Restart();    // reinit for next use
190
203k
}
Unexecuted instantiation: CryptoPP::IteratedHashBase<unsigned int, CryptoPP::MessageAuthenticationCode>::TruncatedFinal(unsigned char*, unsigned long)
191
192
#if defined(__GNUC__) || defined(__clang__)
193
  template class IteratedHashBase<word64, HashTransformation>;
194
  template class IteratedHashBase<word64, MessageAuthenticationCode>;
195
196
  template class IteratedHashBase<word32, HashTransformation>;
197
  template class IteratedHashBase<word32, MessageAuthenticationCode>;
198
#endif
199
200
NAMESPACE_END