ATLAS Offline Software
Functions | Variables
picosha2::detail Namespace Reference

Functions

byte_t mask_8bit (byte_t x)
 
word_t mask_32bit (word_t x)
 
word_t ch (word_t x, word_t y, word_t z)
 
word_t maj (word_t x, word_t y, word_t z)
 
word_t rotr (word_t x, std::size_t n)
 
word_t bsig0 (word_t x)
 
word_t bsig1 (word_t x)
 
word_t shr (word_t x, std::size_t n)
 
word_t ssig0 (word_t x)
 
word_t ssig1 (word_t x)
 
template<typename RaIter1 , typename RaIter2 >
void hash256_block (RaIter1 message_digest, RaIter2 first, RaIter2 last)
 

Variables

const word_t add_constant [64]
 
const word_t initial_message_digest [8]
 

Function Documentation

◆ bsig0()

word_t picosha2::detail::bsig0 ( word_t  x)
inline

Definition at line 81 of file picosha2.h.

81 {return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);}

◆ bsig1()

word_t picosha2::detail::bsig1 ( word_t  x)
inline

Definition at line 83 of file picosha2.h.

83 {return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);}

◆ ch()

word_t picosha2::detail::ch ( word_t  x,
word_t  y,
word_t  z 
)
inline

Definition at line 70 of file picosha2.h.

70 {return (x & y) ^ ((~x) & z);}

◆ hash256_block()

template<typename RaIter1 , typename RaIter2 >
void picosha2::detail::hash256_block ( RaIter1  message_digest,
RaIter2  first,
RaIter2  last 
)

Definition at line 95 of file picosha2.h.

95  {
96  assert(first + 64 == last);
97  static_cast<void>(last); // for avoiding unused-variable warning
98  word_t w[64];
99  std::fill(w, w + 64, 0);
100  for (std::size_t i = 0; i < 16; ++i) {
101  w[i] = (static_cast<word_t>(mask_8bit(*(first + i * 4))) << 24) |
102  (static_cast<word_t>(mask_8bit(*(first + i * 4 + 1))) << 16) |
103  (static_cast<word_t>(mask_8bit(*(first + i * 4 + 2))) << 8) |
104  (static_cast<word_t>(mask_8bit(*(first + i * 4 + 3))));
105  }
106  for (std::size_t i = 16; i < 64; ++i) {
107  w[i] = mask_32bit(ssig1(w[i - 2]) + w[i - 7] + ssig0(w[i - 15]) +
108  w[i - 16]);
109  }
110 
111  word_t a = *message_digest;
112  word_t b = *(message_digest + 1);
113  word_t c = *(message_digest + 2);
114  word_t d = *(message_digest + 3);
115  word_t e = *(message_digest + 4);
116  word_t f = *(message_digest + 5);
117  word_t g = *(message_digest + 6);
118  word_t h = *(message_digest + 7);
119 
120  for (std::size_t i = 0; i < 64; ++i) {
121  word_t temp1 = h + bsig1(e) + ch(e, f, g) + add_constant[i] + w[i];
122  word_t temp2 = bsig0(a) + maj(a, b, c);
123  h = g;
124  g = f;
125  f = e;
126  e = mask_32bit(d + temp1);
127  d = c;
128  c = b;
129  b = a;
130  a = mask_32bit(temp1 + temp2);
131  }
132  *message_digest += a;
133  *(message_digest + 1) += b;
134  *(message_digest + 2) += c;
135  *(message_digest + 3) += d;
136  *(message_digest + 4) += e;
137  *(message_digest + 5) += f;
138  *(message_digest + 6) += g;
139  *(message_digest + 7) += h;
140  for (std::size_t i = 0; i < 8; ++i) {
141  *(message_digest + i) = mask_32bit(*(message_digest + i));
142  }
143  }

◆ maj()

word_t picosha2::detail::maj ( word_t  x,
word_t  y,
word_t  z 
)
inline

