#include <sstream>
#include <iomanip>
#include <string.h>
Go to the source code of this file.
Namespaces | |
namespace | icl_core |
namespace | icl_core::crypt |
Contains cryptographic functions. | |
Defines | |
#define | bswaparr(buf, T, i) |
#define | bswaparr64(buf, T, i) |
#define | Ch(x, y, z) ((z) ^ ((x) & ((y) ^ (z)))) |
FIPS PUB 180-3 "Ch" operation. | |
#define | CLASSM Sha2Impl<T, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len> |
#define | CLASSM Sha2Impl<uint64_t, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len> |
#define | Maj(x, y, z) (((x) & (y)) | ((z) & ((x) ^ (y)))) |
FIPS PUB 180-3 "Maj" operation. | |
#define | Rotr(x, n, nbits) (((x) >> (n)) | ((x) << ((nbits)-(n)))) |
Right rotation. | |
#define | round_0_15(a, b, c, d, e, f, g, h, K, W, t) |
#define | round_0_15(a, b, c, d, e, f, g, h, K, W, t) |
#define | round_16_63(a, b, c, d, e, f, g, h, K, W, t) |
#define | round_16_79(a, b, c, d, e, f, g, h, K, W, t) |
#define | Shr(x, n) ((x) >> (n)) |
Right shift. | |
#define | Sigma0_256(x) (Rotr((x), 2, 32) ^ Rotr((x), 13, 32) ^ Rotr((x), 22, 32)) |
#define | sigma0_256(x) (Rotr((x), 7, 32) ^ Rotr((x), 18, 32) ^ Shr((x), 3)) |
#define | Sigma0_512(x) (Rotr((x), 28, 64) ^ Rotr((x), 34, 64) ^ Rotr((x), 39, 64)) |
#define | sigma0_512(x) (Rotr((x), 1, 64) ^ Rotr((x), 8, 64) ^ Shr((x), 7)) |
#define | Sigma1_256(x) (Rotr((x), 6, 32) ^ Rotr((x), 11, 32) ^ Rotr((x), 25, 32)) |
#define | sigma1_256(x) (Rotr((x), 17, 32) ^ Rotr((x), 19, 32) ^ Shr((x), 10)) |
#define | Sigma1_512(x) (Rotr((x), 14, 64) ^ Rotr((x), 18, 64) ^ Rotr((x), 41, 64)) |
#define | sigma1_512(x) (Rotr((x), 19, 64) ^ Rotr((x), 61, 64) ^ Shr((x), 6)) |
#define | TEMPLATEM template <typename T, T t_h0, T t_h1, T t_h2, T t_h3, T t_h4, T t_h5, T t_h6, T t_h7, size_t t_len> |
#define | TEMPLATEM template <uint64_t t_h0, uint64_t t_h1, uint64_t t_h2, uint64_t t_h3, uint64_t t_h4, uint64_t t_h5, uint64_t t_h6, uint64_t t_h7, size_t t_len> |
#define | wv(i) v##i |
Flexible variable mapping to avoid unnecessary copying. | |
Variables | |
static const uint32_t | icl_core::crypt::k256 [64] |
static const uint64_t | icl_core::crypt::k512 [80] |
Definition in file Sha2Impl.hpp.
#define bswaparr | ( | buf, | |
T, | |||
i | |||
) |
((static_cast<T>(buf[(i)*4+3]) ) | \ (static_cast<T>(buf[(i)*4+2]) << 8) | \ (static_cast<T>(buf[(i)*4+1]) << 16) | \ (static_cast<T>(buf[(i)*4+0]) << 24))
Definition at line 68 of file Sha2Impl.hpp.
#define bswaparr64 | ( | buf, | |
T, | |||
i | |||
) |
((static_cast<T>(buf[(i)*8+7]) ) | \ (static_cast<T>(buf[(i)*8+6]) << 8) | \ (static_cast<T>(buf[(i)*8+5]) << 16) | \ (static_cast<T>(buf[(i)*8+4]) << 24) | \ (static_cast<T>(buf[(i)*8+3]) << 32) | \ (static_cast<T>(buf[(i)*8+2]) << 40) | \ (static_cast<T>(buf[(i)*8+1]) << 48) | \ (static_cast<T>(buf[(i)*8+0]) << 56))
Definition at line 73 of file Sha2Impl.hpp.
#define Ch | ( | x, | |
y, | |||
z | |||
) | ((z) ^ ((x) & ((y) ^ (z)))) |
FIPS PUB 180-3 "Ch" operation.
Definition at line 83 of file Sha2Impl.hpp.
#define CLASSM Sha2Impl<T, t_h0, t_h1, t_h2, t_h3, t_h4, t_h5, t_h6, t_h7, t_len> |
Definition at line 266 of file Sha2Impl.hpp.
Definition at line 266 of file Sha2Impl.hpp.
#define Maj | ( | x, | |
y, | |||
z | |||
) | (((x) & (y)) | ((z) & ((x) ^ (y)))) |
FIPS PUB 180-3 "Maj" operation.
Definition at line 85 of file Sha2Impl.hpp.
#define Rotr | ( | x, | |
n, | |||
nbits | |||
) | (((x) >> (n)) | ((x) << ((nbits)-(n)))) |
Right rotation.
Definition at line 87 of file Sha2Impl.hpp.
#define round_0_15 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
K, | |||
W, | |||
t | |||
) |
T1 = wv(h) + Sigma1_256(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \ T2 = Sigma0_256(wv(a)) + Maj(wv(a), wv(b), wv(c)); \ wv(d) += T1; \ wv(h) = T1 + T2;
Definition at line 305 of file Sha2Impl.hpp.
#define round_0_15 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
K, | |||
W, | |||
t | |||
) |
T1 = wv(h) + Sigma1_512(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \ T2 = Sigma0_512(wv(a)) + Maj(wv(a), wv(b), wv(c)); \ wv(d) += T1; \ wv(h) = T1 + T2;
Definition at line 305 of file Sha2Impl.hpp.
#define round_16_63 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
K, | |||
W, | |||
t | |||
) |
W[(t)&15] += sigma1_256(W[(t+14)&15]) + W[(t+9)&15] + sigma0_256(W[(t+1)&15]); \ T1 = wv(h) + Sigma1_256(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \ T2 = Sigma0_256(wv(a)) + Maj(wv(a), wv(b), wv(c)); \ wv(d) += T1; \ wv(h) = T1 + T2;
Definition at line 119 of file Sha2Impl.hpp.
#define round_16_79 | ( | a, | |
b, | |||
c, | |||
d, | |||
e, | |||
f, | |||
g, | |||
h, | |||
K, | |||
W, | |||
t | |||
) |
W[(t)&15] += sigma1_512(W[(t+14)&15]) + W[(t+9)&15] + sigma0_512(W[(t+1)&15]); \ T1 = wv(h) + Sigma1_512(wv(e)) + Ch(wv(e), wv(f), wv(g)) + K[t] + W[t&15]; \ T2 = Sigma0_512(wv(a)) + Maj(wv(a), wv(b), wv(c)); \ wv(d) += T1; \ wv(h) = T1 + T2;
Definition at line 311 of file Sha2Impl.hpp.
#define Shr | ( | x, | |
n | |||
) | ((x) >> (n)) |
Right shift.
Definition at line 89 of file Sha2Impl.hpp.
#define Sigma0_256 | ( | x | ) | (Rotr((x), 2, 32) ^ Rotr((x), 13, 32) ^ Rotr((x), 22, 32)) |
Definition at line 93 of file Sha2Impl.hpp.
#define sigma0_256 | ( | x | ) | (Rotr((x), 7, 32) ^ Rotr((x), 18, 32) ^ Shr((x), 3)) |
Definition at line 95 of file Sha2Impl.hpp.
#define Sigma0_512 | ( | x | ) | (Rotr((x), 28, 64) ^ Rotr((x), 34, 64) ^ Rotr((x), 39, 64)) |
Definition at line 268 of file Sha2Impl.hpp.
#define sigma0_512 | ( | x | ) | (Rotr((x), 1, 64) ^ Rotr((x), 8, 64) ^ Shr((x), 7)) |
Definition at line 270 of file Sha2Impl.hpp.
#define Sigma1_256 | ( | x | ) | (Rotr((x), 6, 32) ^ Rotr((x), 11, 32) ^ Rotr((x), 25, 32)) |
Definition at line 94 of file Sha2Impl.hpp.
#define sigma1_256 | ( | x | ) | (Rotr((x), 17, 32) ^ Rotr((x), 19, 32) ^ Shr((x), 10)) |
Definition at line 96 of file Sha2Impl.hpp.
#define Sigma1_512 | ( | x | ) | (Rotr((x), 14, 64) ^ Rotr((x), 18, 64) ^ Rotr((x), 41, 64)) |
Definition at line 269 of file Sha2Impl.hpp.
#define sigma1_512 | ( | x | ) | (Rotr((x), 19, 64) ^ Rotr((x), 61, 64) ^ Shr((x), 6)) |
Definition at line 271 of file Sha2Impl.hpp.
#define TEMPLATEM template <typename T, T t_h0, T t_h1, T t_h2, T t_h3, T t_h4, T t_h5, T t_h6, T t_h7, size_t t_len> |
Definition at line 265 of file Sha2Impl.hpp.
#define TEMPLATEM template <uint64_t t_h0, uint64_t t_h1, uint64_t t_h2, uint64_t t_h3, uint64_t t_h4, uint64_t t_h5, uint64_t t_h6, uint64_t t_h7, size_t t_len> |
Definition at line 265 of file Sha2Impl.hpp.
#define wv | ( | i | ) | v##i |
Flexible variable mapping to avoid unnecessary copying.
Definition at line 91 of file Sha2Impl.hpp.