summaryrefslogtreecommitdiff
path: root/dh.c
diff options
context:
space:
mode:
Diffstat (limited to 'dh.c')
-rw-r--r--dh.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/dh.c b/dh.c
index 6c53b0038..03b9fd1b8 100644
--- a/dh.c
+++ b/dh.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: dh.c,v 1.11 2001/03/29 21:17:39 markus Exp $"); 26RCSID("$OpenBSD: dh.c,v 1.12 2001/04/03 19:53:29 markus Exp $");
27 27
28#include "xmalloc.h" 28#include "xmalloc.h"
29 29
@@ -273,3 +273,22 @@ dh_new_group1(void)
273 273
274 return (dh_new_group_asc(gen, group1)); 274 return (dh_new_group_asc(gen, group1));
275} 275}
276
277/*
278 * Estimates the group order for a Diffie-Hellman group that has an
279 * attack complexity approximately the same as O(2**bits). Estimate
280 * with: O(exp(1.9223 * (ln q)^(1/3) (ln ln q)^(2/3)))
281 */
282
283int
284dh_estimate(int bits)
285{
286
287 if (bits < 64)
288 return (512); /* O(2**63) */
289 if (bits < 128)
290 return (1024); /* O(2**86) */
291 if (bits < 192)
292 return (2048); /* O(2**116) */
293 return (4096); /* O(2**156) */
294}