Definition at line 72 of file picosha2.h.

72  {
73  return (x & y) ^ (x & z) ^ (y & z);
74  }

◆ mask_32bit()

word_t picosha2::detail::mask_32bit ( word_t  x)
inline

Definition at line 48 of file picosha2.h.

48 {return x & 0xffffffff;}

◆ mask_8bit()

byte_t picosha2::detail::mask_8bit ( byte_t  x)
inline

Definition at line 46 of file picosha2.h.

46 {return x & 0xff;}

◆ rotr()

word_t picosha2::detail::rotr ( word_t  x,
std::size_t  n 
)
inline

Definition at line 76 of file picosha2.h.

76  {
77  assert(n < 32);
78  return mask_32bit((x >> n) | (x << (32 - n)));
79  }

◆ shr()

word_t picosha2::detail::shr ( word_t  x,
std::size_t  n 
)
inline

Definition at line 85 of file picosha2.h.

85  {
86  assert(n < 32);
87  return x >> n;
88  }

◆ ssig0()

word_t picosha2::detail::ssig0 ( word_t  x)
inline

Definition at line 90 of file picosha2.h.

90 {return rotr(x, 7) ^ rotr(x, 18) ^ shr(x, 3);}

◆ ssig1()

word_t picosha2::detail::ssig1 ( word_t  x)
inline

Definition at line 92 of file picosha2.h.

92 {return rotr(x, 17) ^ rotr(x, 19) ^ shr(x, 10);}

Variable Documentation

◆ add_constant

const word_t picosha2::detail::add_constant[64]
Initial value:
= {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1,
0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786,
0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147,
0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b,
0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a,
0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
}

Definition at line 50 of file picosha2.h.

◆ initial_message_digest

const word_t picosha2::detail::initial_message_digest[8]
Initial value:
= {
0x6a09e667, 0xbb67ae85, 0x3c6ef372,
0xa54ff53a, 0x510e527f, 0x9b05688c,
0x1f83d9ab, 0x5be0cd19
}

Definition at line 64 of file picosha2.h.

AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
picosha2::detail::bsig1
word_t bsig1(word_t x)
Definition: picosha2.h:83
picosha2::detail::maj
word_t maj(word_t x, word_t y, word_t z)
Definition: picosha2.h:72
hist_file_dump.d
d
Definition: hist_file_dump.py:137
picosha2::detail::shr
word_t shr(word_t x, std::size_t n)
Definition: picosha2.h:85
x
#define x
picosha2::detail::bsig0
word_t bsig0(word_t x)
Definition: picosha2.h:81
lumiFormat.i
int i
Definition: lumiFormat.py:85
z
#define z
beamspotman.n
n
Definition: beamspotman.py:731
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
picosha2::detail::mask_32bit
word_t mask_32bit(word_t x)
Definition: picosha2.h:48
hist_file_dump.f
f
Definition: hist_file_dump.py:135
picosha2::word_t
unsigned long word_t
Definition: picosha2.h:40
fill
void fill(H5::Group &out_file, size_t iterations)
Definition: test-hdf5-writer.cxx:95
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
picosha2::detail::ch
word_t ch(word_t x, word_t y, word_t z)
Definition: picosha2.h:70
picosha2::detail::ssig0
word_t ssig0(word_t x)
Definition: picosha2.h:90
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
h
DeMoScan.first
bool first
Definition: DeMoScan.py:536
picosha2::detail::mask_8bit
byte_t mask_8bit(byte_t x)
Definition: picosha2.h:46
picosha2::detail::add_constant
const word_t add_constant[64]
Definition: picosha2.h:50
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
python.compressB64.c
def c
Definition: compressB64.py:93
picosha2::detail::ssig1
word_t ssig1(word_t x)
Definition: picosha2.h:92
picosha2::detail::rotr
word_t rotr(word_t x, std::size_t n)
Definition: picosha2.h:76