Introduce negotiation for Diffie--Hellman groups.
[secnet] / dh.c
diff --git a/dh.c b/dh.c
index 11f1d35..0b5e4d2 100644 (file)
--- a/dh.c
+++ b/dh.c
@@ -32,6 +32,7 @@
 #include <limits.h>
 
 #include "secnet.h"
+#include "magic.h"
 #include "util.h"
 
 struct dh {
@@ -169,6 +170,15 @@ static list_t *dh_apply(closure_t *self, struct cloc loc, dict_t *context,
     /* According to the docs, mpz_sizeinbase(,256) is allowed to return
      * an answer which is 1 too large.  But mpz_sizeinbase(,2) isn't. */
 
+    if (!dict)
+       st->ops.capab_bit = CAPAB_BIT_TRADZP;
+    else
+       st->ops.capab_bit = dict_read_number(dict, "capab-num", False,
+                                            "dh", loc, CAPAB_BIT_TRADZP);
+    if (st->ops.capab_bit > CAPAB_BIT_MAX)
+       cfgfatal(loc,"dh","capab-num out of range 0..%d\n",
+                CAPAB_BIT_MAX);
+
     return new_closure(&st->cl);
 }