本文整理汇总了C++中Ch函数的典型用法代码示例。如果您正苦于以下问题:C++ Ch函数的具体用法?C++ Ch怎么用?C++ Ch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Ch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sha256_transform
// Transform one block and update state.
// State is in native byte order, data is big endian.
void sha256_transform(uint32_t state[8], const uint32_t data[16])
{
uint32_t T[20];
uint32_t W[32];
unsigned int i = 0, j = 0;
uint32_t *t = T+8;
memcpy(t, state, 32);
uint32_t e = t[4], a = t[0];
do
{
uint32_t w = be32_to_cpu(data[j]);
W[j] = w;
w += SHA256_K_GET(j);
w += t[7];
w += S1(e);
w += Ch(e, t[5], t[6]);
e = t[3] + w;
t[3] = t[3+8] = e;
w += S0(t[0]);
a = w + Maj(a, t[1], t[2]);
t[-1] = t[7] = a;
--t;
++j;
if (j%8 == 0)
t += 8;
} while (j<16);
do
{
i = j & 0xf;
uint32_t w = s1(W[i+16-2]) + s0(W[i+16-15]) + W[i] + W[i+16-7];
W[i+16] = W[i] = w;
w += SHA256_K_GET(j);
w += t[7];
w += S1(e);
w += Ch(e, t[5], t[6]);
e = t[3] + w;
t[3] = t[3+8] = e;
w += S0(t[0]);
a = w + Maj(a, t[1], t[2]);
t[-1] = t[7] = a;
w = s1(W[(i+1)+16-2]) + s0(W[(i+1)+16-15]) + W[(i+1)] + W[(i+1)+16-7];
W[(i+1)+16] = W[(i+1)] = w;
w += SHA256_K_GET(j+1);
w += (t-1)[7];
w += S1(e);
w += Ch(e, (t-1)[5], (t-1)[6]);
e = (t-1)[3] + w;
(t-1)[3] = (t-1)[3+8] = e;
w += S0((t-1)[0]);
a = w + Maj(a, (t-1)[1], (t-1)[2]);
(t-1)[-1] = (t-1)[7] = a;
t -= 2;
j += 2;
if (j % 8 == 0)
t += 8;
} while (j<64);
state[0] += a;
state[1] += t[1];
state[2] += t[2];
state[3] += t[3];
state[4] += e;
state[5] += t[5];
state[6] += t[6];
state[7] += t[7];
}
示例2: print_cdata_node
inline OutIt print_cdata_node(OutIt out, const xml_node<Ch> *node, int flags, int indent)
{
assert(node->type() == node_cdata);
if (!(flags & print_no_indenting))
out = fill_chars(out, indent, Ch('\t'));
*out = Ch('<'); ++out;
*out = Ch('!'); ++out;
*out = Ch('['); ++out;
*out = Ch('C'); ++out;
*out = Ch('D'); ++out;
*out = Ch('A'); ++out;
*out = Ch('T'); ++out;
*out = Ch('A'); ++out;
*out = Ch('['); ++out;
out = copy_chars(node->value(), node->value() + node->value_size(), out);
*out = Ch(']'); ++out;
*out = Ch(']'); ++out;
*out = Ch('>'); ++out;
return out;
}
示例3: copy_and_expand_chars
inline OutIt copy_and_expand_chars(const Ch *begin, const Ch *end, Ch noexpand, OutIt out)
{
while (begin != end)
{
if (*begin == noexpand)
{
*out++ = *begin; // No expansion, copy character
}
else
{
switch (*begin)
{
case Ch('<'):
*out++ = Ch('&'); *out++ = Ch('l'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('>'):
*out++ = Ch('&'); *out++ = Ch('g'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('\''):
*out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('p'); *out++ = Ch('o'); *out++ = Ch('s'); *out++ = Ch(';');
break;
case Ch('"'):
*out++ = Ch('&'); *out++ = Ch('q'); *out++ = Ch('u'); *out++ = Ch('o'); *out++ = Ch('t'); *out++ = Ch(';');
break;
case Ch('&'):
*out++ = Ch('&'); *out++ = Ch('a'); *out++ = Ch('m'); *out++ = Ch('p'); *out++ = Ch(';');
break;
default:
*out++ = *begin; // No expansion, copy character
}
}
++begin; // Step to next character
}
return out;
}
示例4: sha256_block_data_order
static void sha256_block_data_order(SHA256_CTX *ctx, const void *in,
size_t num)
{
unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1, T2;
SHA_LONG X[16], l;
int i;
const unsigned char *data = in;
while (num--) {
a = ctx->h[0];
b = ctx->h[1];
c = ctx->h[2];
d = ctx->h[3];
e = ctx->h[4];
f = ctx->h[5];
g = ctx->h[6];
h = ctx->h[7];
for (i = 0; i < 16; i++) {
HOST_c2l(data, l);
T1 = X[i] = l;
T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i];
T2 = Sigma0(a) + Maj(a, b, c);
h = g;
g = f;
f = e;
e = d + T1;
d = c;
c = b;
b = a;
a = T1 + T2;
}
for (; i < 64; i++) {
s0 = X[(i + 1) & 0x0f];
s0 = sigma0(s0);
s1 = X[(i + 14) & 0x0f];
s1 = sigma1(s1);
T1 = X[i & 0xf] += s0 + s1 + X[(i + 9) & 0xf];
T1 += h + Sigma1(e) + Ch(e, f, g) + K256[i];
T2 = Sigma0(a) + Maj(a, b, c);
h = g;
g = f;
f = e;
e = d + T1;
d = c;
c = b;
b = a;
a = T1 + T2;
}
ctx->h[0] += a;
ctx->h[1] += b;
ctx->h[2] += c;
ctx->h[3] += d;
ctx->h[4] += e;
ctx->h[5] += f;
ctx->h[6] += g;
ctx->h[7] += h;
}
}
示例5: ccsha512_ltc_compress
/* compress 1024-bits */
void ccsha512_ltc_compress(ccdigest_state_t state, unsigned long nblocks, const void *in)
{
uint64_t S[8], W[80], t0, t1;
int i;
uint64_t *s = ccdigest_u64(state);
const unsigned char *buf = in;
while(nblocks--) {
/* copy state into S */
for (i = 0; i < 8; i++) {
S[i] = s[i];
}
/* copy the state into 1024-bits into W[0..15] */
for (i = 0; i < 16; i++) {
CC_LOAD64_BE(W[i], buf + (8*i));
}
/* fill W[16..79] */
for (i = 16; i < 80; i++) {
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
}
/* Compress */
#ifdef CC_SMALL_CODE
for (i = 0; i < 80; i++) {
t0 = S[7] + Sigma1(S[4]) + Ch(S[4], S[5], S[6]) + K[i] + W[i];
t1 = Sigma0(S[0]) + Maj(S[0], S[1], S[2]);
S[7] = S[6];
S[6] = S[5];
S[5] = S[4];
S[4] = S[3] + t0;
S[3] = S[2];
S[2] = S[1];
S[1] = S[0];
S[0] = t0 + t1;
}
#else
#define RND(a,b,c,d,e,f,g,h,i) \
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
t1 = Sigma0(a) + Maj(a, b, c); \
d += t0; \
h = t0 + t1;
for (i = 0; i < 80; i += 8) {
RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
}
#endif
/* feedback */
for (i = 0; i < 8; i++) {
s[i] = s[i] + S[i];
}
buf+=CCSHA512_BLOCK_SIZE;
}
}
示例6: operator
void operator()(unsigned long u) const
{
u = (std::min)(u, static_cast<unsigned long>((std::numeric_limits<Ch>::max)()));
c.string += Ch(u);
}
示例7: xml_writer_make_settings
xml_writer_settings<Ch> xml_writer_make_settings(Ch indent_char = Ch(' '),
typename std::basic_string<Ch>::size_type indent_count = 0,
const std::basic_string<Ch> &encoding = widen<Ch>("utf-8"))
{
return xml_writer_settings<Ch>(indent_char, indent_count, encoding);
}
示例8: sha256_transform
static void sha256_transform(uint32_t *state, const uint8_t buffer[64])
{
unsigned int i, a, b, c, d, e, f, g, h;
uint32_t block[64];
uint32_t T1;
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
f = state[5];
g = state[6];
h = state[7];
#if CONFIG_SMALL
for (i = 0; i < 64; i++) {
uint32_t T2;
if (i < 16)
T1 = blk0(i);
else
T1 = blk(i);
T1 += h + Sigma1_256(e) + Ch(e, f, g) + K256[i];
T2 = Sigma0_256(a) + Maj(a, b, c);
h = g;
g = f;
f = e;
e = d + T1;
d = c;
c = b;
b = a;
a = T1 + T2;
}
#else
i = 0;
#define R256_0 \
ROUND256_0_TO_15(a, b, c, d, e, f, g, h); \
ROUND256_0_TO_15(h, a, b, c, d, e, f, g); \
ROUND256_0_TO_15(g, h, a, b, c, d, e, f); \
ROUND256_0_TO_15(f, g, h, a, b, c, d, e); \
ROUND256_0_TO_15(e, f, g, h, a, b, c, d); \
ROUND256_0_TO_15(d, e, f, g, h, a, b, c); \
ROUND256_0_TO_15(c, d, e, f, g, h, a, b); \
ROUND256_0_TO_15(b, c, d, e, f, g, h, a)
R256_0; R256_0;
#define R256_16 \
ROUND256_16_TO_63(a, b, c, d, e, f, g, h); \
ROUND256_16_TO_63(h, a, b, c, d, e, f, g); \
ROUND256_16_TO_63(g, h, a, b, c, d, e, f); \
ROUND256_16_TO_63(f, g, h, a, b, c, d, e); \
ROUND256_16_TO_63(e, f, g, h, a, b, c, d); \
ROUND256_16_TO_63(d, e, f, g, h, a, b, c); \
ROUND256_16_TO_63(c, d, e, f, g, h, a, b); \
ROUND256_16_TO_63(b, c, d, e, f, g, h, a)
R256_16; R256_16; R256_16;
R256_16; R256_16; R256_16;
#endif
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
state[5] += f;
state[6] += g;
state[7] += h;
}
示例9: block
/*
========================================================================
Routine Description:
SHA1 computation for one block (512 bits)
Arguments:
pSHA_CTX Pointer to SHA1_CTX_STRUC
Return Value:
None
Note:
None
========================================================================
*/
VOID RT_SHA1_Hash (
IN SHA1_CTX_STRUC *pSHA_CTX)
{
uint32_t W_i,t;
uint32_t W[80];
uint32_t a,b,c,d,e,T,f_t = 0;
/* Prepare the message schedule, {W_i}, 0 < t < 15 */
memmove(W, pSHA_CTX->Block, SHA1_BLOCK_SIZE);
for (W_i = 0; W_i < 16; W_i++) {
W[W_i] = cpu2be32(W[W_i]); /* Endian Swap */
} /* End of for */
for (W_i = 16; W_i < 80; W_i++) {
W[W_i] = ROTL32((W[W_i - 3] ^ W[W_i - 8] ^ W[W_i - 14] ^ W[W_i - 16]),1);
} /* End of for */
/* SHA256 hash computation */
/* Initialize the working variables */
a = pSHA_CTX->HashValue[0];
b = pSHA_CTX->HashValue[1];
c = pSHA_CTX->HashValue[2];
d = pSHA_CTX->HashValue[3];
e = pSHA_CTX->HashValue[4];
/* 80 rounds */
for (t = 0;t < 20;t++) {
f_t = Ch(b,c,d);
T = ROTL32(a,5) + f_t + e + SHA1_K[0] + W[t];
e = d;
d = c;
c = ROTL32(b,30);
b = a;
a = T;
} /* End of for */
for (t = 20;t < 40;t++) {
f_t = Parity(b,c,d);
T = ROTL32(a,5) + f_t + e + SHA1_K[1] + W[t];
e = d;
d = c;
c = ROTL32(b,30);
b = a;
a = T;
} /* End of for */
for (t = 40;t < 60;t++) {
f_t = Maj(b,c,d);
T = ROTL32(a,5) + f_t + e + SHA1_K[2] + W[t];
e = d;
d = c;
c = ROTL32(b,30);
b = a;
a = T;
} /* End of for */
for (t = 60;t < 80;t++) {
f_t = Parity(b,c,d);
T = ROTL32(a,5) + f_t + e + SHA1_K[3] + W[t];
e = d;
d = c;
c = ROTL32(b,30);
b = a;
a = T;
} /* End of for */
/* Compute the i^th intermediate hash value H^(i) */
pSHA_CTX->HashValue[0] += a;
pSHA_CTX->HashValue[1] += b;
pSHA_CTX->HashValue[2] += c;
pSHA_CTX->HashValue[3] += d;
pSHA_CTX->HashValue[4] += e;
memset(pSHA_CTX->Block, 0, SHA1_BLOCK_SIZE);
pSHA_CTX->BlockLen = 0;
} /* End of RT_SHA1_Hash */
示例10: info_writer_settings
info_writer_settings(Ch indent_char = Ch(' '), unsigned indent_count = 4):
indent_char(indent_char),
indent_count(indent_count)
{
}
示例11: info_writer_make_settings
info_writer_settings<Ch> info_writer_make_settings(Ch indent_char = Ch(' '), unsigned indent_count = 4)
{
return info_writer_settings<Ch>(indent_char, indent_count);
}
示例12: main
int main(int argc, char* argv[]) {
if(argc < 2) {
printf("Usage: sha256 <string>\n");
return 0;
}
// 4.2.2
uint32_t K[] = {
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
};
// 5.3.2
uint32_t H[] = {
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
};
char* msg = argv[1];
size_t len = strlen(msg);
// 5.1.1
uint64_t l = len * sizeof(char) * 8;
size_t k = (448 - l - 1) % 512;
if(k < 0) k += 512;
assert((l+1+k) % 512 == 448);
size_t msgSize = l + 1 + k + 64;
char* msgPad = (char*)calloc((msgSize / 8), sizeof(char));
memcpy(msgPad, msg, len);
msgPad[len] = 0x80;
l = swapE64(l);
memcpy(msgPad+(msgSize/8)-8, &l, 8);
// 5.2.1
size_t N = msgSize / 512;
// 6.2
uint32_t v[8];
uint32_t W[64];
uint32_t* M = (uint32_t*)msgPad;
uint32_t T1, T2;
for(size_t i = 0; i < N * 16; i++) {
M[i] = swapE32(M[i]);
}
// 6.2.2
for(size_t i = 0; i < N; i++) {
// 1
for(size_t t = 0; t < 16; t++) {
W[t] = M[i*16 + t];
}
for(size_t t = 16; t < 64; t++) {
W[t] = sig1(W[t-2]) + W[t-7] + sig0(W[t-15]) + W[t-16];
}
// 2
for(size_t t = 0; t < 8; t++) {
v[t] = H[t];
}
// 3
for(size_t t = 0; t < 64; t++) {
// a=0 b=1 c=2 d=3 e=4 f=5 g=6 h=7
T1 = v[7] + ep1(v[4]) + Ch(v[4], v[5], v[6]) + K[t] + W[t];
T2 = ep0(v[0]) + Maj(v[0], v[1], v[2]);
v[7] = v[6];
v[6] = v[5];
v[5] = v[4];
v[4] = v[3] + T1;
v[3] = v[2];
v[2] = v[1];
v[1] = v[0];
v[0] = T1 + T2;
}
for(size_t t = 0; t < 8; t++) {
H[t] += v[t];
}
}
for(size_t i = 0; i < 8; i++) {
H[i] = swapE32(H[i]);
hex(&H[i], 4);
}
printf("\n");
free(msgPad);
return 0;
}
示例13: GetTopCtrl
void AssistEditor::SyncParamInfo()
{
String qtf;
Ctrl *p = GetTopCtrl();
int mpar = INT_MAX;
int pos = 0;
if(p && p->HasFocusDeep()) {
for(int q = 0; q < PARAMN; q++) {
ParamInfo& m = param[q];
int i = GetCursorLine();
if(m.line >= 0 && m.line < GetLineCount() && i >= m.line && i < m.line + 10
&& m.editfile == theide->editfile && GetWLine(m.line).StartsWith(m.test)) {
int c = GetCursor();
i = GetPos(m.line) + m.test.GetCount();
if(c >= i) {
int par = 0;
int pari = 0;
for(;;) {
int ch = Ch(i++);
if(i > c) {
if(par < mpar) {
qtf = "[A1 " + DecoratedItem(m.item.name, m.item, m.item.natural, pari);
mpar = par;
pos = m.pos;
}
break;
}
if(ch == ')') {
if(par <= 0)
break;
par--;
}
if(ch == '(')
par++;
if(ch == ',' && par == 0)
pari++;
}
}
}
}
}
if(param_qtf != qtf)
param_info.SetQTF(qtf);
Rect r = GetLineScreenRect(GetCursorLine());
int cx = max(GetSize().cx - 30, 300);
int h = param_info.GetHeight(cx);
h = min(h, 550);
int y = r.top - h - 6;
if(y < GetWorkArea().top)
y = r.bottom;
r = RectC(r.left, y, min(param_info.GetWidth(), cx) + 8, h + 6);
r.OffsetHorz(GetColumnLine(pos).x * GetFontSize().cx);
r.OffsetHorz(min(GetWorkArea().right - r.right, 0));
if(param_qtf != qtf || r != param_info.GetRect()) {
param_qtf = qtf;
if(IsNull(qtf)) {
if(param_info.IsOpen())
param_info.Close();
}
else {
param_info.SetRect(r);
if(!param_info.IsOpen() && !IsSelection())
param_info.Ctrl::PopUp(this, false, false, false);
}
}
}
示例14: transform
//.........这里部分代码省略.........
for (i = 0, p2 = (byte *) w; i < 16; i++, p2 += 8)
{
p2[7] = *data++;
p2[6] = *data++;
p2[5] = *data++;
p2[4] = *data++;
p2[3] = *data++;
p2[2] = *data++;
p2[1] = *data++;
p2[0] = *data++;
}
}
#endif
#define S0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7))
#define S1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6))
for (t = 16; t < 80; t++)
w[t] = S1 (w[t - 2]) + w[t - 7] + S0 (w[t - 15]) + w[t - 16];
for (t = 0; t < 80; )
{
u64 t1, t2;
/* Performance on a AMD Athlon(tm) Dual Core Processor 4050e
with gcc 4.3.3 using gcry_md_hash_buffer of each 10000 bytes
initialized to 0,1,2,3...255,0,... and 1000 iterations:
Not unrolled with macros: 440ms
Unrolled with macros: 350ms
Unrolled with inline: 330ms
*/
#if 0 /* Not unrolled. */
t1 = h + Sum1 (e) + Ch (e, f, g) + k[t] + w[t];
t2 = Sum0 (a) + Maj (a, b, c);
h = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
t++;
#else /* Unrolled to interweave the chain variables. */
t1 = h + Sum1 (e) + Ch (e, f, g) + k[t] + w[t];
t2 = Sum0 (a) + Maj (a, b, c);
d += t1;
h = t1 + t2;
t1 = g + Sum1 (d) + Ch (d, e, f) + k[t+1] + w[t+1];
t2 = Sum0 (h) + Maj (h, a, b);
c += t1;
g = t1 + t2;
t1 = f + Sum1 (c) + Ch (c, d, e) + k[t+2] + w[t+2];
t2 = Sum0 (g) + Maj (g, h, a);
b += t1;
f = t1 + t2;
t1 = e + Sum1 (b) + Ch (b, c, d) + k[t+3] + w[t+3];
t2 = Sum0 (f) + Maj (f, g, h);
a += t1;
e = t1 + t2;
t1 = d + Sum1 (a) + Ch (a, b, c) + k[t+4] + w[t+4];
t2 = Sum0 (e) + Maj (e, f, g);
h += t1;
d = t1 + t2;
t1 = c + Sum1 (h) + Ch (h, a, b) + k[t+5] + w[t+5];
t2 = Sum0 (d) + Maj (d, e, f);
g += t1;
c = t1 + t2;
t1 = b + Sum1 (g) + Ch (g, h, a) + k[t+6] + w[t+6];
t2 = Sum0 (c) + Maj (c, d, e);
f += t1;
b = t1 + t2;
t1 = a + Sum1 (f) + Ch (f, g, h) + k[t+7] + w[t+7];
t2 = Sum0 (b) + Maj (b, c, d);
e += t1;
a = t1 + t2;
t += 8;
#endif
}
/* Update chaining vars. */
hd->h0 += a;
hd->h1 += b;
hd->h2 += c;
hd->h3 += d;
hd->h4 += e;
hd->h5 += f;
hd->h6 += g;
hd->h7 += h;
}
示例15: sha512_compress
static int sha512_compress(hash_state * md, const unsigned char *buf)
#endif
{
ulong64 S[8], W[80], t0, t1;
int i;
/* copy state into S */
for (i = 0; i < 8; i++) {
S[i] = md->sha512.state[i];
}
/* copy the state into 1024-bits into W[0..15] */
for (i = 0; i < 16; i++) {
LOAD64H(W[i], buf + (8*i));
}
/* fill W[16..79] */
for (i = 16; i < 80; i++) {
W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + W[i - 16];
}
/* Compress */
#ifdef LTC_SMALL_CODE
for (i = 0; i < 80; i++) {
t0 = S[7] + Sigma1(S[4]) + Ch(S[4], S[5], S[6]) + K[i] + W[i];
t1 = Sigma0(S[0]) + Maj(S[0], S[1], S[2]);
S[7] = S[6];
S[6] = S[5];
S[5] = S[4];
S[4] = S[3] + t0;
S[3] = S[2];
S[2] = S[1];
S[1] = S[0];
S[0] = t0 + t1;
}
#else
#define RND(a,b,c,d,e,f,g,h,i) \
t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \
t1 = Sigma0(a) + Maj(a, b, c); \
d += t0; \
h = t0 + t1;
for (i = 0; i < 80; i += 8) {
RND(S[0],S[1],S[2],S[3],S[4],S[5],S[6],S[7],i+0);
RND(S[7],S[0],S[1],S[2],S[3],S[4],S[5],S[6],i+1);
RND(S[6],S[7],S[0],S[1],S[2],S[3],S[4],S[5],i+2);
RND(S[5],S[6],S[7],S[0],S[1],S[2],S[3],S[4],i+3);
RND(S[4],S[5],S[6],S[7],S[0],S[1],S[2],S[3],i+4);
RND(S[3],S[4],S[5],S[6],S[7],S[0],S[1],S[2],i+5);
RND(S[2],S[3],S[4],S[5],S[6],S[7],S[0],S[1],i+6);
RND(S[1],S[2],S[3],S[4],S[5],S[6],S[7],S[0],i+7);
}
#endif
/* feedback */
for (i = 0; i < 8; i++) {
md->sha512.state[i] = md->sha512.state[i] + S[i];
}
return CRYPT_OK;
}