mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-27 04:36:19 +08:00
internal/sm2ec: ppc64le, change p256NegCond to constant-time
This commit is contained in:
parent
b69000109b
commit
35d5ddeaf4
@ -121,15 +121,20 @@ GLOBL p256mul<>(SB), 8, $96
|
|||||||
#define PL V30
|
#define PL V30
|
||||||
#define PH V31
|
#define PH V31
|
||||||
|
|
||||||
|
#define SEL V4
|
||||||
|
#define ZER V5
|
||||||
#define CAR1 V6
|
#define CAR1 V6
|
||||||
// func p256NegCond(val *p256Point, cond int)
|
// func p256NegCond(val *p256Point, cond int)
|
||||||
TEXT ·p256NegCond(SB), NOSPLIT, $0-16
|
TEXT ·p256NegCond(SB), NOSPLIT, $0-16
|
||||||
MOVD val+0(FP), P1ptr
|
MOVD val+0(FP), P1ptr
|
||||||
MOVD $16, R16
|
MOVD $16, R16
|
||||||
|
MOVD $48, R17
|
||||||
|
|
||||||
MOVD cond+8(FP), R6
|
// cond is R1 + 16 (cond offset) + 32
|
||||||
CMP $0, R6
|
LXVDSX (R1)(R17), SEL
|
||||||
BC 12, 2, LR // just return if cond == 0
|
VSPLTISB $0, ZER
|
||||||
|
// SEL controls whether to store a or b
|
||||||
|
VCMPEQUD SEL, ZER, SEL
|
||||||
|
|
||||||
MOVD $p256mul<>+0x00(SB), CPOOL
|
MOVD $p256mul<>+0x00(SB), CPOOL
|
||||||
|
|
||||||
@ -146,11 +151,14 @@ TEXT ·p256NegCond(SB), NOSPLIT, $0-16
|
|||||||
VSUBUQM PL, Y1L, T1L // subtract part2 giving result
|
VSUBUQM PL, Y1L, T1L // subtract part2 giving result
|
||||||
VSUBEUQM PH, Y1H, CAR1, T1H // subtract part1 using carry from part2
|
VSUBEUQM PH, Y1H, CAR1, T1H // subtract part1 using carry from part2
|
||||||
|
|
||||||
XXPERMDI T1H, T1H, $2, T1H
|
VSEL X1H, T1H, SEL, X1H
|
||||||
XXPERMDI T1L, T1L, $2, T1L
|
VSEL X1L, T1L, SEL, X1L
|
||||||
|
|
||||||
STXVD2X T1L, (R0+P1ptr)
|
XXPERMDI X1H, X1H, $2, X1H
|
||||||
STXVD2X T1H, (R16+P1ptr)
|
XXPERMDI X1L, X1L, $2, X1L
|
||||||
|
|
||||||
|
STXVD2X X1L, (R0+P1ptr)
|
||||||
|
STXVD2X X1H, (R16+P1ptr)
|
||||||
RET
|
RET
|
||||||
|
|
||||||
#undef P1ptr
|
#undef P1ptr
|
||||||
@ -161,6 +169,8 @@ TEXT ·p256NegCond(SB), NOSPLIT, $0-16
|
|||||||
#undef T1H
|
#undef T1H
|
||||||
#undef PL
|
#undef PL
|
||||||
#undef PH
|
#undef PH
|
||||||
|
#undef ZER
|
||||||
|
#undef SEL
|
||||||
#undef CAR1
|
#undef CAR1
|
||||||
|
|
||||||
#define P3ptr R3
|
#define P3ptr R3
|
||||||
|
Loading…
x
Reference in New Issue
Block a user