2013-01-19 15:39:31 +04:00
# include < l i n u x / l i n k a g e . h >
# enter s a l s a20 _ e n c r y p t _ b y t e s
ENTRY( s a l s a20 _ e n c r y p t _ b y t e s )
2007-12-17 19:04:40 +03:00
mov % r s p ,% r11
and $ 3 1 ,% r11
add $ 2 5 6 ,% r11
sub % r11 ,% r s p
# x = a r g 1
mov % r d i ,% r8
# m = a r g 2
mov % r s i ,% r s i
# out = a r g 3
mov % r d x ,% r d i
# bytes = a r g 4
mov % r c x ,% r d x
# unsigned> ? b y t e s - 0
cmp $ 0 ,% r d x
# comment : fp s t a c k u n c h a n g e d b y j u m p
# goto d o n e i f ! u n s i g n e d >
jbe . _ d o n e
# comment : fp s t a c k u n c h a n g e d b y f a l l t h r o u g h
# start :
._start :
# r1 1 _ s t a c k = r11
movq % r11 ,0 ( % r s p )
# r1 2 _ s t a c k = r12
movq % r12 ,8 ( % r s p )
# r1 3 _ s t a c k = r13
movq % r13 ,1 6 ( % r s p )
# r1 4 _ s t a c k = r14
movq % r14 ,2 4 ( % r s p )
# r1 5 _ s t a c k = r15
movq % r15 ,3 2 ( % r s p )
# rbx_ s t a c k = r b x
movq % r b x ,4 0 ( % r s p )
# rbp_ s t a c k = r b p
movq % r b p ,4 8 ( % r s p )
# in0 = * ( u i n t 6 4 * ) ( x + 0 )
movq 0 ( % r8 ) ,% r c x
# in2 = * ( u i n t 6 4 * ) ( x + 8 )
movq 8 ( % r8 ) ,% r9
# in4 = * ( u i n t 6 4 * ) ( x + 1 6 )
movq 1 6 ( % r8 ) ,% r a x
# in6 = * ( u i n t 6 4 * ) ( x + 2 4 )
movq 2 4 ( % r8 ) ,% r10
# in8 = * ( u i n t 6 4 * ) ( x + 3 2 )
movq 3 2 ( % r8 ) ,% r11
# in1 0 = * ( u i n t 6 4 * ) ( x + 4 0 )
movq 4 0 ( % r8 ) ,% r12
# in1 2 = * ( u i n t 6 4 * ) ( x + 4 8 )
movq 4 8 ( % r8 ) ,% r13
# in1 4 = * ( u i n t 6 4 * ) ( x + 5 6 )
movq 5 6 ( % r8 ) ,% r14
# j0 = i n 0
movq % r c x ,5 6 ( % r s p )
# j2 = i n 2
movq % r9 ,6 4 ( % r s p )
# j4 = i n 4
movq % r a x ,7 2 ( % r s p )
# j6 = i n 6
movq % r10 ,8 0 ( % r s p )
# j8 = i n 8
movq % r11 ,8 8 ( % r s p )
# j1 0 = i n 1 0
movq % r12 ,9 6 ( % r s p )
# j1 2 = i n 1 2
movq % r13 ,1 0 4 ( % r s p )
# j1 4 = i n 1 4
movq % r14 ,1 1 2 ( % r s p )
# x_ b a c k u p = x
movq % r8 ,1 2 0 ( % r s p )
# bytesatleast1 :
._bytesatleast1 :
# unsigned< ? b y t e s - 6 4
cmp $ 6 4 ,% r d x
# comment : fp s t a c k u n c h a n g e d b y j u m p
# goto n o c o p y i f ! u n s i g n e d <
jae . _ n o c o p y
# ctarget = o u t
movq % r d i ,1 2 8 ( % r s p )
# out = & t m p
leaq 1 9 2 ( % r s p ) ,% r d i
# i = b y t e s
mov % r d x ,% r c x
# while ( i ) { * o u t + + = * m + + ; --i }
rep m o v s b
# out = & t m p
leaq 1 9 2 ( % r s p ) ,% r d i
# m = & t m p
leaq 1 9 2 ( % r s p ) ,% r s i
# comment : fp s t a c k u n c h a n g e d b y f a l l t h r o u g h
# nocopy :
._nocopy :
# out_ b a c k u p = o u t
movq % r d i ,1 3 6 ( % r s p )
# m_ b a c k u p = m
movq % r s i ,1 4 4 ( % r s p )
# bytes_ b a c k u p = b y t e s
movq % r d x ,1 5 2 ( % r s p )
# x1 = j 0
movq 5 6 ( % r s p ) ,% r d i
# x0 = x1
mov % r d i ,% r d x
# ( uint6 4 ) x1 > > = 3 2
shr $ 3 2 ,% r d i
# x3 = j 2
movq 6 4 ( % r s p ) ,% r s i
# x2 = x3
mov % r s i ,% r c x
# ( uint6 4 ) x3 > > = 3 2
shr $ 3 2 ,% r s i
# x5 = j 4
movq 7 2 ( % r s p ) ,% r8
# x4 = x5
mov % r8 ,% r9
# ( uint6 4 ) x5 > > = 3 2
shr $ 3 2 ,% r8
# x5 _ s t a c k = x5
movq % r8 ,1 6 0 ( % r s p )
# x7 = j 6
movq 8 0 ( % r s p ) ,% r8
# x6 = x7
mov % r8 ,% r a x
# ( uint6 4 ) x7 > > = 3 2
shr $ 3 2 ,% r8
# x9 = j 8
movq 8 8 ( % r s p ) ,% r10
# x8 = x9
mov % r10 ,% r11
# ( uint6 4 ) x9 > > = 3 2
shr $ 3 2 ,% r10
# x1 1 = j 1 0
movq 9 6 ( % r s p ) ,% r12
# x1 0 = x11
mov % r12 ,% r13
# x1 0 _ s t a c k = x10
movq % r13 ,1 6 8 ( % r s p )
# ( uint6 4 ) x11 > > = 3 2
shr $ 3 2 ,% r12
# x1 3 = j 1 2
movq 1 0 4 ( % r s p ) ,% r13
# x1 2 = x13
mov % r13 ,% r14
# ( uint6 4 ) x13 > > = 3 2
shr $ 3 2 ,% r13
# x1 5 = j 1 4
movq 1 1 2 ( % r s p ) ,% r15
# x1 4 = x15
mov % r15 ,% r b x
# ( uint6 4 ) x15 > > = 3 2
shr $ 3 2 ,% r15
# x1 5 _ s t a c k = x15
movq % r15 ,1 7 6 ( % r s p )
# i = 2 0
mov $ 2 0 ,% r15
# mainloop :
._mainloop :
# i_ b a c k u p = i
movq % r15 ,1 8 4 ( % r s p )
# x5 = x5 _ s t a c k
movq 1 6 0 ( % r s p ) ,% r15
# a = x12 + x0
lea ( % r14 ,% r d x ) ,% r b p
# ( uint3 2 ) a < < < = 7
rol $ 7 ,% e b p
# x4 ^ = a
xor % r b p ,% r9
# b = x1 + x5
lea ( % r d i ,% r15 ) ,% r b p
# ( uint3 2 ) b < < < = 7
rol $ 7 ,% e b p
# x9 ^ = b
xor % r b p ,% r10
# a = x0 + x4
lea ( % r d x ,% r9 ) ,% r b p
# ( uint3 2 ) a < < < = 9
rol $ 9 ,% e b p
# x8 ^ = a
xor % r b p ,% r11
# b = x5 + x9
lea ( % r15 ,% r10 ) ,% r b p
# ( uint3 2 ) b < < < = 9
rol $ 9 ,% e b p
# x1 3 ^ = b
xor % r b p ,% r13
# a = x4 + x8
lea ( % r9 ,% r11 ) ,% r b p
# ( uint3 2 ) a < < < = 1 3
rol $ 1 3 ,% e b p
# x1 2 ^ = a
xor % r b p ,% r14
# b = x9 + x13
lea ( % r10 ,% r13 ) ,% r b p
# ( uint3 2 ) b < < < = 1 3
rol $ 1 3 ,% e b p
# x1 ^ = b
xor % r b p ,% r d i
# a = x8 + x12
lea ( % r11 ,% r14 ) ,% r b p
# ( uint3 2 ) a < < < = 1 8
rol $ 1 8 ,% e b p
# x0 ^ = a
xor % r b p ,% r d x
# b = x13 + x1
lea ( % r13 ,% r d i ) ,% r b p
# ( uint3 2 ) b < < < = 1 8
rol $ 1 8 ,% e b p
# x5 ^ = b
xor % r b p ,% r15
# x1 0 = x10 _ s t a c k
movq 1 6 8 ( % r s p ) ,% r b p
# x5 _ s t a c k = x5
movq % r15 ,1 6 0 ( % r s p )
# c = x6 + x10
lea ( % r a x ,% r b p ) ,% r15
# ( uint3 2 ) c < < < = 7
rol $ 7 ,% r15 d
# x1 4 ^ = c
xor % r15 ,% r b x
# c = x10 + x14
lea ( % r b p ,% r b x ) ,% r15
# ( uint3 2 ) c < < < = 9
rol $ 9 ,% r15 d
# x2 ^ = c
xor % r15 ,% r c x
# c = x14 + x2
lea ( % r b x ,% r c x ) ,% r15
# ( uint3 2 ) c < < < = 1 3
rol $ 1 3 ,% r15 d
# x6 ^ = c
xor % r15 ,% r a x
# c = x2 + x6
lea ( % r c x ,% r a x ) ,% r15
# ( uint3 2 ) c < < < = 1 8
rol $ 1 8 ,% r15 d
# x1 0 ^ = c
xor % r15 ,% r b p
# x1 5 = x15 _ s t a c k
movq 1 7 6 ( % r s p ) ,% r15
# x1 0 _ s t a c k = x10
movq % r b p ,1 6 8 ( % r s p )
# d = x11 + x15
lea ( % r12 ,% r15 ) ,% r b p
# ( uint3 2 ) d < < < = 7
rol $ 7 ,% e b p
# x3 ^ = d
xor % r b p ,% r s i
# d = x15 + x3
lea ( % r15 ,% r s i ) ,% r b p
# ( uint3 2 ) d < < < = 9
rol $ 9 ,% e b p
# x7 ^ = d
xor % r b p ,% r8
# d = x3 + x7
lea ( % r s i ,% r8 ) ,% r b p
# ( uint3 2 ) d < < < = 1 3
rol $ 1 3 ,% e b p
# x1 1 ^ = d
xor % r b p ,% r12
# d = x7 + x11
lea ( % r8 ,% r12 ) ,% r b p
# ( uint3 2 ) d < < < = 1 8
rol $ 1 8 ,% e b p
# x1 5 ^ = d
xor % r b p ,% r15
# x1 5 _ s t a c k = x15
movq % r15 ,1 7 6 ( % r s p )
# x5 = x5 _ s t a c k
movq 1 6 0 ( % r s p ) ,% r15
# a = x3 + x0
lea ( % r s i ,% r d x ) ,% r b p
# ( uint3 2 ) a < < < = 7
rol $ 7 ,% e b p
# x1 ^ = a
xor % r b p ,% r d i
# b = x4 + x5
lea ( % r9 ,% r15 ) ,% r b p
# ( uint3 2 ) b < < < = 7
rol $ 7 ,% e b p
# x6 ^ = b
xor % r b p ,% r a x
# a = x0 + x1
lea ( % r d x ,% r d i ) ,% r b p
# ( uint3 2 ) a < < < = 9
rol $ 9 ,% e b p
# x2 ^ = a
xor % r b p ,% r c x
# b = x5 + x6
lea ( % r15 ,% r a x ) ,% r b p
# ( uint3 2 ) b < < < = 9
rol $ 9 ,% e b p
# x7 ^ = b
xor % r b p ,% r8
# a = x1 + x2
lea ( % r d i ,% r c x ) ,% r b p
# ( uint3 2 ) a < < < = 1 3
rol $ 1 3 ,% e b p
# x3 ^ = a
xor % r b p ,% r s i
# b = x6 + x7
lea ( % r a x ,% r8 ) ,% r b p
# ( uint3 2 ) b < < < = 1 3
rol $ 1 3 ,% e b p
# x4 ^ = b
xor % r b p ,% r9
# a = x2 + x3
lea ( % r c x ,% r s i ) ,% r b p
# ( uint3 2 ) a < < < = 1 8
rol $ 1 8 ,% e b p
# x0 ^ = a
xor % r b p ,% r d x
# b = x7 + x4
lea ( % r8 ,% r9 ) ,% r b p
# ( uint3 2 ) b < < < = 1 8
rol $ 1 8 ,% e b p
# x5 ^ = b
xor % r b p ,% r15
# x1 0 = x10 _ s t a c k
movq 1 6 8 ( % r s p ) ,% r b p
# x5 _ s t a c k = x5
movq % r15 ,1 6 0 ( % r s p )
# c = x9 + x10
lea ( % r10 ,% r b p ) ,% r15
# ( uint3 2 ) c < < < = 7
rol $ 7 ,% r15 d
# x1 1 ^ = c
xor % r15 ,% r12
# c = x10 + x11
lea ( % r b p ,% r12 ) ,% r15
# ( uint3 2 ) c < < < = 9
rol $ 9 ,% r15 d
# x8 ^ = c
xor % r15 ,% r11
# c = x11 + x8
lea ( % r12 ,% r11 ) ,% r15
# ( uint3 2 ) c < < < = 1 3
rol $ 1 3 ,% r15 d
# x9 ^ = c
xor % r15 ,% r10
# c = x8 + x9
lea ( % r11 ,% r10 ) ,% r15
# ( uint3 2 ) c < < < = 1 8
rol $ 1 8 ,% r15 d
# x1 0 ^ = c
xor % r15 ,% r b p
# x1 5 = x15 _ s t a c k
movq 1 7 6 ( % r s p ) ,% r15
# x1 0 _ s t a c k = x10
movq % r b p ,1 6 8 ( % r s p )
# d = x14 + x15
lea ( % r b x ,% r15 ) ,% r b p
# ( uint3 2 ) d < < < = 7
rol $ 7 ,% e b p
# x1 2 ^ = d
xor % r b p ,% r14
# d = x15 + x12
lea ( % r15 ,% r14 ) ,% r b p
# ( uint3 2 ) d < < < = 9
rol $ 9 ,% e b p
# x1 3 ^ = d
xor % r b p ,% r13
# d = x12 + x13
lea ( % r14 ,% r13 ) ,% r b p
# ( uint3 2 ) d < < < = 1 3
rol $ 1 3 ,% e b p
# x1 4 ^ = d
xor % r b p ,% r b x
# d = x13 + x14
lea ( % r13 ,% r b x ) ,% r b p
# ( uint3 2 ) d < < < = 1 8
rol $ 1 8 ,% e b p
# x1 5 ^ = d
xor % r b p ,% r15
# x1 5 _ s t a c k = x15
movq % r15 ,1 7 6 ( % r s p )
# x5 = x5 _ s t a c k
movq 1 6 0 ( % r s p ) ,% r15
# a = x12 + x0
lea ( % r14 ,% r d x ) ,% r b p
# ( uint3 2 ) a < < < = 7
rol $ 7 ,% e b p
# x4 ^ = a
xor % r b p ,% r9
# b = x1 + x5
lea ( % r d i ,% r15 ) ,% r b p
# ( uint3 2 ) b < < < = 7
rol $ 7 ,% e b p
# x9 ^ = b
xor % r b p ,% r10
# a = x0 + x4
lea ( % r d x ,% r9 ) ,% r b p
# ( uint3 2 ) a < < < = 9
rol $ 9 ,% e b p
# x8 ^ = a
xor % r b p ,% r11
# b = x5 + x9
lea ( % r15 ,% r10 ) ,% r b p
# ( uint3 2 ) b < < < = 9
rol $ 9 ,% e b p
# x1 3 ^ = b
xor % r b p ,% r13
# a = x4 + x8
lea ( % r9 ,% r11 ) ,% r b p
# ( uint3 2 ) a < < < = 1 3
rol $ 1 3 ,% e b p
# x1 2 ^ = a
xor % r b p ,% r14
# b = x9 + x13
lea ( % r10 ,% r13 ) ,% r b p
# ( uint3 2 ) b < < < = 1 3
rol $ 1 3 ,% e b p
# x1 ^ = b
xor % r b p ,% r d i
# a = x8 + x12
lea ( % r11 ,% r14 ) ,% r b p
# ( uint3 2 ) a < < < = 1 8
rol $ 1 8 ,% e b p
# x0 ^ = a
xor % r b p ,% r d x
# b = x13 + x1
lea ( % r13 ,% r d i ) ,% r b p
# ( uint3 2 ) b < < < = 1 8
rol $ 1 8 ,% e b p
# x5 ^ = b
xor % r b p ,% r15
# x1 0 = x10 _ s t a c k
movq 1 6 8 ( % r s p ) ,% r b p
# x5 _ s t a c k = x5
movq % r15 ,1 6 0 ( % r s p )
# c = x6 + x10
lea ( % r a x ,% r b p ) ,% r15
# ( uint3 2 ) c < < < = 7
rol $ 7 ,% r15 d
# x1 4 ^ = c
xor % r15 ,% r b x
# c = x10 + x14
lea ( % r b p ,% r b x ) ,% r15
# ( uint3 2 ) c < < < = 9
rol $ 9 ,% r15 d
# x2 ^ = c
xor % r15 ,% r c x
# c = x14 + x2
lea ( % r b x ,% r c x ) ,% r15
# ( uint3 2 ) c < < < = 1 3
rol $ 1 3 ,% r15 d
# x6 ^ = c
xor % r15 ,% r a x
# c = x2 + x6
lea ( % r c x ,% r a x ) ,% r15
# ( uint3 2 ) c < < < = 1 8
rol $ 1 8 ,% r15 d
# x1 0 ^ = c
xor % r15 ,% r b p
# x1 5 = x15 _ s t a c k
movq 1 7 6 ( % r s p ) ,% r15
# x1 0 _ s t a c k = x10
movq % r b p ,1 6 8 ( % r s p )
# d = x11 + x15
lea ( % r12 ,% r15 ) ,% r b p
# ( uint3 2 ) d < < < = 7
rol $ 7 ,% e b p
# x3 ^ = d
xor % r b p ,% r s i
# d = x15 + x3
lea ( % r15 ,% r s i ) ,% r b p
# ( uint3 2 ) d < < < = 9
rol $ 9 ,% e b p
# x7 ^ = d
xor % r b p ,% r8
# d = x3 + x7
lea ( % r s i ,% r8 ) ,% r b p
# ( uint3 2 ) d < < < = 1 3
rol $ 1 3 ,% e b p
# x1 1 ^ = d
xor % r b p ,% r12
# d = x7 + x11
lea ( % r8 ,% r12 ) ,% r b p
# ( uint3 2 ) d < < < = 1 8
rol $ 1 8 ,% e b p
# x1 5 ^ = d
xor % r b p ,% r15
# x1 5 _ s t a c k = x15
movq % r15 ,1 7 6 ( % r s p )
# x5 = x5 _ s t a c k
movq 1 6 0 ( % r s p ) ,% r15
# a = x3 + x0
lea ( % r s i ,% r d x ) ,% r b p
# ( uint3 2 ) a < < < = 7
rol $ 7 ,% e b p
# x1 ^ = a
xor % r b p ,% r d i
# b = x4 + x5
lea ( % r9 ,% r15 ) ,% r b p
# ( uint3 2 ) b < < < = 7
rol $ 7 ,% e b p
# x6 ^ = b
xor % r b p ,% r a x
# a = x0 + x1
lea ( % r d x ,% r d i ) ,% r b p
# ( uint3 2 ) a < < < = 9
rol $ 9 ,% e b p
# x2 ^ = a
xor % r b p ,% r c x
# b = x5 + x6
lea ( % r15 ,% r a x ) ,% r b p
# ( uint3 2 ) b < < < = 9
rol $ 9 ,% e b p
# x7 ^ = b
xor % r b p ,% r8
# a = x1 + x2
lea ( % r d i ,% r c x ) ,% r b p
# ( uint3 2 ) a < < < = 1 3
rol $ 1 3 ,% e b p
# x3 ^ = a
xor % r b p ,% r s i
# b = x6 + x7
lea ( % r a x ,% r8 ) ,% r b p
# ( uint3 2 ) b < < < = 1 3
rol $ 1 3 ,% e b p
# x4 ^ = b
xor % r b p ,% r9
# a = x2 + x3
lea ( % r c x ,% r s i ) ,% r b p
# ( uint3 2 ) a < < < = 1 8
rol $ 1 8 ,% e b p
# x0 ^ = a
xor % r b p ,% r d x
# b = x7 + x4
lea ( % r8 ,% r9 ) ,% r b p
# ( uint3 2 ) b < < < = 1 8
rol $ 1 8 ,% e b p
# x5 ^ = b
xor % r b p ,% r15
# x1 0 = x10 _ s t a c k
movq 1 6 8 ( % r s p ) ,% r b p
# x5 _ s t a c k = x5
movq % r15 ,1 6 0 ( % r s p )
# c = x9 + x10
lea ( % r10 ,% r b p ) ,% r15
# ( uint3 2 ) c < < < = 7
rol $ 7 ,% r15 d
# x1 1 ^ = c
xor % r15 ,% r12
# c = x10 + x11
lea ( % r b p ,% r12 ) ,% r15
# ( uint3 2 ) c < < < = 9
rol $ 9 ,% r15 d
# x8 ^ = c
xor % r15 ,% r11
# c = x11 + x8
lea ( % r12 ,% r11 ) ,% r15
# ( uint3 2 ) c < < < = 1 3
rol $ 1 3 ,% r15 d
# x9 ^ = c
xor % r15 ,% r10
# c = x8 + x9
lea ( % r11 ,% r10 ) ,% r15
# ( uint3 2 ) c < < < = 1 8
rol $ 1 8 ,% r15 d
# x1 0 ^ = c
xor % r15 ,% r b p
# x1 5 = x15 _ s t a c k
movq 1 7 6 ( % r s p ) ,% r15
# x1 0 _ s t a c k = x10
movq % r b p ,1 6 8 ( % r s p )
# d = x14 + x15
lea ( % r b x ,% r15 ) ,% r b p
# ( uint3 2 ) d < < < = 7
rol $ 7 ,% e b p
# x1 2 ^ = d
xor % r b p ,% r14
# d = x15 + x12
lea ( % r15 ,% r14 ) ,% r b p
# ( uint3 2 ) d < < < = 9
rol $ 9 ,% e b p
# x1 3 ^ = d
xor % r b p ,% r13
# d = x12 + x13
lea ( % r14 ,% r13 ) ,% r b p
# ( uint3 2 ) d < < < = 1 3
rol $ 1 3 ,% e b p
# x1 4 ^ = d
xor % r b p ,% r b x
# d = x13 + x14
lea ( % r13 ,% r b x ) ,% r b p
# ( uint3 2 ) d < < < = 1 8
rol $ 1 8 ,% e b p
# x1 5 ^ = d
xor % r b p ,% r15
# x1 5 _ s t a c k = x15
movq % r15 ,1 7 6 ( % r s p )
# i = i _ b a c k u p
movq 1 8 4 ( % r s p ) ,% r15
# unsigned> ? i - = 4
sub $ 4 ,% r15
# comment : fp s t a c k u n c h a n g e d b y j u m p
# goto m a i n l o o p i f u n s i g n e d >
ja . _ m a i n l o o p
# ( uint3 2 ) x2 + = j 2
addl 6 4 ( % r s p ) ,% e c x
# x3 < < = 3 2
shl $ 3 2 ,% r s i
# x3 + = j 2
addq 6 4 ( % r s p ) ,% r s i
# ( uint6 4 ) x3 > > = 3 2
shr $ 3 2 ,% r s i
# x3 < < = 3 2
shl $ 3 2 ,% r s i
# x2 + = x3
add % r s i ,% r c x
# ( uint3 2 ) x6 + = j 6
addl 8 0 ( % r s p ) ,% e a x
# x7 < < = 3 2
shl $ 3 2 ,% r8
# x7 + = j 6
addq 8 0 ( % r s p ) ,% r8
# ( uint6 4 ) x7 > > = 3 2
shr $ 3 2 ,% r8
# x7 < < = 3 2
shl $ 3 2 ,% r8
# x6 + = x7
add % r8 ,% r a x
# ( uint3 2 ) x8 + = j 8
addl 8 8 ( % r s p ) ,% r11 d
# x9 < < = 3 2
shl $ 3 2 ,% r10
# x9 + = j 8
addq 8 8 ( % r s p ) ,% r10
# ( uint6 4 ) x9 > > = 3 2
shr $ 3 2 ,% r10
# x9 < < = 3 2
shl $ 3 2 ,% r10
# x8 + = x9
add % r10 ,% r11
# ( uint3 2 ) x12 + = j 1 2
addl 1 0 4 ( % r s p ) ,% r14 d
# x1 3 < < = 3 2
shl $ 3 2 ,% r13
# x1 3 + = j 1 2
addq 1 0 4 ( % r s p ) ,% r13
# ( uint6 4 ) x13 > > = 3 2
shr $ 3 2 ,% r13
# x1 3 < < = 3 2
shl $ 3 2 ,% r13
# x1 2 + = x13
add % r13 ,% r14
# ( uint3 2 ) x0 + = j 0
addl 5 6 ( % r s p ) ,% e d x
# x1 < < = 3 2
shl $ 3 2 ,% r d i
# x1 + = j 0
addq 5 6 ( % r s p ) ,% r d i
# ( uint6 4 ) x1 > > = 3 2
shr $ 3 2 ,% r d i
# x1 < < = 3 2
shl $ 3 2 ,% r d i
# x0 + = x1
add % r d i ,% r d x
# x5 = x5 _ s t a c k
movq 1 6 0 ( % r s p ) ,% r d i
# ( uint3 2 ) x4 + = j 4
addl 7 2 ( % r s p ) ,% r9 d
# x5 < < = 3 2
shl $ 3 2 ,% r d i
# x5 + = j 4
addq 7 2 ( % r s p ) ,% r d i
# ( uint6 4 ) x5 > > = 3 2
shr $ 3 2 ,% r d i
# x5 < < = 3 2
shl $ 3 2 ,% r d i
# x4 + = x5
add % r d i ,% r9
# x1 0 = x10 _ s t a c k
movq 1 6 8 ( % r s p ) ,% r8
# ( uint3 2 ) x10 + = j 1 0
addl 9 6 ( % r s p ) ,% r8 d
# x1 1 < < = 3 2
shl $ 3 2 ,% r12
# x1 1 + = j 1 0
addq 9 6 ( % r s p ) ,% r12
# ( uint6 4 ) x11 > > = 3 2
shr $ 3 2 ,% r12
# x1 1 < < = 3 2
shl $ 3 2 ,% r12
# x1 0 + = x11
add % r12 ,% r8
# x1 5 = x15 _ s t a c k
movq 1 7 6 ( % r s p ) ,% r d i
# ( uint3 2 ) x14 + = j 1 4
addl 1 1 2 ( % r s p ) ,% e b x
# x1 5 < < = 3 2
shl $ 3 2 ,% r d i
# x1 5 + = j 1 4
addq 1 1 2 ( % r s p ) ,% r d i
# ( uint6 4 ) x15 > > = 3 2
shr $ 3 2 ,% r d i
# x1 5 < < = 3 2
shl $ 3 2 ,% r d i
# x1 4 + = x15
add % r d i ,% r b x
# out = o u t _ b a c k u p
movq 1 3 6 ( % r s p ) ,% r d i
# m = m _ b a c k u p
movq 1 4 4 ( % r s p ) ,% r s i
# x0 ^ = * ( u i n t 6 4 * ) ( m + 0 )
xorq 0 ( % r s i ) ,% r d x
# * ( uint6 4 * ) ( o u t + 0 ) = x0
movq % r d x ,0 ( % r d i )
# x2 ^ = * ( u i n t 6 4 * ) ( m + 8 )
xorq 8 ( % r s i ) ,% r c x
# * ( uint6 4 * ) ( o u t + 8 ) = x2
movq % r c x ,8 ( % r d i )
# x4 ^ = * ( u i n t 6 4 * ) ( m + 1 6 )
xorq 1 6 ( % r s i ) ,% r9
# * ( uint6 4 * ) ( o u t + 1 6 ) = x4
movq % r9 ,1 6 ( % r d i )
# x6 ^ = * ( u i n t 6 4 * ) ( m + 2 4 )
xorq 2 4 ( % r s i ) ,% r a x
# * ( uint6 4 * ) ( o u t + 2 4 ) = x6
movq % r a x ,2 4 ( % r d i )
# x8 ^ = * ( u i n t 6 4 * ) ( m + 3 2 )
xorq 3 2 ( % r s i ) ,% r11
# * ( uint6 4 * ) ( o u t + 3 2 ) = x8
movq % r11 ,3 2 ( % r d i )
# x1 0 ^ = * ( u i n t 6 4 * ) ( m + 4 0 )
xorq 4 0 ( % r s i ) ,% r8
# * ( uint6 4 * ) ( o u t + 4 0 ) = x10
movq % r8 ,4 0 ( % r d i )
# x1 2 ^ = * ( u i n t 6 4 * ) ( m + 4 8 )
xorq 4 8 ( % r s i ) ,% r14
# * ( uint6 4 * ) ( o u t + 4 8 ) = x12
movq % r14 ,4 8 ( % r d i )
# x1 4 ^ = * ( u i n t 6 4 * ) ( m + 5 6 )
xorq 5 6 ( % r s i ) ,% r b x
# * ( uint6 4 * ) ( o u t + 5 6 ) = x14
movq % r b x ,5 6 ( % r d i )
# bytes = b y t e s _ b a c k u p
movq 1 5 2 ( % r s p ) ,% r d x
# in8 = j 8
movq 8 8 ( % r s p ) ,% r c x
# in8 + = 1
add $ 1 ,% r c x
# j8 = i n 8
movq % r c x ,8 8 ( % r s p )
# unsigned> ? u n s i g n e d < ? b y t e s - 6 4
cmp $ 6 4 ,% r d x
# comment : fp s t a c k u n c h a n g e d b y j u m p
# goto b y t e s a t l e a s t 6 5 i f u n s i g n e d >
ja . _ b y t e s a t l e a s t 6 5
# comment : fp s t a c k u n c h a n g e d b y j u m p
# goto b y t e s a t l e a s t 6 4 i f ! u n s i g n e d <
jae . _ b y t e s a t l e a s t 6 4
# m = o u t
mov % r d i ,% r s i
# out = c t a r g e t
movq 1 2 8 ( % r s p ) ,% r d i
# i = b y t e s
mov % r d x ,% r c x
# while ( i ) { * o u t + + = * m + + ; --i }
rep m o v s b
# comment : fp s t a c k u n c h a n g e d b y f a l l t h r o u g h
# bytesatleast64 :
._bytesatleast64 :
# x = x _ b a c k u p
movq 1 2 0 ( % r s p ) ,% r d i
# in8 = j 8
movq 8 8 ( % r s p ) ,% r s i
# * ( uint6 4 * ) ( x + 3 2 ) = i n 8
movq % r s i ,3 2 ( % r d i )
# r1 1 = r11 _ s t a c k
movq 0 ( % r s p ) ,% r11
# r1 2 = r12 _ s t a c k
movq 8 ( % r s p ) ,% r12
# r1 3 = r13 _ s t a c k
movq 1 6 ( % r s p ) ,% r13
# r1 4 = r14 _ s t a c k
movq 2 4 ( % r s p ) ,% r14
# r1 5 = r15 _ s t a c k
movq 3 2 ( % r s p ) ,% r15
# rbx = r b x _ s t a c k
movq 4 0 ( % r s p ) ,% r b x
# rbp = r b p _ s t a c k
movq 4 8 ( % r s p ) ,% r b p
# comment : fp s t a c k u n c h a n g e d b y f a l l t h r o u g h
# done :
._done :
# leave
add % r11 ,% r s p
mov % r d i ,% r a x
mov % r s i ,% r d x
ret
# bytesatleast65 :
._bytesatleast65 :
# bytes - = 6 4
sub $ 6 4 ,% r d x
# out + = 6 4
add $ 6 4 ,% r d i
# m + = 6 4
add $ 6 4 ,% r s i
# comment : fp s t a c k u n c h a n g e d b y j u m p
# goto b y t e s a t l e a s t 1
jmp . _ b y t e s a t l e a s t 1
2013-01-19 15:39:31 +04:00
ENDPROC( s a l s a20 _ e n c r y p t _ b y t e s )
# enter s a l s a20 _ k e y s e t u p
ENTRY( s a l s a20 _ k e y s e t u p )
2007-12-17 19:04:40 +03:00
mov % r s p ,% r11
and $ 3 1 ,% r11
add $ 2 5 6 ,% r11
sub % r11 ,% r s p
# k = a r g 2
mov % r s i ,% r s i
# kbits = a r g 3
mov % r d x ,% r d x
# x = a r g 1
mov % r d i ,% r d i
# in0 = * ( u i n t 6 4 * ) ( k + 0 )
movq 0 ( % r s i ) ,% r8
# in2 = * ( u i n t 6 4 * ) ( k + 8 )
movq 8 ( % r s i ) ,% r9
# * ( uint6 4 * ) ( x + 4 ) = i n 0
movq % r8 ,4 ( % r d i )
# * ( uint6 4 * ) ( x + 1 2 ) = i n 2
movq % r9 ,1 2 ( % r d i )
# unsigned< ? k b i t s - 2 5 6
cmp $ 2 5 6 ,% r d x
# comment : fp s t a c k u n c h a n g e d b y j u m p
# goto k b i t s12 8 i f u n s i g n e d <
jb . _ k b i t s12 8
# kbits256 :
._kbits256 :
# in1 0 = * ( u i n t 6 4 * ) ( k + 1 6 )
movq 1 6 ( % r s i ) ,% r d x
# in1 2 = * ( u i n t 6 4 * ) ( k + 2 4 )
movq 2 4 ( % r s i ) ,% r s i
# * ( uint6 4 * ) ( x + 4 4 ) = i n 1 0
movq % r d x ,4 4 ( % r d i )
# * ( uint6 4 * ) ( x + 5 2 ) = i n 1 2
movq % r s i ,5 2 ( % r d i )
# in0 = 1 6 3 4 7 6 0 8 0 5
mov $ 1 6 3 4 7 6 0 8 0 5 ,% r s i
# in4 = 8 5 7 7 6 0 8 7 8
mov $ 8 5 7 7 6 0 8 7 8 ,% r d x
# in1 0 = 2 0 3 6 4 7 7 2 3 4
mov $ 2 0 3 6 4 7 7 2 3 4 ,% r c x
# in1 4 = 1 7 9 7 2 8 5 2 3 6
mov $ 1 7 9 7 2 8 5 2 3 6 ,% r8
# * ( uint3 2 * ) ( x + 0 ) = i n 0
movl % e s i ,0 ( % r d i )
# * ( uint3 2 * ) ( x + 2 0 ) = i n 4
movl % e d x ,2 0 ( % r d i )
# * ( uint3 2 * ) ( x + 4 0 ) = i n 1 0
movl % e c x ,4 0 ( % r d i )
# * ( uint3 2 * ) ( x + 6 0 ) = i n 1 4
movl % r8 d ,6 0 ( % r d i )
# comment : fp s t a c k u n c h a n g e d b y j u m p
# goto k e y s e t u p d o n e
jmp . _ k e y s e t u p d o n e
# kbits128 :
._kbits128 :
# in1 0 = * ( u i n t 6 4 * ) ( k + 0 )
movq 0 ( % r s i ) ,% r d x
# in1 2 = * ( u i n t 6 4 * ) ( k + 8 )
movq 8 ( % r s i ) ,% r s i
# * ( uint6 4 * ) ( x + 4 4 ) = i n 1 0
movq % r d x ,4 4 ( % r d i )
# * ( uint6 4 * ) ( x + 5 2 ) = i n 1 2
movq % r s i ,5 2 ( % r d i )
# in0 = 1 6 3 4 7 6 0 8 0 5
mov $ 1 6 3 4 7 6 0 8 0 5 ,% r s i
# in4 = 8 2 4 2 0 6 4 4 6
mov $ 8 2 4 2 0 6 4 4 6 ,% r d x
# in1 0 = 2 0 3 6 4 7 7 2 3 8
mov $ 2 0 3 6 4 7 7 2 3 8 ,% r c x
# in1 4 = 1 7 9 7 2 8 5 2 3 6
mov $ 1 7 9 7 2 8 5 2 3 6 ,% r8
# * ( uint3 2 * ) ( x + 0 ) = i n 0
movl % e s i ,0 ( % r d i )
# * ( uint3 2 * ) ( x + 2 0 ) = i n 4
movl % e d x ,2 0 ( % r d i )
# * ( uint3 2 * ) ( x + 4 0 ) = i n 1 0
movl % e c x ,4 0 ( % r d i )
# * ( uint3 2 * ) ( x + 6 0 ) = i n 1 4
movl % r8 d ,6 0 ( % r d i )
# keysetupdone :
._keysetupdone :
# leave
add % r11 ,% r s p
mov % r d i ,% r a x
mov % r s i ,% r d x
ret
2013-01-19 15:39:31 +04:00
ENDPROC( s a l s a20 _ k e y s e t u p )
# enter s a l s a20 _ i v s e t u p
ENTRY( s a l s a20 _ i v s e t u p )
2007-12-17 19:04:40 +03:00
mov % r s p ,% r11
and $ 3 1 ,% r11
add $ 2 5 6 ,% r11
sub % r11 ,% r s p
# iv = a r g 2
mov % r s i ,% r s i
# x = a r g 1
mov % r d i ,% r d i
# in6 = * ( u i n t 6 4 * ) ( i v + 0 )
movq 0 ( % r s i ) ,% r s i
# in8 = 0
mov $ 0 ,% r8
# * ( uint6 4 * ) ( x + 2 4 ) = i n 6
movq % r s i ,2 4 ( % r d i )
# * ( uint6 4 * ) ( x + 3 2 ) = i n 8
movq % r8 ,3 2 ( % r d i )
# leave
add % r11 ,% r s p
mov % r d i ,% r a x
mov % r s i ,% r d x
ret
2013-01-19 15:39:31 +04:00
ENDPROC( s a l s a20 _ i v s e t u p )