File: MD5UtilsImpl.hpp

package info (click to toggle)
pbseqlib 5.3.4%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 7,020 kB
  • sloc: cpp: 77,246; python: 331; sh: 103; makefile: 42
file content (44 lines) | stat: -rw-r--r-- 1,317 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef _BLASR_MD5_UTILS_IMPL_HPP_
#define _BLASR_MD5_UTILS_IMPL_HPP_
// ROTATE_LEFT rotates x left n bits.

inline unsigned int MD5::rotate_left(uint4 x, uint4 n) { return (x << n) | (x >> (32 - n)); }

// F, G, H and I are basic MD5 functions.

inline unsigned int MD5::F(uint4 x, uint4 y, uint4 z) { return (x & y) | (~x & z); }

inline unsigned int MD5::G(uint4 x, uint4 y, uint4 z) { return (x & z) | (y & ~z); }

inline unsigned int MD5::H(uint4 x, uint4 y, uint4 z) { return x ^ y ^ z; }

inline unsigned int MD5::I(uint4 x, uint4 y, uint4 z) { return y ^ (x | ~z); }

// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
// Rotation is separate from addition to prevent recomputation.

inline void MD5::FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
{
    a += F(b, c, d) + x + ac;
    a = rotate_left(a, s) + b;
}

inline void MD5::GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
{
    a += G(b, c, d) + x + ac;
    a = rotate_left(a, s) + b;
}

inline void MD5::HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
{
    a += H(b, c, d) + x + ac;
    a = rotate_left(a, s) + b;
}

inline void MD5::II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4 ac)
{
    a += I(b, c, d) + x + ac;
    a = rotate_left(a, s) + b;
}

#endif