本文整理汇总了C++中F3函数的典型用法代码示例。如果您正苦于以下问题:C++ F3函数的具体用法?C++ F3怎么用?C++ F3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了F3函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: F1
void CAST128::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{
word32 t, l, r;
/* Get inblock into l,r */
Block::Get(inBlock)(r)(l);
/* Only do full 16 rounds if key length > 80 bits */
if (!reduced) {
F1(r, l, 15, 16);
F3(l, r, 14, 16);
F2(r, l, 13, 16);
F1(l, r, 12, 16);
}
F3(r, l, 11, 16);
F2(l, r, 10, 16);
F1(r, l, 9, 16);
F3(l, r, 8, 16);
F2(r, l, 7, 16);
F1(l, r, 6, 16);
F3(r, l, 5, 16);
F2(l, r, 4, 16);
F1(r, l, 3, 16);
F3(l, r, 2, 16);
F2(r, l, 1, 16);
F1(l, r, 0, 16);
/* Put l,r into outblock */
Block::Put(xorBlock, outBlock)(l)(r);
/* Wipe clean */
t = l = r = 0;
}
开发者ID:prakhs123,项目名称:cryptopp,代码行数:30,代码来源:cast.cpp
示例2: FOR_BLOCKS
FOR_BLOCKS(length, dst, src, CAST128_BLOCK_SIZE)
{
uint32_t t, l, r;
/* Get inblock into l,r */
l = READ_UINT32(src);
r = READ_UINT32(src+4);
/* Do the work */
F1(l, r, 0);
F2(r, l, 1);
F3(l, r, 2);
F1(r, l, 3);
F2(l, r, 4);
F3(r, l, 5);
F1(l, r, 6);
F2(r, l, 7);
F3(l, r, 8);
F1(r, l, 9);
F2(l, r, 10);
F3(r, l, 11);
/* Only do full 16 rounds if key length > 80 bits */
if (ctx->rounds > 12) {
F1(l, r, 12);
F2(r, l, 13);
F3(l, r, 14);
F1(r, l, 15);
}
/* Put l,r into outblock */
WRITE_UINT32(dst, r);
WRITE_UINT32(dst + 4, l);
/* Wipe clean */
t = l = r = 0;
}
开发者ID:ystk,项目名称:debian-nettle,代码行数:34,代码来源:cast128.c
示例3: F1
void CAST256::W(const uint8_t i){
g ^= F1(h, Tm[0][i], Tr[0][i]);
f ^= F2(g, Tm[1][i], Tr[1][i]);
e ^= F3(f, Tm[2][i], Tr[2][i]);
d ^= F1(e, Tm[3][i], Tr[3][i]);
c ^= F2(d, Tm[4][i], Tr[4][i]);
b ^= F3(c, Tm[5][i], Tr[5][i]);
a ^= F1(b, Tm[6][i], Tr[6][i]);
h ^= F2(a, Tm[7][i], Tr[7][i]);
}
开发者ID:calccrypto,项目名称:Encryptions,代码行数:10,代码来源:CAST256.cpp
示例4: W
/* forward octave */
static inline void W(u32 *key, unsigned int i) {
u32 I;
key[6] ^= F1(key[7], Tr[i % 4][0], Tm[i][0]);
key[5] ^= F2(key[6], Tr[i % 4][1], Tm[i][1]);
key[4] ^= F3(key[5], Tr[i % 4][2], Tm[i][2]);
key[3] ^= F1(key[4], Tr[i % 4][3], Tm[i][3]);
key[2] ^= F2(key[3], Tr[i % 4][4], Tm[i][4]);
key[1] ^= F3(key[2], Tr[i % 4][5], Tm[i][5]);
key[0] ^= F1(key[1], Tr[i % 4][6], Tm[i][6]);
key[7] ^= F2(key[0], Tr[i % 4][7], Tm[i][7]);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:12,代码来源:cast6.c
示例5: cast5_encrypt
static void cast5_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf)
{
struct cast5_ctx *c = crypto_tfm_ctx(tfm);
const __be32 *src = (const __be32 *)inbuf;
__be32 *dst = (__be32 *)outbuf;
u32 l, r, t;
u32 I; /* used by the Fx macros */
u32 *Km;
u8 *Kr;
Km = c->Km;
Kr = c->Kr;
/* (L0,R0) <-- (m1...m64). (Split the plaintext into left and
* right 32-bit halves L0 = m1...m32 and R0 = m33...m64.)
*/
l = be32_to_cpu(src[0]);
r = be32_to_cpu(src[1]);
/* (16 rounds) for i from 1 to 16, compute Li and Ri as follows:
* Li = Ri-1;
* Ri = Li-1 ^ f(Ri-1,Kmi,Kri), where f is defined in Section 2.2
* Rounds 1, 4, 7, 10, 13, and 16 use f function Type 1.
* Rounds 2, 5, 8, 11, and 14 use f function Type 2.
* Rounds 3, 6, 9, 12, and 15 use f function Type 3.
*/
t = l; l = r; r = t ^ F1(r, Km[0], Kr[0]);
t = l; l = r; r = t ^ F2(r, Km[1], Kr[1]);
t = l; l = r; r = t ^ F3(r, Km[2], Kr[2]);
t = l; l = r; r = t ^ F1(r, Km[3], Kr[3]);
t = l; l = r; r = t ^ F2(r, Km[4], Kr[4]);
t = l; l = r; r = t ^ F3(r, Km[5], Kr[5]);
t = l; l = r; r = t ^ F1(r, Km[6], Kr[6]);
t = l; l = r; r = t ^ F2(r, Km[7], Kr[7]);
t = l; l = r; r = t ^ F3(r, Km[8], Kr[8]);
t = l; l = r; r = t ^ F1(r, Km[9], Kr[9]);
t = l; l = r; r = t ^ F2(r, Km[10], Kr[10]);
t = l; l = r; r = t ^ F3(r, Km[11], Kr[11]);
if (!(c->rr)) {
t = l; l = r; r = t ^ F1(r, Km[12], Kr[12]);
t = l; l = r; r = t ^ F2(r, Km[13], Kr[13]);
t = l; l = r; r = t ^ F3(r, Km[14], Kr[14]);
t = l; l = r; r = t ^ F1(r, Km[15], Kr[15]);
}
/* c1...c64 <-- (R16,L16). (Exchange final blocks L16, R16 and
* concatenate to form the ciphertext.) */
dst[0] = cpu_to_be32(r);
dst[1] = cpu_to_be32(l);
}
开发者ID:08opt,项目名称:linux,代码行数:51,代码来源:cast5.c
示例6: QBAR
/*reverse quad round*/
static inline void QBAR (u32 * block, u8 * Kr, u32 * Km) {
u32 I;
block[3] ^= F1(block[0], Kr[3], Km[3]);
block[0] ^= F3(block[1], Kr[2], Km[2]);
block[1] ^= F2(block[2], Kr[1], Km[1]);
block[2] ^= F1(block[3], Kr[0], Km[0]);
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:8,代码来源:cast6.c
示例7: rubikStep
void rubikStep(char *step)
{
u8 m=0;
for(m=0;step[m]!=0;m++)
{
switch(step[m])
{
case 7:allright90();break;
case 11:F1();break;
case 12:F2();break;
case 13:F3();break;
case 21:B1();break;
case 22:B2();break;
case 23:B3();break;
case 31:R1();break;
case 32:R2();break;
case 33:R3();break;
case 41:L1();break;
case 42:L2();break;
case 43:L3();break;
case 51:U1();break;
case 52:U2();break;
case 53:U3();break;
case 61:D1();break;
case 62:D2();break;
case 63:D3();break;
default:break;
}
}
}
开发者ID:MrChang0,项目名称:rubik,代码行数:30,代码来源:mofang.c
示例8: cast5_decrypt
static void cast5_decrypt(void *ctx, u8 * outbuf, const u8 * inbuf)
{
struct cast5_ctx *c = (struct cast5_ctx *) ctx;
const __be32 *src = (const __be32 *)inbuf;
__be32 *dst = (__be32 *)outbuf;
u32 l, r, t;
u32 I;
u32 *Km;
u8 *Kr;
Km = c->Km;
Kr = c->Kr;
l = be32_to_cpu(src[0]);
r = be32_to_cpu(src[1]);
if (!(c->rr)) {
t = l; l = r; r = t ^ F1(r, Km[15], Kr[15]);
t = l; l = r; r = t ^ F3(r, Km[14], Kr[14]);
t = l; l = r; r = t ^ F2(r, Km[13], Kr[13]);
t = l; l = r; r = t ^ F1(r, Km[12], Kr[12]);
t = l; l = r; r = t ^ F3(r, Km[11], Kr[11]);
t = l; l = r; r = t ^ F2(r, Km[10], Kr[10]);
t = l; l = r; r = t ^ F1(r, Km[9], Kr[9]);
t = l; l = r; r = t ^ F3(r, Km[8], Kr[8]);
t = l; l = r; r = t ^ F2(r, Km[7], Kr[7]);
t = l; l = r; r = t ^ F1(r, Km[6], Kr[6]);
t = l; l = r; r = t ^ F3(r, Km[5], Kr[5]);
t = l; l = r; r = t ^ F2(r, Km[4], Kr[4]);
t = l; l = r; r = t ^ F1(r, Km[3], Kr[3]);
t = l; l = r; r = t ^ F3(r, Km[2], Kr[2]);
t = l; l = r; r = t ^ F2(r, Km[1], Kr[1]);
t = l; l = r; r = t ^ F1(r, Km[0], Kr[0]);
} else {
t = l; l = r; r = t ^ F3(r, Km[11], Kr[11]);
t = l; l = r; r = t ^ F2(r, Km[10], Kr[10]);
t = l; l = r; r = t ^ F1(r, Km[9], Kr[9]);
t = l; l = r; r = t ^ F3(r, Km[8], Kr[8]);
t = l; l = r; r = t ^ F2(r, Km[7], Kr[7]);
t = l; l = r; r = t ^ F1(r, Km[6], Kr[6]);
t = l; l = r; r = t ^ F3(r, Km[5], Kr[5]);
t = l; l = r; r = t ^ F2(r, Km[4], Kr[4]);
t = l; l = r; r = t ^ F1(r, Km[3], Kr[3]);
t = l; l = r; r = t ^ F3(r, Km[2], Kr[2]);
t = l; l = r; r = t ^ F2(r, Km[1], Kr[1]);
t = l; l = r; r = t ^ F1(r, Km[0], Kr[0]);
}
dst[0] = cpu_to_be32(r);
dst[1] = cpu_to_be32(l);
}
开发者ID:devicenull,项目名称:supermicro_ipmi_firmware,代码行数:51,代码来源:cast5.c
示例9: main
int main()
{
auto a1 = F1();
auto a2 = F2();
auto a3 = F3();
auto a4 = F4();
auto a5 = F5();
return 0;
}
开发者ID:potimarimo,项目名称:material-of-a-study-meeting,代码行数:10,代码来源:テンプレートメタプログラミング.cpp
示例10: cast_decrypt
void
cast_decrypt(cast_key* key, u_int8_t* inblock, u_int8_t* outblock)
{
u_int32_t t, l, r;
/* Get inblock into l,r */
r = ((u_int32_t)inblock[0] << 24) | ((u_int32_t)inblock[1] << 16) |
((u_int32_t)inblock[2] << 8) | (u_int32_t)inblock[3];
l = ((u_int32_t)inblock[4] << 24) | ((u_int32_t)inblock[5] << 16) |
((u_int32_t)inblock[6] << 8) | (u_int32_t)inblock[7];
/* Do the work */
/* Only do full 16 rounds if key length > 80 bits */
if (key->rounds > 12) {
F1(r, l, 15);
F3(l, r, 14);
F2(r, l, 13);
F1(l, r, 12);
}
F3(r, l, 11);
F2(l, r, 10);
F1(r, l, 9);
F3(l, r, 8);
F2(r, l, 7);
F1(l, r, 6);
F3(r, l, 5);
F2(l, r, 4);
F1(r, l, 3);
F3(l, r, 2);
F2(r, l, 1);
F1(l, r, 0);
/* Put l,r into outblock */
outblock[0] = U8a(l);
outblock[1] = U8b(l);
outblock[2] = U8c(l);
outblock[3] = U8d(l);
outblock[4] = U8a(r);
outblock[5] = U8b(r);
outblock[6] = U8c(r);
outblock[7] = U8d(r);
/* Wipe clean */
t = l = r = 0;
}
开发者ID:mikekmv,项目名称:aeriebsd-src,代码行数:42,代码来源:cast.c
示例11: CAST5decrypt
void
CAST5decrypt(const PGPUInt8 *in, PGPUInt8 *out, const PGPUInt32 *xkey)
{
PGPUInt32 l, r, t;
r = (PGPUInt32) in[0]<<24 | (PGPUInt32) in[1]<<16 |
(PGPUInt32) in[2]<<8 | in[3];
l = (PGPUInt32) in[4]<<24 | (PGPUInt32) in[5]<<16 |
(PGPUInt32) in[6]<<8 | in[7];
t = F1(l, xkey, 15); r ^= G1(t);
t = F3(r, xkey, 14); l ^= G3(t);
t = F2(l, xkey, 13); r ^= G2(t);
t = F1(r, xkey, 12); l ^= G1(t);
// Start here if only doing 12 rounds
t = F3(l, xkey, 11); r ^= G3(t);
t = F2(r, xkey, 10); l ^= G2(t);
t = F1(l, xkey, 9); r ^= G1(t);
t = F3(r, xkey, 8); l ^= G3(t);
t = F2(l, xkey, 7); r ^= G2(t);
t = F1(r, xkey, 6); l ^= G1(t);
t = F3(l, xkey, 5); r ^= G3(t);
t = F2(r, xkey, 4); l ^= G2(t);
t = F1(l, xkey, 3); r ^= G1(t);
t = F3(r, xkey, 2); l ^= G3(t);
t = F2(l, xkey, 1); r ^= G2(t);
t = F1(r, xkey, 0); l ^= G1(t);
out[0] = (PGPUInt8) B0(l);
out[1] = (PGPUInt8) B1(l);
out[2] = (PGPUInt8) B2(l);
out[3] = (PGPUInt8) B3(l);
out[4] = (PGPUInt8) B0(r);
out[5] = (PGPUInt8) B1(r);
out[6] = (PGPUInt8) B2(r);
out[7] = (PGPUInt8) B3(r);
}
开发者ID:ysangkok,项目名称:pgp-win32-6.5.8,代码行数:38,代码来源:Cast5.cpp
示例12: Vector_Drive
void
Vector_Drive(vector V, double omega)
{
vector F1(-1.000,0.000), F2(0.500,-0.866), F3(0.866,0.500);
double omega1, omega2, omega3, b=0.090, r=0.020, h=0;
omega1 = ( F1*V + b*omega ) / r; // F1*V is overloaded dot product
omega2 = ( F2*V + b*omega ) / r;
omega3 = ( F3*V + b*omega ) / r;
// makes sure that given path is physically possible
if ( (omega1>6) || (omega2>6) || (omega3>6) || (omega1<-6) || (omega2<-6) || (omega3<-6) )
DisplayTxt("Vectors: ERROR!");
else
Drive(Vel_To_Value(omega1),Vel_To_Value(omega2),Vel_To_Value(omega3));
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:14,代码来源:palmbot.cpp
示例13: CAST5encrypt
/*
* Encrypt the 8 bytes at *in into the 8 bytes at *out using the expanded
* key schedule from *xkey.
*/
static void
CAST5encrypt(PGPByte const *in, PGPByte *out, PGPUInt32 const *xkey)
{
PGPUInt32 l, r, t;
l = (PGPUInt32)
in[0]<<24 | (PGPUInt32)in[1]<<16 | (PGPUInt32)in[2]<<8 | in[3];
r = (PGPUInt32)
in[4]<<24 | (PGPUInt32)in[5]<<16 | (PGPUInt32)in[6]<<8 | in[7];
t = F1(r, xkey, 0); l ^= G1(t);
t = F2(l, xkey, 1); r ^= G2(t);
t = F3(r, xkey, 2); l ^= G3(t);
t = F1(l, xkey, 3); r ^= G1(t);
t = F2(r, xkey, 4); l ^= G2(t);
t = F3(l, xkey, 5); r ^= G3(t);
t = F1(r, xkey, 6); l ^= G1(t);
t = F2(l, xkey, 7); r ^= G2(t);
t = F3(r, xkey, 8); l ^= G3(t);
t = F1(l, xkey, 9); r ^= G1(t);
t = F2(r, xkey, 10); l ^= G2(t);
t = F3(l, xkey, 11); r ^= G3(t);
/* Stop here if only doing 12 rounds */
t = F1(r, xkey, 12); l ^= G1(t);
t = F2(l, xkey, 13); r ^= G2(t);
t = F3(r, xkey, 14); l ^= G3(t);
t = F1(l, xkey, 15); r ^= G1(t);
out[0] = B0(r);
out[1] = B1(r);
out[2] = B2(r);
out[3] = B3(r);
out[4] = B0(l);
out[5] = B1(l);
out[6] = B2(l);
out[7] = B3(l);
}
开发者ID:ysangkok,项目名称:pgp-win32-6.5.8,代码行数:41,代码来源:pgpCAST5.c
示例14: QWidget
seconlevel_f4::seconlevel_f4(QWidget *parent) :
QWidget(parent),
ui(new Ui::seconlevel_f4)
{
ui->setupUi(this);
group = new GroupDialog(parent);
group->hide();
connect(group ,SIGNAL(finished(int)) ,this ,SLOT(f1_Done(int)));
autotab = new AutoDialog(parent);
autotab->hide();
connect(autotab ,SIGNAL(finished(int)) ,this ,SLOT(f2_Done(int)));
jump = new JumpDialog(parent);
jump->hide();
connect(jump ,SIGNAL(finished(int)) ,this ,SLOT(f6_Done(int)));
connect(ui->pushButton_F1,SIGNAL(clicked()),this ,SLOT(F1()));
ui->pushButton_F1->setCheckable(true);
connect(ui->pushButton_F2,SIGNAL(clicked()),this ,SLOT(F2()));
ui->pushButton_F2->setCheckable(true);
connect(ui->pushButton_F3,SIGNAL(clicked()),this ,SLOT(F3()));
ui->pushButton_F3->setCheckable(true);
connect(ui->pushButton_F4,SIGNAL(clicked()),this ,SLOT(F4()));
ui->pushButton_F4->setCheckable(true);
connect(ui->pushButton_F5,SIGNAL(clicked()),this ,SLOT(F5()));
ui->pushButton_F5->setCheckable(true);
connect(ui->pushButton_F6,SIGNAL(clicked()),this ,SLOT(F6()));
ui->pushButton_F6->setCheckable(true);
connect(ui->pushButton_F7,SIGNAL(clicked()),this ,SLOT(F7()));
ui->pushButton_F7->setCheckable(true);
connect(this ,SIGNAL(enter(int)),parent ,SLOT(funcbarUpdate(int)));
connect(ui->pushButton_F8,SIGNAL(clicked()),this ,SLOT(F8()));
/*数据表模式改变信号*/
connect(this ,SIGNAL(stateChange(char)) ,parent ,SLOT(tableStateUpdate(char)));
/*段选信号*/
connect(this ,SIGNAL(selectRows(bool)) ,parent ,SLOT(tableSelect(bool)));
setFocusPolicy(Qt::NoFocus);
}
开发者ID:taiyuankejizhu,项目名称:SparkZNC,代码行数:49,代码来源:seconlevel_f4.cpp
示例15: test_main
int test_main(int,char *[])
{
bu::quantity<mixed_length> a1(2.0 * mixed_length());
bu::quantity<si_area> a2(a1);
BOOST_CHECK((std::abs(a2.value() - .02) < .0001));
bu::quantity<mixed_length> a3(a2);
BOOST_CHECK((std::abs(a3.value() - 2.0) < .0001));
bu::quantity<mixed_energy_1> e1(2.0 * mixed_energy_1());
bu::quantity<mixed_energy_2> e2(e1);
BOOST_CHECK((std::abs(e2.value() - 20.0) < .0001));
bu::quantity<bu::si::energy> e3(e1);
BOOST_CHECK((std::abs(e3.value() - .0002) < .0001));
bu::quantity<mixed_energy_2> e4(e3);
BOOST_CHECK((std::abs(e4.value() - 20.0) < .0001));
bu::quantity<bu::cgs::force> F0 = 20 * bu::cgs::dyne;
BOOST_CHECK((std::abs(F0.value() - 20.0) < .0001));
bu::quantity<bu::si::force> F3(F0);
BOOST_CHECK((std::abs(F3.value() - 2.0e-4) < .000000001));
bu::quantity<bu::si::force> F5(20 * bu::cgs::dyne);
BOOST_CHECK((std::abs(F5.value() - 2.0e-4) < .000000001));
bu::quantity<bu::si::dimensionless> dimensionless_test1(1.0*bu::cgs::dyne/bu::si::newton);
BOOST_CHECK(dimensionless_test1 == 1e-5);
typedef bu::multiply_typeof_helper<bu::si::length, bu::cgs::length>::type m_cm;
typedef bu::divide_typeof_helper<m_cm, m_cm>::type heterogeneous_dimensionless;
bu::quantity<heterogeneous_dimensionless> dimensionless_test2(1.0*bu::cgs::dyne/bu::si::newton);
BOOST_CHECK(dimensionless_test2.value() == 1e-5);
bu::quantity<bu::divide_typeof_helper<bu::cgs::force, bu::si::force>::type> dimensionless_test3(dimensionless_test2);
BOOST_UNITS_CHECK_CLOSE(dimensionless_test3.value(), 1.0);
//m/cm -> g/kg
bu::quantity<bu::divide_typeof_helper<bu::si::length, bu::cgs::length>::type> dimensionless_test4(2.0 * bu::si::meters / bu::cgs::centimeters);
bu::quantity<bu::divide_typeof_helper<bu::cgs::mass, bu::si::mass>::type> dimensionless_test5(dimensionless_test4);
BOOST_UNITS_CHECK_CLOSE(dimensionless_test5.value(), 2e5);
return(0);
}
开发者ID:Ruinland,项目名称:boost-doc-zh,代码行数:47,代码来源:test_conversion.cpp
示例16: g
int g(unsigned char *in,int i,dword *h)
{
dword h0,h1,h2,h3,h4,a,b,c,d,e,temp;
unsigned char *kp;
dword w[80];
kp = in;
h0 = WORD(kp); kp += 4;
h1 = WORD(kp); kp += 4;
h2 = WORD(kp); kp += 4;
h3 = WORD(kp); kp += 4;
h4 = WORD(kp); kp += 4;
w[0] = i;
for (i=1;i<16;i++) w[i] = 0;
for (i=16;i<80;i++) w[i] = w[i-3]^w[i-8]^w[i-14]^w[i-16];
a = h0; b = h1; c = h2; d = h3; e = h4;
for(i=0;i<20;i++)
{
temp = ROT27(a) + F1(b, c, d) + e + w[i] + 0x5a827998;
e = d; d = c; c = ROT2(b); b = a; a = temp;
}
for (i=20;i<40;i++)
{
temp = ROT27(a) + F2(b, c, d) + e + w[i] + 0x6ef9eba1;
e = d; d = c; c = ROT2(b); b = a; a = temp;
}
for (i=40;i<60;i++)
{
temp = ROT27(a) + F3(b, c, d) + e + w[i] + 0x7f1cbcdc;
e = d; d = c; c = ROT2(b); b = a; a = temp;
}
for (i=60;i<80;i++)
{
temp = ROT27(a) + F4(b, c, d) + e + w[i] + 0xaa62d1d6;
e = d; d = c; c = ROT2(b); b = a; a = temp;
}
h[0] = h0+a; h[1] = h1+b; h[2] = h2+c; h[3] = h3+d; h[4] = h4+e;
return (ALG_OK);
}
开发者ID:Beanux,项目名称:openkore_fork,代码行数:46,代码来源:seal.c
示例17: rmd160_compress
/* The RIPEMD160 compression function. */
static inline void rmd160_compress(struct rmd160_ctx *ctx, uint32_t *buf)
{
uint8_t w, round;
uint32_t T;
uint32_t AL, BL, CL, DL, EL; /* left line */
uint32_t AR, BR, CR, DR, ER; /* right line */
uint32_t X[16];
/* Byte-swap the buffer if we're on a big-endian machine */
cpu_to_le32_array(X, buf, 16);
/* Load the left and right lines with the initial state */
AL = AR = ctx->h[0];
BL = BR = ctx->h[1];
CL = CR = ctx->h[2];
DL = DR = ctx->h[3];
EL = ER = ctx->h[4];
/* Round 1 */
round = 0;
for (w = 0; w < 16; w++) { /* left line */
T = rol32(AL + F1(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL;
AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = rol32(AR + F5(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER;
AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T;
}
/* Round 2 */
round++;
for (w = 0; w < 16; w++) { /* left line */
T = rol32(AL + F2(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL;
AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = rol32(AR + F4(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER;
AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T;
}
/* Round 3 */
round++;
for (w = 0; w < 16; w++) { /* left line */
T = rol32(AL + F3(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL;
AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = rol32(AR + F3(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER;
AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T;
}
/* Round 4 */
round++;
for (w = 0; w < 16; w++) { /* left line */
T = rol32(AL + F4(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL;
AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = rol32(AR + F2(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER;
AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T;
}
/* Round 5 */
round++;
for (w = 0; w < 16; w++) { /* left line */
T = rol32(AL + F5(BL, CL, DL) + X[RL[round][w]] + KL[round], SL[round][w]) + EL;
AL = EL; EL = DL; DL = rol32(CL, 10); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = rol32(AR + F1(BR, CR, DR) + X[RR[round][w]] + KR[round], SR[round][w]) + ER;
AR = ER; ER = DR; DR = rol32(CR, 10); CR = BR; BR = T;
}
/* Final mixing stage */
T = ctx->h[1] + CL + DR;
ctx->h[1] = ctx->h[2] + DL + ER;
ctx->h[2] = ctx->h[3] + EL + AR;
ctx->h[3] = ctx->h[4] + AL + BR;
ctx->h[4] = ctx->h[0] + BL + CR;
ctx->h[0] = T;
}
开发者ID:oklm-wsh,项目名称:Digestif,代码行数:82,代码来源:ripemd160.c
示例18: psc_balance_sub_communicate_fields
static void
psc_balance_sub_communicate_fields(struct psc_balance *bal, struct communicate_ctx *ctx,
struct psc_mfields *mflds_old, struct psc_mfields *mflds_new)
{
//HACK: Don't communicate output fields if they don't correspond to the domain
//This is needed e.g. for the boosted output which handles its MPI communication internally
//printf("Field: %s\n", flds->f[0].name);
if (ctx->nr_patches_old != mflds_old->nr_patches /* || strncmp(flds->f[0].name, "lab", 3) == 0 */) return;
assert(ctx->nr_patches_old == mflds_old->nr_patches);
assert(ctx->nr_patches_old > 0);
// send from old local patches
MPI_Request *send_reqs = calloc(ctx->nr_patches_old, sizeof(*send_reqs));
int *nr_patches_new_by_rank = calloc(ctx->mpi_size, sizeof(*nr_patches_new_by_rank));
for (int p = 0; p < ctx->nr_patches_old; p++) {
int new_rank = ctx->send_info[p].rank;
if (new_rank == ctx->mpi_rank || new_rank < 0) {
send_reqs[p] = MPI_REQUEST_NULL;
} else {
fields_t *pf_old = psc_mfields_get_patch(mflds_old, p);
int nn = psc_fields_size(pf_old) * pf_old->nr_comp;
int *ib = pf_old->ib;
void *addr_old = &F3(pf_old, 0, ib[0], ib[1], ib[2]);
int tag = nr_patches_new_by_rank[new_rank]++;
MPI_Isend(addr_old, nn, MPI_FIELDS_REAL, new_rank, tag, ctx->comm, &send_reqs[p]);
}
}
free(nr_patches_new_by_rank);
// recv for new local patches
MPI_Request *recv_reqs = calloc(ctx->nr_patches_new, sizeof(*recv_reqs));
int *nr_patches_old_by_rank = calloc(ctx->mpi_size, sizeof(*nr_patches_new_by_rank));
for (int p = 0; p < ctx->nr_patches_new; p++) {
int old_rank = ctx->recv_info[p].rank;
if (old_rank == ctx->mpi_rank) {
recv_reqs[p] = MPI_REQUEST_NULL;
} else if (old_rank < 0) { //this patch did not exist before
recv_reqs[p] = MPI_REQUEST_NULL;
//Seed new data
} else {
fields_t *pf_new = psc_mfields_get_patch(mflds_new, p);
int nn = psc_fields_size(pf_new) * pf_new->nr_comp;
int *ib = pf_new->ib;
void *addr_new = &F3(pf_new, 0, ib[0], ib[1], ib[2]);
int tag = nr_patches_old_by_rank[old_rank]++;
MPI_Irecv(addr_new, nn, MPI_FIELDS_REAL, old_rank,
tag, ctx->comm, &recv_reqs[p]);
}
}
free(nr_patches_old_by_rank);
static int pr;
if (!pr) {
pr = prof_register("bal flds local", 1., 0, 0);
}
prof_start(pr);
// local fields
// OPT: could keep the alloced arrays, just move pointers...
for (int p = 0; p < ctx->nr_patches_new; p++) {
if (ctx->recv_info[p].rank != ctx->mpi_rank) {
continue;
}
fields_t *pf_old = psc_mfields_get_patch(mflds_old, ctx->recv_info[p].patch);
fields_t *pf_new = psc_mfields_get_patch(mflds_new, p);
assert(pf_old->nr_comp == pf_new->nr_comp);
assert(psc_fields_size(pf_old) == psc_fields_size(pf_new));
int size = psc_fields_size(pf_old) * pf_old->nr_comp;
int *ib = pf_new->ib;
void *addr_new = &F3(pf_new, 0, ib[0], ib[1], ib[2]);
void *addr_old = &F3(pf_old, 0, ib[0], ib[1], ib[2]);
memcpy(addr_new, addr_old, size * sizeof(fields_real_t));
}
prof_stop(pr);
MPI_Waitall(ctx->nr_patches_old, send_reqs, MPI_STATUSES_IGNORE);
MPI_Waitall(ctx->nr_patches_new, recv_reqs, MPI_STATUSES_IGNORE);
free(send_reqs);
free(recv_reqs);
}
开发者ID:ALaDyn,项目名称:psc,代码行数:84,代码来源:psc_balance_common.c
示例19: ripemd160_compress
/* The RIPEMD160 compression function. Operates on self->buf */
static void ripemd160_compress(hash_state *self)
{
unsigned w, round;
uint32_t T;
uint32_t AL, BL, CL, DL, EL; /* left line */
uint32_t AR, BR, CR, DR, ER; /* right line */
uint32_t bufw[16];
for (w=0; w<16; w++)
bufw[w] = LOAD_U32_LITTLE(&self->buf[w*4]);
/* Load the left and right lines with the initial state */
AL = AR = self->h[0];
BL = BR = self->h[1];
CL = CR = self->h[2];
DL = DR = self->h[3];
EL = ER = self->h[4];
/* Round 1 */
round = 0;
for (w = 0; w < 16; w++) { /* left line */
T = ROL(SL[round][w], AL + F1(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL;
AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = ROL(SR[round][w], AR + F5(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER;
AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T;
}
/* Round 2 */
round++;
for (w = 0; w < 16; w++) { /* left line */
T = ROL(SL[round][w], AL + F2(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL;
AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = ROL(SR[round][w], AR + F4(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER;
AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T;
}
/* Round 3 */
round++;
for (w = 0; w < 16; w++) { /* left line */
T = ROL(SL[round][w], AL + F3(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL;
AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = ROL(SR[round][w], AR + F3(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER;
AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T;
}
/* Round 4 */
round++;
for (w = 0; w < 16; w++) { /* left line */
T = ROL(SL[round][w], AL + F4(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL;
AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = ROL(SR[round][w], AR + F2(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER;
AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T;
}
/* Round 5 */
round++;
for (w = 0; w < 16; w++) { /* left line */
T = ROL(SL[round][w], AL + F5(BL, CL, DL) + bufw[RL[round][w]] + KL[round]) + EL;
AL = EL; EL = DL; DL = ROL(10, CL); CL = BL; BL = T;
}
for (w = 0; w < 16; w++) { /* right line */
T = ROL(SR[round][w], AR + F1(BR, CR, DR) + bufw[RR[round][w]] + KR[round]) + ER;
AR = ER; ER = DR; DR = ROL(10, CR); CR = BR; BR = T;
}
/* Final mixing stage */
T = self->h[1] + CL + DR;
self->h[1] = self->h[2] + DL + ER;
self->h[2] = self->h[3] + EL + AR;
self->h[3] = self->h[4] + AL + BR;
self->h[4] = self->h[0] + BL + CR;
self->h[0] = T;
/* Clear the buffer and wipe the temporary variables */
T = AL = BL = CL = DL = EL = AR = BR = CR = DR = ER = 0;
memset(&self->buf, 0, sizeof(self->buf));
self->bufpos = 0;
}
开发者ID:Legrandin,项目名称:pycryptodome,代码行数:87,代码来源:RIPEMD160.c
示例20: binary_composer
binary_composer(F1 f1 = F1(), F2 f2 = F2(), F3 f3 = F3())
: _f1(f1), _f2(f2), _f3(f3)
{}
开发者ID:julien-f,项目名称:jfcpp,代码行数:3,代码来源:functional.hpp
注:本文中的F3函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论