.prologue
{ .mmi; .save ar.pfs,prevfs
alloc prevfs=ar.pfs,4,4,0,8
- $ADDP inp=15,in0 // &inp[15]
+ $ADDP inp=15,in2 // &inp[15]
mov rem_4bitp=ip }
-{ .mmi; $ADDP end=in1,in0 // &inp[len]
- $ADDP Xi=15,in2 // &Xi[15]
+{ .mmi; $ADDP end=in3,in2 // &inp[len]
+ $ADDP Xi=15,in0 // &Xi[15]
.save ar.lc,prevlc
mov prevlc=ar.lc };;
-{ .mmi; $ADDP Htbl=8,in3 // &Htbl[0].lo
+{ .mmi; $ADDP Htbl=8,in1 // &Htbl[0].lo
mov mask0xf0=0xf0
.save pr,prevpr
mov prevpr=pr }
# PIII 63 /77 16 24
# P4 96 /122 30 84(***)
# Opteron 50 /71 21 30
-# Core2 63 /102 19 28
+# Core2 54 /68 13 18
#
# (*) gcc 3.4.x was observed to generate few percent slower code,
# which is one of reasons why 2.95.3 results were chosen,
&lea ("eax",&DWP(&label("rem_4bit")."-".&label("pic_point"),"eax"));
- &mov ($inp,&wparam(0)); # load in
- &mov ($Zlh,&wparam(1)); # load len
- &mov ($Zhh,&wparam(2)); # load Xi
- &mov ($Htbl,&wparam(3)); # load Htable
+ &mov ($Zhh,&wparam(0)); # load Xi
+ &mov ($Htbl,&wparam(1)); # load Htable
+ &mov ($inp,&wparam(2)); # load in
+ &mov ($Zlh,&wparam(3)); # load len
&add ($Zlh,$inp);
- &mov (&wparam(1),$Zlh); # len to point at the end of input
+ &mov (&wparam(3),$Zlh); # len to point at the end of input
&stack_push(4+1); # +1 for stack alignment
&mov ($Zll,&DWP(12,$Zhh)); # load Xi[16]
&mov ($Zhl,&DWP(4,$Zhh));
&mmx_loop("esp","eax");
&lea ($inp,&DWP(16,$inp));
- &cmp ($inp,&wparam(1));
+ &cmp ($inp,&wparam(3));
&jb (&label("mmx_outer_loop"));
- &mov ($inp,&wparam(2)); # load Xi
+ &mov ($inp,&wparam(0)); # load Xi
&emms ();
&mov (&DWP(12,$inp),$Zll);
&mov (&DWP(4,$inp),$Zhl);
&set_label("x86",16);
}
&stack_push(16+4+1); # +1 for 64-bit alignment
- &mov ($inp,&wparam(0)); # load in
- &mov ("ecx",&wparam(1)); # load len
- &mov ($Zll,&wparam(2)); # load Xi
- &mov ($Htbl,&wparam(3)); # load Htable
+ &mov ($Zll,&wparam(0)); # load Xi
+ &mov ($Htbl,&wparam(1)); # load Htable
+ &mov ($inp,&wparam(2)); # load in
+ &mov ("ecx",&wparam(3)); # load len
&add ("ecx",$inp);
- &mov (&wparam(1),"ecx");
+ &mov (&wparam(3),"ecx");
&mov ($Zhh,&DWP(0,$Zll)); # load Xi[16]
&mov ($Zhl,&DWP(4,$Zll));
&call ("_x86_gmult_4bit_inner");
} else {
&x86_loop(0);
- &mov ($inp,&wparam(0));
+ &mov ($inp,&wparam(2));
}
&lea ($inp,&DWP(16,$inp));
- &cmp ($inp,&wparam(1));
- &mov (&wparam(0),$inp) if (!$unroll);
+ &cmp ($inp,&wparam(3));
+ &mov (&wparam(2),$inp) if (!$unroll);
&jb (&label("x86_outer_loop"));
- &mov ($inp,&wparam(2)); # load Xi
+ &mov ($inp,&wparam(0)); # load Xi
&mov (&DWP(12,$inp),$Zll);
&mov (&DWP(8,$inp),$Zlh);
&mov (&DWP(4,$inp),$Zhl);
PACK(0xE100), PACK(0xFD20), PACK(0xD940), PACK(0xC560),
PACK(0x9180), PACK(0x8DA0), PACK(0xA9C0), PACK(0xB5E0) };
-static void gcm_gmult_4bit(u64 Xi[2], u128 Htable[16])
+static void gcm_gmult_4bit(u64 Xi[2], const u128 Htable[16])
{
u128 Z;
int cnt = 15;
* mostly as reference and a placeholder for possible future
* non-trivial optimization[s]...
*/
-static void gcm_ghash_4bit(const u8 *inp,size_t len,u64 Xi[2], u128 Htable[16])
+static void gcm_ghash_4bit(u64 Xi[2],const u128 Htable[16],
+ const u8 *inp,size_t len)
{
u128 Z;
int cnt;
}
#endif
#else
-void gcm_gmult_4bit(u64 Xi[2],u128 Htable[16]);
-void gcm_ghash_4bit(const u8 *inp,size_t len,u64 Xi[2],u128 Htable[16]);
+void gcm_gmult_4bit(u64 Xi[2],const u128 Htable[16]);
+void gcm_ghash_4bit(u64 Xi[2],const u128 Htable[16],const u8 *inp,size_t len);
#endif
#define GCM_MUL(ctx,Xi) gcm_gmult_4bit(ctx->Xi.u,ctx->Htable)
#if defined(GHASH_ASM) || !defined(OPENSSL_SMALL_FOOTPRINT)
-#define GHASH(in,len,ctx) gcm_ghash_4bit(in,len,(ctx)->Xi.u,(ctx)->Htable)
+#define GHASH(in,len,ctx) gcm_ghash_4bit((ctx)->Xi.u,(ctx)->Htable,in,len)
/* GHASH_CHUNK is "stride parameter" missioned to mitigate cache
* trashing effect. In other words idea is to hash data while it's
* still in L1 cache after encryption pass... */