proxy/tripe-mitm.c: Abolish use of RC4.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 13 Sep 2017 09:04:46 +0000 (10:04 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Thu, 28 Jun 2018 23:24:43 +0000 (00:24 +0100)
proxy/tripe-mitm.c

index 7a2502b..ab05a88 100644 (file)
@@ -62,9 +62,9 @@
 #include <catacomb/mprand.h>
 #include <catacomb/dh.h>
 
+#include <catacomb/chacha20.h>
 #include <catacomb/noise.h>
 #include <catacomb/rand.h>
-#include <catacomb/rc4.h>
 
 #include "util.h"
 
@@ -627,7 +627,8 @@ int main(int argc, char *argv[])
   const char *kfname = "keyring.pub";
   int i;
   unsigned f = 0;
-  char buf[16];
+  char buf[32];
+  static octet zero[CHACHA_NONCESZ];
 
 #define f_bogus 1u
 
@@ -652,9 +653,9 @@ int main(int argc, char *argv[])
   if (f & f_bogus) { usage(stderr); exit(1); }
 
   rand_noisesrc(RAND_GLOBAL, &noise_source);
-  rand_seed(RAND_GLOBAL, 160);
+  rand_seed(RAND_GLOBAL, 256);
   rand_get(RAND_GLOBAL, buf, sizeof(buf));
-  rng = rc4_rand(buf, sizeof(buf));
+  rng = chacha20_rand(buf, sizeof(buf), zero);
   sel_init(&sel);
   if (key_open(&keys, kfname, KOPEN_READ, key_moan, 0))
     die(1, "couldn't open `%s': %s", kfname, strerror(errno));