summaryrefslogtreecommitdiffstats
path: root/win-x86_64/crypto/rand/rdrand-x86_64.asm
blob: 4c03791b48efed0eda7140d590c3da8faeeb9ec9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
default	rel
%define XMMWORD
%define YMMWORD
%define ZMMWORD
section	.text code align=64





global	CRYPTO_rdrand

ALIGN	16
CRYPTO_rdrand:
	mov	QWORD[8+rsp],rdi	;WIN64 prologue
	mov	QWORD[16+rsp],rsi
	mov	rax,rsp
$L$SEH_begin_CRYPTO_rdrand:
	mov	rdi,rcx


	xor	rax,rax


DB	0x48,0x0f,0xc7,0xf1

	adc	rax,rax
	mov	QWORD[rdi],rcx
	mov	rdi,QWORD[8+rsp]	;WIN64 epilogue
	mov	rsi,QWORD[16+rsp]
	DB	0F3h,0C3h		;repret





global	CRYPTO_rdrand_multiple8_buf

ALIGN	16
CRYPTO_rdrand_multiple8_buf:
	mov	QWORD[8+rsp],rdi	;WIN64 prologue
	mov	QWORD[16+rsp],rsi
	mov	rax,rsp
$L$SEH_begin_CRYPTO_rdrand_multiple8_buf:
	mov	rdi,rcx
	mov	rsi,rdx


	test	rsi,rsi
	jz	NEAR $L$out
	mov	rdx,8
$L$loop:


DB	0x48,0x0f,0xc7,0xf1
	jnc	NEAR $L$err
	mov	QWORD[rdi],rcx
	add	rdi,rdx
	sub	rsi,rdx
	jnz	NEAR $L$loop
$L$out:
	mov	rax,1
	mov	rdi,QWORD[8+rsp]	;WIN64 epilogue
	mov	rsi,QWORD[16+rsp]
	DB	0F3h,0C3h		;repret
$L$err:
	xor	rax,rax
	mov	rdi,QWORD[8+rsp]	;WIN64 epilogue
	mov	rsi,QWORD[16+rsp]
	DB	0F3h,0C3h		;repret