2015-03-10 09:47:48 +01:00
/ *
* Accelerated G H A S H i m p l e m e n t a t i o n w i t h A R M v8 v m u l l . p64 i n s t r u c t i o n s .
*
* Copyright ( C ) 2 0 1 5 L i n a r o L t d . < a r d . b i e s h e u v e l @linaro.org>
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify it
* under t h e t e r m s o f t h e G N U G e n e r a l P u b l i c L i c e n s e v e r s i o n 2 a s p u b l i s h e d
* by t h e F r e e S o f t w a r e F o u n d a t i o n .
* /
# include < l i n u x / l i n k a g e . h >
# include < a s m / a s s e m b l e r . h >
SHASH . r e q q0
SHASH2 . r e q q1
T1 . r e q q2
T2 . r e q q3
MASK . r e q q4
XL . r e q q5
XM . r e q q6
XH . r e q q7
IN1 . r e q q7
SHASH_ L . r e q d0
SHASH_ H . r e q d1
SHASH2 _ L . r e q d2
T1 _ L . r e q d4
MASK_ L . r e q d8
XL_ L . r e q d10
XL_ H . r e q d11
XM_ L . r e q d12
XM_ H . r e q d13
XH_ L . r e q d14
.text
.fpu crypto- n e o n - f p - a r m v8
/ *
* void p m u l l _ g h a s h _ u p d a t e ( i n t b l o c k s , u 6 4 d g [ ] , c o n s t c h a r * s r c ,
* struct g h a s h _ k e y c o n s t * k , c o n s t c h a r * h e a d )
* /
ENTRY( p m u l l _ g h a s h _ u p d a t e )
2015-03-23 21:33:09 +01:00
vld1 . 6 4 { S H A S H } , [ r3 ]
2015-03-10 09:47:48 +01:00
vld1 . 6 4 { X L } , [ r1 ]
vmov. i 8 M A S K , #0xe1
vext. 8 S H A S H 2 , S H A S H , S H A S H , #8
vshl. u 6 4 M A S K , M A S K , #57
veor S H A S H 2 , S H A S H 2 , S H A S H
/* do the head block first, if supplied */
ldr i p , [ s p ]
teq i p , #0
beq 0 f
vld1 . 6 4 { T 1 } , [ i p ]
teq r0 , #0
b 1 f
0 : vld1 . 6 4 { T 1 } , [ r2 ] !
subs r0 , r0 , #1
1 : /* multiply XL by SHASH in GF(2^128) */
# ifndef C O N F I G _ C P U _ B I G _ E N D I A N
vrev6 4 . 8 T 1 , T 1
# endif
vext. 8 T 2 , X L , X L , #8
vext. 8 I N 1 , T 1 , T 1 , #8
veor T 1 , T 1 , T 2
veor X L , X L , I N 1
vmull. p64 X H , S H A S H _ H , X L _ H @ a1 * b1
veor T 1 , T 1 , X L
vmull. p64 X L , S H A S H _ L , X L _ L @ a0 * b0
vmull. p64 X M , S H A S H 2 _ L , T 1 _ L @ (a1 + a0)(b1 + b0)
vext. 8 T 1 , X L , X H , #8
veor T 2 , X L , X H
veor X M , X M , T 1
veor X M , X M , T 2
vmull. p64 T 2 , X L _ L , M A S K _ L
vmov X H _ L , X M _ H
vmov X M _ H , X L _ L
veor X L , X M , T 2
vext. 8 T 2 , X L , X L , #8
vmull. p64 X L , X L _ L , M A S K _ L
veor T 2 , T 2 , X H
veor X L , X L , T 2
bne 0 b
vst1 . 6 4 { X L } , [ r1 ]
bx l r
ENDPROC( p m u l l _ g h a s h _ u p d a t e )