summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt <>2014-06-02 15:08:38 +0000
committerderaadt <>2014-06-02 15:08:38 +0000
commit5df353beff71ba1f1e84cd691ef3edf892aa5311 (patch)
tree9705407a292ffa9e8df2ed301da2accffe5268ad
parent599c6f06ff6ff9ca9526b1c08abb02d14f3501c4 (diff)
downloadopenbsd-5df353beff71ba1f1e84cd691ef3edf892aa5311.tar.gz
openbsd-5df353beff71ba1f1e84cd691ef3edf892aa5311.tar.bz2
openbsd-5df353beff71ba1f1e84cd691ef3edf892aa5311.zip
A few months back there was a big community fuss regarding direct-use
of the intel RDRAND instruction. Consensus was RDRAND should probably only be used as an additional source of entropy in a mixer. Guess which library bends over backwards to provide easy access to RDRAND? Yep. Guess which applications are using this support? Not even one... but still, this is being placed as a trap for someone. Send this support straight to the abyss. ok kettenis
-rw-r--r--src/lib/libcrypto/crypto/Makefile4
-rw-r--r--src/lib/libcrypto/engine/eng_all.c3
-rw-r--r--src/lib/libcrypto/engine/eng_rdrand.c139
-rw-r--r--src/lib/libcrypto/engine/engine.h1
-rwxr-xr-xsrc/lib/libcrypto/perlasm/x86_64-xlate.pl13
-rw-r--r--src/lib/libcrypto/perlasm/x86asm.pl8
-rw-r--r--src/lib/libcrypto/x86_64cpuid.pl17
-rw-r--r--src/lib/libcrypto/x86cpuid.pl12
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_all.c3
-rw-r--r--src/lib/libssl/src/crypto/engine/eng_rdrand.c139
-rw-r--r--src/lib/libssl/src/crypto/engine/engine.h1
-rwxr-xr-xsrc/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl13
-rw-r--r--src/lib/libssl/src/crypto/perlasm/x86asm.pl8
-rw-r--r--src/lib/libssl/src/crypto/x86_64cpuid.pl17
-rw-r--r--src/lib/libssl/src/crypto/x86cpuid.pl12
15 files changed, 2 insertions, 388 deletions
diff --git a/src/lib/libcrypto/crypto/Makefile b/src/lib/libcrypto/crypto/Makefile
index 9acf6701c5..1e2ce774d3 100644
--- a/src/lib/libcrypto/crypto/Makefile
+++ b/src/lib/libcrypto/crypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.37 2014/05/25 17:29:51 tedu Exp $ 1# $OpenBSD: Makefile,v 1.38 2014/06/02 15:08:38 deraadt Exp $
2 2
3LIB= crypto 3LIB= crypto
4 4
@@ -133,7 +133,7 @@ SRCS+= eng_table.c eng_pkey.c eng_fat.c eng_all.c
133SRCS+= tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c 133SRCS+= tb_rsa.c tb_dsa.c tb_ecdsa.c tb_dh.c tb_ecdh.c tb_rand.c tb_store.c
134SRCS+= tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c 134SRCS+= tb_cipher.c tb_digest.c tb_pkmeth.c tb_asnmth.c
135SRCS+= eng_openssl.c eng_cnf.c eng_dyn.c hw_cryptodev.c 135SRCS+= eng_openssl.c eng_cnf.c eng_dyn.c hw_cryptodev.c
136SRCS+= eng_rsax.c eng_rdrand.c 136SRCS+= eng_rsax.c
137# XXX unnecessary? handled in EVP now... 137# XXX unnecessary? handled in EVP now...
138# SRCS+= eng_aesni.c # local addition 138# SRCS+= eng_aesni.c # local addition
139 139
diff --git a/src/lib/libcrypto/engine/eng_all.c b/src/lib/libcrypto/engine/eng_all.c
index f318ea69c4..fd36594a0b 100644
--- a/src/lib/libcrypto/engine/eng_all.c
+++ b/src/lib/libcrypto/engine/eng_all.c
@@ -76,9 +76,6 @@ void ENGINE_load_builtin_engines(void)
76#ifndef OPENSSL_NO_RSAX 76#ifndef OPENSSL_NO_RSAX
77 ENGINE_load_rsax(); 77 ENGINE_load_rsax();
78#endif 78#endif
79#ifndef OPENSSL_NO_RDRAND
80 ENGINE_load_rdrand();
81#endif
82 ENGINE_load_dynamic(); 79 ENGINE_load_dynamic();
83#ifndef OPENSSL_NO_STATIC_ENGINE 80#ifndef OPENSSL_NO_STATIC_ENGINE
84#ifndef OPENSSL_NO_HW 81#ifndef OPENSSL_NO_HW
diff --git a/src/lib/libcrypto/engine/eng_rdrand.c b/src/lib/libcrypto/engine/eng_rdrand.c
deleted file mode 100644
index ba1b5bfbff..0000000000
--- a/src/lib/libcrypto/engine/eng_rdrand.c
+++ /dev/null
@@ -1,139 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2011 The OpenSSL Project. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 */
49
50#include <openssl/opensslconf.h>
51
52#include <stdio.h>
53#include <string.h>
54#include <openssl/engine.h>
55#include <openssl/rand.h>
56#include <openssl/err.h>
57
58#if (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
59 defined(__x86_64) || defined(__x86_64__) || \
60 defined(_M_AMD64) || defined (_M_X64)) && defined(OPENSSL_CPUID_OBJ)
61
62size_t OPENSSL_ia32_rdrand(void);
63
64static int get_random_bytes (unsigned char *buf, int num)
65 {
66 size_t rnd;
67
68 while (num>=(int)sizeof(size_t)) {
69 if ((rnd = OPENSSL_ia32_rdrand()) == 0) return 0;
70
71 *((size_t *)buf) = rnd;
72 buf += sizeof(size_t);
73 num -= sizeof(size_t);
74 }
75 if (num) {
76 if ((rnd = OPENSSL_ia32_rdrand()) == 0) return 0;
77
78 memcpy (buf,&rnd,num);
79 }
80
81 return 1;
82 }
83
84static int random_status (void)
85{ return 1; }
86
87static RAND_METHOD rdrand_meth = {
88 .bytes = get_random_bytes,
89 .pseudorand = get_random_bytes,
90 .status = random_status
91};
92
93static int rdrand_init(ENGINE *e)
94{ return 1; }
95
96static const char *engine_e_rdrand_id = "rdrand";
97static const char *engine_e_rdrand_name = "Intel RDRAND engine";
98
99static int bind_helper(ENGINE *e)
100 {
101 if (!ENGINE_set_id(e, engine_e_rdrand_id) ||
102 !ENGINE_set_name(e, engine_e_rdrand_name) ||
103 !ENGINE_set_flags(e, ENGINE_FLAGS_NO_REGISTER_ALL) ||
104 !ENGINE_set_init_function(e, rdrand_init) ||
105 !ENGINE_set_RAND(e, &rdrand_meth) )
106 return 0;
107
108 return 1;
109 }
110
111static ENGINE *ENGINE_rdrand(void)
112 {
113 ENGINE *ret = ENGINE_new();
114 if(!ret)
115 return NULL;
116 if(!bind_helper(ret))
117 {
118 ENGINE_free(ret);
119 return NULL;
120 }
121 return ret;
122 }
123
124void ENGINE_load_rdrand (void)
125 {
126 extern unsigned int OPENSSL_ia32cap_P[];
127
128 if (OPENSSL_ia32cap_P[1] & (1<<(62-32)))
129 {
130 ENGINE *toadd = ENGINE_rdrand();
131 if(!toadd) return;
132 ENGINE_add(toadd);
133 ENGINE_free(toadd);
134 ERR_clear_error();
135 }
136 }
137#else
138void ENGINE_load_rdrand (void) {}
139#endif
diff --git a/src/lib/libcrypto/engine/engine.h b/src/lib/libcrypto/engine/engine.h
index 5c2f7b0527..e99ad750e4 100644
--- a/src/lib/libcrypto/engine/engine.h
+++ b/src/lib/libcrypto/engine/engine.h
@@ -320,7 +320,6 @@ void ENGINE_load_padlock(void);
320#endif 320#endif
321void ENGINE_load_cryptodev(void); 321void ENGINE_load_cryptodev(void);
322void ENGINE_load_rsax(void); 322void ENGINE_load_rsax(void);
323void ENGINE_load_rdrand(void);
324void ENGINE_load_builtin_engines(void); 323void ENGINE_load_builtin_engines(void);
325 324
326/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation 325/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
diff --git a/src/lib/libcrypto/perlasm/x86_64-xlate.pl b/src/lib/libcrypto/perlasm/x86_64-xlate.pl
index 56d9b64b6f..2ad032c4ba 100755
--- a/src/lib/libcrypto/perlasm/x86_64-xlate.pl
+++ b/src/lib/libcrypto/perlasm/x86_64-xlate.pl
@@ -759,19 +759,6 @@ my $pclmulqdq = sub {
759 } 759 }
760}; 760};
761 761
762my $rdrand = sub {
763 if (shift =~ /%[er](\w+)/) {
764 my @opcode=();
765 my $dst=$1;
766 if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; }
767 rex(\@opcode,0,$1,8);
768 push @opcode,0x0f,0xc7,0xf0|($dst&7);
769 @opcode;
770 } else {
771 ();
772 }
773};
774
775if ($nasm) { 762if ($nasm) {
776 print <<___; 763 print <<___;
777default rel 764default rel
diff --git a/src/lib/libcrypto/perlasm/x86asm.pl b/src/lib/libcrypto/perlasm/x86asm.pl
index d74d1992f8..5916ea4f89 100644
--- a/src/lib/libcrypto/perlasm/x86asm.pl
+++ b/src/lib/libcrypto/perlasm/x86asm.pl
@@ -130,14 +130,6 @@ sub ::pclmulqdq
130 { &::generic("pclmulqdq",@_); } 130 { &::generic("pclmulqdq",@_); }
131} 131}
132 132
133sub ::rdrand
134{ my ($dst)=@_;
135 if ($dst =~ /(e[a-dsd][ixp])/)
136 { &::data_byte(0x0f,0xc7,0xf0|$regrm{$dst}); }
137 else
138 { &::generic("rdrand",@_); }
139}
140
141# label management 133# label management
142$lbdecor="L"; # local label decoration, set by package 134$lbdecor="L"; # local label decoration, set by package
143$label="000"; 135$label="000";
diff --git a/src/lib/libcrypto/x86_64cpuid.pl b/src/lib/libcrypto/x86_64cpuid.pl
index ac002a2e0e..b36d3f7dc5 100644
--- a/src/lib/libcrypto/x86_64cpuid.pl
+++ b/src/lib/libcrypto/x86_64cpuid.pl
@@ -195,21 +195,4 @@ OPENSSL_wipe_cpu:
195.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu 195.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
196___ 196___
197 197
198print<<___;
199.globl OPENSSL_ia32_rdrand
200.type OPENSSL_ia32_rdrand,\@abi-omnipotent
201.align 16
202OPENSSL_ia32_rdrand:
203 mov \$8,%ecx
204.Loop_rdrand:
205 rdrand %rax
206 jc .Lbreak_rdrand
207 loop .Loop_rdrand
208.Lbreak_rdrand:
209 cmp \$0,%rax
210 cmove %rcx,%rax
211 ret
212.size OPENSSL_ia32_rdrand,.-OPENSSL_ia32_rdrand
213___
214
215close STDOUT; # flush 198close STDOUT; # flush
diff --git a/src/lib/libcrypto/x86cpuid.pl b/src/lib/libcrypto/x86cpuid.pl
index 169036d53d..47df147a83 100644
--- a/src/lib/libcrypto/x86cpuid.pl
+++ b/src/lib/libcrypto/x86cpuid.pl
@@ -257,18 +257,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
257 &ret (); 257 &ret ();
258&function_end_B("OPENSSL_atomic_add"); 258&function_end_B("OPENSSL_atomic_add");
259 259
260&function_begin_B("OPENSSL_ia32_rdrand");
261 &mov ("ecx",8);
262&set_label("loop");
263 &rdrand ("eax");
264 &jc (&label("break"));
265 &loop (&label("loop"));
266&set_label("break");
267 &cmp ("eax",0);
268 &cmove ("eax","ecx");
269 &ret ();
270&function_end_B("OPENSSL_ia32_rdrand");
271
272&initseg("OPENSSL_cpuid_setup"); 260&initseg("OPENSSL_cpuid_setup");
273 261
274&asm_finish(); 262&asm_finish();
diff --git a/src/lib/libssl/src/crypto/engine/eng_all.c b/src/lib/libssl/src/crypto/engine/eng_all.c
index f318ea69c4..fd36594a0b 100644
--- a/src/lib/libssl/src/crypto/engine/eng_all.c
+++ b/src/lib/libssl/src/crypto/engine/eng_all.c
@@ -76,9 +76,6 @@ void ENGINE_load_builtin_engines(void)
76#ifndef OPENSSL_NO_RSAX 76#ifndef OPENSSL_NO_RSAX
77 ENGINE_load_rsax(); 77 ENGINE_load_rsax();
78#endif 78#endif
79#ifndef OPENSSL_NO_RDRAND
80 ENGINE_load_rdrand();
81#endif
82 ENGINE_load_dynamic(); 79 ENGINE_load_dynamic();
83#ifndef OPENSSL_NO_STATIC_ENGINE 80#ifndef OPENSSL_NO_STATIC_ENGINE
84#ifndef OPENSSL_NO_HW 81#ifndef OPENSSL_NO_HW
diff --git a/src/lib/libssl/src/crypto/engine/eng_rdrand.c b/src/lib/libssl/src/crypto/engine/eng_rdrand.c
deleted file mode 100644
index ba1b5bfbff..0000000000
--- a/src/lib/libssl/src/crypto/engine/eng_rdrand.c
+++ /dev/null
@@ -1,139 +0,0 @@
1/* ====================================================================
2 * Copyright (c) 2011 The OpenSSL Project. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the OpenSSL Project
19 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
20 *
21 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
24 * licensing@OpenSSL.org.
25 *
26 * 5. Products derived from this software may not be called "OpenSSL"
27 * nor may "OpenSSL" appear in their names without prior written
28 * permission of the OpenSSL Project.
29 *
30 * 6. Redistributions of any form whatsoever must retain the following
31 * acknowledgment:
32 * "This product includes software developed by the OpenSSL Project
33 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
48 */
49
50#include <openssl/opensslconf.h>
51
52#include <stdio.h>
53#include <string.h>
54#include <openssl/engine.h>
55#include <openssl/rand.h>
56#include <openssl/err.h>
57
58#if (defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
59 defined(__x86_64) || defined(__x86_64__) || \
60 defined(_M_AMD64) || defined (_M_X64)) && defined(OPENSSL_CPUID_OBJ)
61
62size_t OPENSSL_ia32_rdrand(void);
63
64static int get_random_bytes (unsigned char *buf, int num)
65 {
66 size_t rnd;
67
68 while (num>=(int)sizeof(size_t)) {
69 if ((rnd = OPENSSL_ia32_rdrand()) == 0) return 0;
70
71 *((size_t *)buf) = rnd;
72 buf += sizeof(size_t);
73 num -= sizeof(size_t);
74 }
75 if (num) {
76 if ((rnd = OPENSSL_ia32_rdrand()) == 0) return 0;
77
78 memcpy (buf,&rnd,num);
79 }
80
81 return 1;
82 }
83
84static int random_status (void)
85{ return 1; }
86
87static RAND_METHOD rdrand_meth = {
88 .bytes = get_random_bytes,
89 .pseudorand = get_random_bytes,
90 .status = random_status
91};
92
93static int rdrand_init(ENGINE *e)
94{ return 1; }
95
96static const char *engine_e_rdrand_id = "rdrand";
97static const char *engine_e_rdrand_name = "Intel RDRAND engine";
98
99static int bind_helper(ENGINE *e)
100 {
101 if (!ENGINE_set_id(e, engine_e_rdrand_id) ||
102 !ENGINE_set_name(e, engine_e_rdrand_name) ||
103 !ENGINE_set_flags(e, ENGINE_FLAGS_NO_REGISTER_ALL) ||
104 !ENGINE_set_init_function(e, rdrand_init) ||
105 !ENGINE_set_RAND(e, &rdrand_meth) )
106 return 0;
107
108 return 1;
109 }
110
111static ENGINE *ENGINE_rdrand(void)
112 {
113 ENGINE *ret = ENGINE_new();
114 if(!ret)
115 return NULL;
116 if(!bind_helper(ret))
117 {
118 ENGINE_free(ret);
119 return NULL;
120 }
121 return ret;
122 }
123
124void ENGINE_load_rdrand (void)
125 {
126 extern unsigned int OPENSSL_ia32cap_P[];
127
128 if (OPENSSL_ia32cap_P[1] & (1<<(62-32)))
129 {
130 ENGINE *toadd = ENGINE_rdrand();
131 if(!toadd) return;
132 ENGINE_add(toadd);
133 ENGINE_free(toadd);
134 ERR_clear_error();
135 }
136 }
137#else
138void ENGINE_load_rdrand (void) {}
139#endif
diff --git a/src/lib/libssl/src/crypto/engine/engine.h b/src/lib/libssl/src/crypto/engine/engine.h
index 5c2f7b0527..e99ad750e4 100644
--- a/src/lib/libssl/src/crypto/engine/engine.h
+++ b/src/lib/libssl/src/crypto/engine/engine.h
@@ -320,7 +320,6 @@ void ENGINE_load_padlock(void);
320#endif 320#endif
321void ENGINE_load_cryptodev(void); 321void ENGINE_load_cryptodev(void);
322void ENGINE_load_rsax(void); 322void ENGINE_load_rsax(void);
323void ENGINE_load_rdrand(void);
324void ENGINE_load_builtin_engines(void); 323void ENGINE_load_builtin_engines(void);
325 324
326/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation 325/* Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation
diff --git a/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl b/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
index 56d9b64b6f..2ad032c4ba 100755
--- a/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86_64-xlate.pl
@@ -759,19 +759,6 @@ my $pclmulqdq = sub {
759 } 759 }
760}; 760};
761 761
762my $rdrand = sub {
763 if (shift =~ /%[er](\w+)/) {
764 my @opcode=();
765 my $dst=$1;
766 if ($dst !~ /[0-9]+/) { $dst = $regrm{"%e$dst"}; }
767 rex(\@opcode,0,$1,8);
768 push @opcode,0x0f,0xc7,0xf0|($dst&7);
769 @opcode;
770 } else {
771 ();
772 }
773};
774
775if ($nasm) { 762if ($nasm) {
776 print <<___; 763 print <<___;
777default rel 764default rel
diff --git a/src/lib/libssl/src/crypto/perlasm/x86asm.pl b/src/lib/libssl/src/crypto/perlasm/x86asm.pl
index d74d1992f8..5916ea4f89 100644
--- a/src/lib/libssl/src/crypto/perlasm/x86asm.pl
+++ b/src/lib/libssl/src/crypto/perlasm/x86asm.pl
@@ -130,14 +130,6 @@ sub ::pclmulqdq
130 { &::generic("pclmulqdq",@_); } 130 { &::generic("pclmulqdq",@_); }
131} 131}
132 132
133sub ::rdrand
134{ my ($dst)=@_;
135 if ($dst =~ /(e[a-dsd][ixp])/)
136 { &::data_byte(0x0f,0xc7,0xf0|$regrm{$dst}); }
137 else
138 { &::generic("rdrand",@_); }
139}
140
141# label management 133# label management
142$lbdecor="L"; # local label decoration, set by package 134$lbdecor="L"; # local label decoration, set by package
143$label="000"; 135$label="000";
diff --git a/src/lib/libssl/src/crypto/x86_64cpuid.pl b/src/lib/libssl/src/crypto/x86_64cpuid.pl
index ac002a2e0e..b36d3f7dc5 100644
--- a/src/lib/libssl/src/crypto/x86_64cpuid.pl
+++ b/src/lib/libssl/src/crypto/x86_64cpuid.pl
@@ -195,21 +195,4 @@ OPENSSL_wipe_cpu:
195.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu 195.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
196___ 196___
197 197
198print<<___;
199.globl OPENSSL_ia32_rdrand
200.type OPENSSL_ia32_rdrand,\@abi-omnipotent
201.align 16
202OPENSSL_ia32_rdrand:
203 mov \$8,%ecx
204.Loop_rdrand:
205 rdrand %rax
206 jc .Lbreak_rdrand
207 loop .Loop_rdrand
208.Lbreak_rdrand:
209 cmp \$0,%rax
210 cmove %rcx,%rax
211 ret
212.size OPENSSL_ia32_rdrand,.-OPENSSL_ia32_rdrand
213___
214
215close STDOUT; # flush 198close STDOUT; # flush
diff --git a/src/lib/libssl/src/crypto/x86cpuid.pl b/src/lib/libssl/src/crypto/x86cpuid.pl
index 169036d53d..47df147a83 100644
--- a/src/lib/libssl/src/crypto/x86cpuid.pl
+++ b/src/lib/libssl/src/crypto/x86cpuid.pl
@@ -257,18 +257,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
257 &ret (); 257 &ret ();
258&function_end_B("OPENSSL_atomic_add"); 258&function_end_B("OPENSSL_atomic_add");
259 259
260&function_begin_B("OPENSSL_ia32_rdrand");
261 &mov ("ecx",8);
262&set_label("loop");
263 &rdrand ("eax");
264 &jc (&label("break"));
265 &loop (&label("loop"));
266&set_label("break");
267 &cmp ("eax",0);
268 &cmove ("eax","ecx");
269 &ret ();
270&function_end_B("OPENSSL_ia32_rdrand");
271
272&initseg("OPENSSL_cpuid_setup"); 260&initseg("OPENSSL_cpuid_setup");
273 261
274&asm_finish(); 262&asm_finish();