diff options
author | Adam Langley <agl@google.com> | 2015-06-23 16:28:07 -0700 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-06-23 16:33:55 -0700 |
commit | bd9957e6e28506c4431ce8d3cadbc0a04905b15e (patch) | |
tree | 25164b0a84665df0c05eb07a4abb82b39fa6d6a0 /linux-x86_64/crypto/rand/rdrand-x86_64.S | |
parent | e0846beeb321f7d3170e4e389950b12fce69ab10 (diff) | |
download | external_boringssl-bd9957e6e28506c4431ce8d3cadbc0a04905b15e.zip external_boringssl-bd9957e6e28506c4431ce8d3cadbc0a04905b15e.tar.gz external_boringssl-bd9957e6e28506c4431ce8d3cadbc0a04905b15e.tar.bz2 |
Handle RDRAND failures.
I mistakenly believed that only RDSEED could fail. However, the Intel
manuals state that RDRAND can fail too.
This change cherry-picks the following BoringSSL changes:
2cac3506 – Handle RDRAND failures.
248abbd7 – Add missing comma in .type pragma for rdrand code.
Change-Id: Icdc56a50ce36e9c525063583882c676a5312d313
Diffstat (limited to 'linux-x86_64/crypto/rand/rdrand-x86_64.S')
-rw-r--r-- | linux-x86_64/crypto/rand/rdrand-x86_64.S | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/linux-x86_64/crypto/rand/rdrand-x86_64.S b/linux-x86_64/crypto/rand/rdrand-x86_64.S index 622ae55..94aab9c 100644 --- a/linux-x86_64/crypto/rand/rdrand-x86_64.S +++ b/linux-x86_64/crypto/rand/rdrand-x86_64.S @@ -1,11 +1,48 @@ #if defined(__x86_64__) .text + + + .globl CRYPTO_rdrand .hidden CRYPTO_rdrand .type CRYPTO_rdrand,@function .align 16 CRYPTO_rdrand: -.byte 0x48, 0x0f, 0xc7, 0xf0 + xorq %rax,%rax + + +.byte 0x48, 0x0f, 0xc7, 0xf1 + + adcq %rax,%rax + movq %rcx,0(%rdi) + .byte 0xf3,0xc3 + + + + + +.globl CRYPTO_rdrand_multiple8_buf +.hidden CRYPTO_rdrand_multiple8_buf +.type CRYPTO_rdrand_multiple8_buf,@function +.align 16 +CRYPTO_rdrand_multiple8_buf: + testq %rsi,%rsi + jz .Lout + movq $8,%rdx +.Lloop: + + +.byte 0x48, 0x0f, 0xc7, 0xf1 + jnc .Lerr + movq %rcx,0(%rdi) + addq %rdx,%rdi + subq %rdx,%rsi + jnz .Lloop +.Lout: + movq $1,%rax + .byte 0xf3,0xc3 +.Lerr: + xorq %rax,%rax .byte 0xf3,0xc3 #endif |