aboutsummaryrefslogtreecommitdiff
path: root/networking/tls.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/tls.c')
-rw-r--r--networking/tls.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/networking/tls.c b/networking/tls.c
index 7ae9e5a1f..4f0e2b6eb 100644
--- a/networking/tls.c
+++ b/networking/tls.c
@@ -2326,6 +2326,48 @@ void FAST_FUNC tls_run_copy_loop(tls_state_t *tls, unsigned flags)
2326 const int INBUF_STEP = 4 * 1024; 2326 const int INBUF_STEP = 4 * 1024;
2327 struct pollfd pfds[2]; 2327 struct pollfd pfds[2];
2328 2328
2329#if 0
2330// Debug aid for comparing P256 implementations.
2331// Enable this, set SP_DEBUG and FIXED_SECRET to 1,
2332// and add
2333// tls_run_copy_loop(NULL, 0);
2334// e.g. at the very beginning of wget_main()
2335//
2336{
2337//kbuild:lib-$(CONFIG_TLS) += tls_sp_c32_new.o
2338 uint8_t ecc_pub_key32[2 * 32];
2339 uint8_t pubkey2x32[2 * 32];
2340 uint8_t premaster32[32];
2341
2342//Fixed input key:
2343// memset(ecc_pub_key32, 0xee, sizeof(ecc_pub_key32));
2344//Fixed 000000000000000000000000000000000000ab000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
2345// memset(ecc_pub_key32, 0x00, sizeof(ecc_pub_key32));
2346// ecc_pub_key32[18] = 0xab;
2347//Random key:
2348 tls_get_random(ecc_pub_key32, sizeof(ecc_pub_key32));
2349//Biased random (almost all zeros or almost all ones):
2350// srand(time(NULL) ^ getpid());
2351// if (rand() & 1)
2352// memset(ecc_pub_key32, 0x00, sizeof(ecc_pub_key32));
2353// else
2354// memset(ecc_pub_key32, 0xff, sizeof(ecc_pub_key32));
2355// ecc_pub_key32[rand() & 0x3f] = rand();
2356
2357 xmove_fd(xopen("p256.OLD", O_WRONLY | O_CREAT | O_TRUNC), 2);
2358 curve_P256_compute_pubkey_and_premaster(
2359 pubkey2x32, premaster32,
2360 /*point:*/ ecc_pub_key32
2361 );
2362 xmove_fd(xopen("p256.NEW", O_WRONLY | O_CREAT | O_TRUNC), 2);
2363 curve_P256_compute_pubkey_and_premaster_NEW(
2364 pubkey2x32, premaster32,
2365 /*point:*/ ecc_pub_key32
2366 );
2367 exit(1);
2368}
2369#endif
2370
2329 pfds[0].fd = STDIN_FILENO; 2371 pfds[0].fd = STDIN_FILENO;
2330 pfds[0].events = POLLIN; 2372 pfds[0].events = POLLIN;
2331 pfds[1].fd = tls->ifd; 2373 pfds[1].fd = tls->ifd;