FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
rawhttps/src/tls/crypto/random.asm at master · felipeek/rawhttps · GitHub
felipeek
/
rawhttps
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
rawhttps
/
src
/
tls
/
crypto
/
random.asm
Copy path
More file actions
More file actions
Latest commit
History
History
History
63 lines (56 loc) · 1.39 KB
Breadcrumbs
rawhttps
/
src
/
tls
/
crypto
/
random.asm
Copy path
File metadata and controls
63 lines (56 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
; ----------------------------------------------------------------------------------------
; nasm -felf64 hello.asm
; ----------------------------------------------------------------------------------------
%ifdef
__APPLE__
global
_random_64bit_integer
global
_random_integer
global
_clock_counter
global
_random_s64
global
_is_pow2
_random_64bit_integer:
jmp
random_64bit_integer
_random_integer:
jmp
random_integer
_clock_counter:
jmp
clock_counter
_random_s64:
jmp
random_s64
_is_pow2:
jmp
is_pow2
%else
global
random_64bit_integer
global
random_integer
global
clock_counter
global
random_s64
global
is_pow2
%endif
section
.text
random_64bit_integer:
%ifdef
__APPLE__
; rdseed is not available on M2, not even when running amd64 code.
; For now we will simply return 0, this obviously need to be implemented
mov
rax
,
0
%else
rdseed
rax
%endif
ret
random_s64:
random_integer:
%ifdef
__APPLE__
; rdseed is not available on M2, not even when running amd64 code.
; For now we will simply consider 0, this obviously need to be implemented
mov
rax
,
0
%else
rdseed
rax
; R
%endif
;rdrand rax
xor
rdx
,
rdx
sub
rsi
,
rdi
; max = max - min
div
rsi
; R % max
mov
rax
,
rdx
; modulo
add
rax
,
rdi
; min + (R % max)
ret
clock_counter:
xor
rax
,
rax
rdtsc
shl
rdx
,
32
or
rax
,
rdx
ret
is_pow2:
blsr
rax
,
rdi
ret
Back
|
FazBrowse Home
|
New Git URL