ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
picosha2::hash256_one_by_one Class Reference

#include <picosha2.h>

Collaboration diagram for picosha2::hash256_one_by_one:

Public Member Functions

 hash256_one_by_one ()
 
void init ()
 
template<typename RaIter >
void process (RaIter first, RaIter last)
 
void finish ()
 
template<typename OutIter >
void get_hash_bytes (OutIter first, OutIter last) const
 

Private Member Functions

void add_to_data_length (word_t n)
 
void write_data_bit_length (byte_t *begin)
 

Private Attributes

std::vector< byte_tm_buffer_
 
word_t m_data_length_digits_ [4]
 
word_t m_h_ [8]
 

Detailed Description

Definition at line 184 of file picosha2.h.

Constructor & Destructor Documentation

◆ hash256_one_by_one()

picosha2::hash256_one_by_one::hash256_one_by_one ( )
inline

Definition at line 186 of file picosha2.h.

186 {init();}

Member Function Documentation

◆ add_to_data_length()

void picosha2::hash256_one_by_one::add_to_data_length ( word_t  n)
inlineprivate

Definition at line 238 of file picosha2.h.

238  {
239  word_t carry = 0;
240 
241  m_data_length_digits_[0] += n;
242  for (std::size_t i = 0; i < 4; ++i) {
243  m_data_length_digits_[i] += carry;
244  if (m_data_length_digits_[i] >= 65536u) {
245  carry = m_data_length_digits_[i] >> 16;
246  m_data_length_digits_[i] &= 65535u;
247  } else {
248  break;
249  }
250  }
251  }

◆ finish()

void picosha2::hash256_one_by_one::finish ( )
inline

Definition at line 207 of file picosha2.h.

207  {
208  byte_t temp[64];
209 
210  std::fill(temp, temp + 64, 0);
211  std::size_t remains = m_buffer_.size();
212  std::copy(m_buffer_.begin(), m_buffer_.end(), temp);
213  temp[remains] = 0x80;
214 
215  if (remains > 55) {
216  std::fill(temp + remains + 1, temp + 64, 0);
217  detail::hash256_block(m_h_, temp, temp + 64);
218  std::fill(temp, temp + 64 - 4, 0);
219  } else {
220  std::fill(temp + remains + 1, temp + 64 - 4, 0);
221  }
222 
223  write_data_bit_length(&(temp[56]));
224  detail::hash256_block(m_h_, temp, temp + 64);
225  }

◆ get_hash_bytes()

template<typename OutIter >
void picosha2::hash256_one_by_one::get_hash_bytes ( OutIter  first,
OutIter  last 
) const
inline

Definition at line 228 of file picosha2.h.

228  {
229  for (const word_t* iter = m_h_; iter != m_h_ + 8; ++iter) {
230  for (std::size_t i = 0; i < 4 && first != last; ++i) {
231  *(first++) = detail::mask_8bit(
232  static_cast<byte_t>((*iter >> (24 - 8 * i))));
233  }
234  }
235  }

◆ init()

void picosha2::hash256_one_by_one::init ( )
inline

Definition at line 188 of file picosha2.h.

◆ process()

template<typename RaIter >
void picosha2::hash256_one_by_one::process ( RaIter  first,
RaIter  last 
)
inline

Definition at line 196 of file picosha2.h.

196  {
197  add_to_data_length(static_cast<word_t>(std::distance(first, last)));
198  std::copy(first, last, std::back_inserter(m_buffer_));
199  std::size_t i = 0;
200  for (; i + 64 <= m_buffer_.size(); i += 64) {
202  m_buffer_.begin() + i + 64);
203  }
204  m_buffer_.erase(m_buffer_.begin(), m_buffer_.begin() + i);
205  }

◆ write_data_bit_length()

void picosha2::hash256_one_by_one::write_data_bit_length ( byte_t begin)
inlineprivate

Definition at line 253 of file picosha2.h.

253  {
254  word_t data_bit_length_digits[4];
255 
257  data_bit_length_digits);
258 
259  // convert byte length to bit length (multiply 8 or shift 3 times left)
260  word_t carry = 0;
261  for (std::size_t i = 0; i < 4; ++i) {
262  word_t before_val = data_bit_length_digits[i];
263  data_bit_length_digits[i] <<= 3;
264  data_bit_length_digits[i] |= carry;
265  data_bit_length_digits[i] &= 65535u;
266  carry = (before_val >> (16 - 3)) & 65535u;
267  }
268 
269  // write data_bit_length
270  for (int i = 3; i >= 0; --i) {
271  (*begin++) = static_cast<byte_t>(data_bit_length_digits[i] >> 8);
272  (*begin++) = static_cast<byte_t>(data_bit_length_digits[i]);
273  }
274  }

Member Data Documentation

◆ m_buffer_

std::vector<byte_t> picosha2::hash256_one_by_one::m_buffer_
private

Definition at line 276 of file picosha2.h.

◆ m_data_length_digits_

word_t picosha2::hash256_one_by_one::m_data_length_digits_[4]
private

Definition at line 277 of file picosha2.h.

◆ m_h_

word_t picosha2::hash256_one_by_one::m_h_[8]
private

Definition at line 278 of file picosha2.h.


The documentation for this class was generated from the following file:
picosha2::hash256_one_by_one::m_data_length_digits_
word_t m_data_length_digits_[4]
Definition: picosha2.h:277
picosha2::hash256_one_by_one::m_h_
word_t m_h_[8]
Definition: picosha2.h:278
picosha2::byte_t
unsigned char byte_t
Definition: picosha2.h:41
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
picosha2::detail::initial_message_digest
const word_t initial_message_digest[8]
Definition: picosha2.h:64
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
picosha2::hash256_one_by_one::add_to_data_length
void add_to_data_length(word_t n)
Definition: picosha2.h:238
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
picosha2::detail::hash256_block
void hash256_block(RaIter1 message_digest, RaIter2 first, RaIter2 last)
Definition: picosha2.h:95
picosha2::word_t
unsigned long word_t
Definition: picosha2.h:40
picosha2::hash256_one_by_one::write_data_bit_length
void write_data_bit_length(byte_t *begin)
Definition: picosha2.h:253
lumiFormat.fill
fill
Definition: lumiFormat.py:111
picosha2::hash256_one_by_one::m_buffer_
std::vector< byte_t > m_buffer_
Definition: picosha2.h:276
DeMoScan.first
bool first
Definition: DeMoScan.py:534
picosha2::detail::mask_8bit
byte_t mask_8bit(byte_t x)
Definition: picosha2.h:46
calibdata.copy
bool copy
Definition: calibdata.py:27
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
picosha2::hash256_one_by_one::init
void init()
Definition: picosha2.h:188