summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormiod <>2014-04-18 20:23:42 +0000
committermiod <>2014-04-18 20:23:42 +0000
commita505a455abe7e50200002d907071ceffe1e3eb85 (patch)
tree457405fa838556eda26f001a407f8b9fd241befa
parent34e84b127a42e7a5eeabe18feec604aa8f08a3fc (diff)
downloadopenbsd-a505a455abe7e50200002d907071ceffe1e3eb85.tar.gz
openbsd-a505a455abe7e50200002d907071ceffe1e3eb85.tar.bz2
openbsd-a505a455abe7e50200002d907071ceffe1e3eb85.zip
ECDSA signature computation involves a random number. Remove the test trying to
force what RAND_bytes() will return and comparing it against known values - I can't let you do this, Dave.
-rw-r--r--src/regress/lib/libcrypto/ecdsa/ecdsatest.c116
1 files changed, 0 insertions, 116 deletions
diff --git a/src/regress/lib/libcrypto/ecdsa/ecdsatest.c b/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
index 8dd04e0fd3..232fb9b4d1 100644
--- a/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
+++ b/src/regress/lib/libcrypto/ecdsa/ecdsatest.c
@@ -85,85 +85,9 @@
85#include <openssl/rand.h> 85#include <openssl/rand.h>
86 86
87/* declaration of the test functions */ 87/* declaration of the test functions */
88int x9_62_tests(BIO *);
89int x9_62_test_internal(BIO *out, int nid, const char *r, const char *s); 88int x9_62_test_internal(BIO *out, int nid, const char *r, const char *s);
90int test_builtin(BIO *); 89int test_builtin(BIO *);
91 90
92/* functions to change the RAND_METHOD */
93int change_rand(void);
94int restore_rand(void);
95int fbytes(unsigned char *buf, int num);
96
97RAND_METHOD fake_rand;
98const RAND_METHOD *old_rand;
99
100int change_rand(void)
101 {
102 /* save old rand method */
103 if ((old_rand = RAND_get_rand_method()) == NULL)
104 return 0;
105
106 fake_rand.seed = old_rand->seed;
107 fake_rand.cleanup = old_rand->cleanup;
108 fake_rand.add = old_rand->add;
109 fake_rand.status = old_rand->status;
110 /* use own random function */
111 fake_rand.bytes = fbytes;
112 fake_rand.pseudorand = old_rand->bytes;
113 /* set new RAND_METHOD */
114 if (!RAND_set_rand_method(&fake_rand))
115 return 0;
116 return 1;
117 }
118
119int restore_rand(void)
120 {
121 if (!RAND_set_rand_method(old_rand))
122 return 0;
123 else
124 return 1;
125 }
126
127static int fbytes_counter = 0;
128static const char *numbers[8] = {
129 "651056770906015076056810763456358567190100156695615665659",
130 "6140507067065001063065065565667405560006161556565665656654",
131 "8763001015071075675010661307616710783570106710677817767166"
132 "71676178726717",
133 "7000000175690566466555057817571571075705015757757057795755"
134 "55657156756655",
135 "1275552191113212300012030439187146164646146646466749494799",
136 "1542725565216523985789236956265265265235675811949404040041",
137 "1456427555219115346513212300075341203043918714616464614664"
138 "64667494947990",
139 "1712787255652165239672857892369562652652652356758119494040"
140 "40041670216363"};
141
142int fbytes(unsigned char *buf, int num)
143 {
144 int ret;
145 BIGNUM *tmp = NULL;
146
147 if (fbytes_counter >= 8)
148 return 0;
149 tmp = BN_new();
150 if (!tmp)
151 return 0;
152 if (!BN_dec2bn(&tmp, numbers[fbytes_counter]))
153 {
154 BN_free(tmp);
155 return 0;
156 }
157 fbytes_counter ++;
158 if (num != BN_num_bytes(tmp) || !BN_bn2bin(tmp, buf))
159 ret = 0;
160 else
161 ret = 1;
162 if (tmp)
163 BN_free(tmp);
164 return ret;
165 }
166
167/* some tests from the X9.62 draft */ 91/* some tests from the X9.62 draft */
168int x9_62_test_internal(BIO *out, int nid, const char *r_in, const char *s_in) 92int x9_62_test_internal(BIO *out, int nid, const char *r_in, const char *s_in)
169 { 93 {
@@ -229,45 +153,6 @@ x962_int_err:
229 return ret; 153 return ret;
230 } 154 }
231 155
232int x9_62_tests(BIO *out)
233 {
234 int ret = 0;
235
236 BIO_printf(out, "some tests from X9.62:\n");
237
238 /* set own rand method */
239 if (!change_rand())
240 goto x962_err;
241
242 if (!x9_62_test_internal(out, NID_X9_62_prime192v1,
243 "3342403536405981729393488334694600415596881826869351677613",
244 "5735822328888155254683894997897571951568553642892029982342"))
245 goto x962_err;
246 if (!x9_62_test_internal(out, NID_X9_62_prime239v1,
247 "3086361431751678114926225473006680188549593787585317781474"
248 "62058306432176",
249 "3238135532097973577080787768312505059318910517550078427819"
250 "78505179448783"))
251 goto x962_err;
252#ifndef OPENSSL_NO_EC2M
253 if (!x9_62_test_internal(out, NID_X9_62_c2tnb191v1,
254 "87194383164871543355722284926904419997237591535066528048",
255 "308992691965804947361541664549085895292153777025772063598"))
256 goto x962_err;
257 if (!x9_62_test_internal(out, NID_X9_62_c2tnb239v1,
258 "2159633321041961198501834003903461262881815148684178964245"
259 "5876922391552",
260 "1970303740007316867383349976549972270528498040721988191026"
261 "49413465737174"))
262 goto x962_err;
263#endif
264 ret = 1;
265x962_err:
266 if (!restore_rand())
267 ret = 0;
268 return ret;
269 }
270
271int test_builtin(BIO *out) 156int test_builtin(BIO *out)
272 { 157 {
273 EC_builtin_curve *curves = NULL; 158 EC_builtin_curve *curves = NULL;
@@ -534,7 +419,6 @@ int main(void)
534 ERR_load_crypto_strings(); 419 ERR_load_crypto_strings();
535 420
536 /* the tests */ 421 /* the tests */
537 if (!x9_62_tests(out)) goto err;
538 if (!test_builtin(out)) goto err; 422 if (!test_builtin(out)) goto err;
539 423
540 ret = 0; 424 ret = 0;