Go to the documentation of this file.
41 #if defined (__GLIBC__)
51 static const unsigned char fillbuf[64] = { 0x80, 0 };
60 # if (__BYTE_ORDER == __BIG_ENDIAN)
66 | (((
n) & 0xff00) << 8)
67 | (((
n) >> 8) & 0xff00)
74 const short x = 0x0100;
77 if (*(
reinterpret_cast<const char*
>(&
x)))
86 | (((
n) & 0xff00) << 8)
87 | (((
n) >> 8) & 0xff00)
97 memcpy(
cp, &v,
sizeof(uint32_t));
114 size_t remaining = bufLen_;
117 sizeof(buffer_) - remaining > len
119 :
sizeof(buffer_) - remaining
122 unsigned char* bufp =
reinterpret_cast<unsigned char*
>(buffer_);
124 memcpy(&bufp[remaining],
data,
add);
129 processBlock(buffer_, bufLen_ & ~63);
134 memcpy(buffer_, &bufp[(remaining +
add) & ~63], bufLen_);
137 data =
reinterpret_cast<const unsigned char*
>(
data) +
add;
144 processBlock(memcpy(buffer_,
data, 64), 64);
145 data =
reinterpret_cast<const unsigned char*
>(
data) + 64;
152 unsigned char* bufp =
reinterpret_cast<unsigned char*
>(buffer_);
153 size_t remaining = bufLen_;
155 memcpy (&bufp[remaining],
data, len);
159 processBlock(buffer_, 64);
161 memcpy(buffer_, &buffer_[16], remaining);
169 #define K1 0x5a827999
170 #define K2 0x6ed9eba1
171 #define K3 0x8f1bbcdc
172 #define K4 0xca62c1d6
175 #define F1(B,C,D) ( D ^ ( B & ( C ^ D ) ) )
176 #define F2(B,C,D) (B ^ C ^ D)
177 #define F3(B,C,D) ( ( B & C ) | ( D & ( B | C ) ) )
178 #define F4(B,C,D) (B ^ C ^ D)
185 const uint32_t *words =
reinterpret_cast<const uint32_t*
>(
data);
186 size_t nwords = len /
sizeof(uint32_t);
187 const uint32_t *endp = words + nwords;
191 uint32_t a = hashsumA_;
192 uint32_t
b = hashsumB_;
193 uint32_t
c = hashsumC_;
194 uint32_t d = hashsumD_;
195 uint32_t
e = hashsumE_;
201 if (bufTotal_[0] < len)
207 #define rol_uint32(x, nbits) (((x) << (nbits)) | ((x) >> (32 - (nbits))))
209 #define M(I) ( tm = x[I & 0x0F] ^ x[(I-14) & 0x0F] \
210 ^ x[(I-8) & 0x0F] ^ x[(I-3) & 0x0F] \
211 , (x[I & 0x0F] = rol_uint32(tm, 1)) )
213 #define R(A,B,C,D,E,F,K,M) \
216 E += rol_uint32(A, 5) + F(B, C, D) + K + M; \
217 B = rol_uint32(B, 30); \
223 for (
int t = 0; t < 16; ++t)
225 x[t] = swapBytes(*words);
321 if (bufTotal_[0] || bufTotal_[1])
323 unsigned char *r = dig.
v_;
325 set_uint32(r + 0 *
sizeof(uint32_t), swapBytes(hashsumA_));
326 set_uint32(r + 1 *
sizeof(uint32_t), swapBytes(hashsumB_));
327 set_uint32(r + 2 *
sizeof(uint32_t), swapBytes(hashsumC_));
328 set_uint32(r + 3 *
sizeof(uint32_t), swapBytes(hashsumD_));
329 set_uint32(r + 4 *
sizeof(uint32_t), swapBytes(hashsumE_));
343 hashsumA_ = 0x67452301;
344 hashsumB_ = 0xefcdab89;
345 hashsumC_ = 0x98badcfe;
346 hashsumD_ = 0x10325476;
347 hashsumE_ = 0xc3d2e1f0;
349 bufTotal_[0] = bufTotal_[1] = 0;
363 uint32_t bytes = bufLen_;
364 size_t size = (bytes < 56 ? 64 : 128) /
sizeof(uint32_t);
367 bufTotal_[0] += bytes;
368 if (bufTotal_[0] < bytes)
374 if (!bufTotal_[0] && !bufTotal_[1])
380 buffer_[size-2] = swapBytes((bufTotal_[1] << 3) | (bufTotal_[0] >> 29));
381 buffer_[size-1] = swapBytes(bufTotal_[0] << 3);
383 unsigned char* bufp =
reinterpret_cast<unsigned char *
>(buffer_);
385 memcpy(&bufp[bytes], fillbuf, (size-2) *
sizeof(uint32_t) - bytes);
388 processBlock(buffer_, size *
sizeof(uint32_t));
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Functions to compute SHA1 message digest according to the NIST specification FIPS-180-1.
void clear()
Reset the digest to zero.
void processBytes(const void *data, size_t len)
Process for the next LEN bytes, LEN need not be a multiple of 64.
bool cp(const fileName &src, const fileName &dst)
Copy, recursively if necessary, the source to the destination.
void calcDigest(SHA1Digest &) const
Calculate current digest from appended data.
#define R(A, B, C, D, E, F, K, M)
unsigned char v_[length]
The digest contents.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
static void set_uint32(unsigned char *cp, uint32_t)
Copy the 4-byte value into the memory location pointed to by *dst.
const double e
Elementary charge.
SHA1Digest digest() const
Calculate current digest from appended data.
void processBlock(const void *data, size_t len)
Process data block-wise, LEN must be a multiple of 64!
void clear()
Reset the hashed data before appending more.
const dimensionedScalar c
Speed of light in a vacuum.
bool finalize()
Finalized the calculations (normally not needed directly).
static uint32_t swapBytes(uint32_t)
Swap bytes from internal to network (big-endian) order.
Database for solution data, solver performance and other reduced data.