The pixie no longer needs to be setuid-root.
[u/mdw/catacomb] / keysz.h
diff --git a/keysz.h b/keysz.h
index 5a49740..97ed144 100644 (file)
--- a/keysz.h
+++ b/keysz.h
@@ -85,6 +85,63 @@ extern size_t keysz(size_t /*sz*/, const octet */*ksz*/);
 #define KSZ_ASSERT(pre, sz)                                            \
   assert(((void)"Bad key size for " #pre, KSZ_CHECK(pre, sz)))
 
+/*----- Key size conversions ----------------------------------------------*/
+
+/* --- @keysz_fromdl@, @_fromschnorr@, @_fromif@, @_fromec@ --- *
+ *
+ * Arguments:  @double nbits@ = key size
+ *
+ * Returns:    Equivalent symmetric key size.
+ *
+ * Use:                Converts key lengths of various kinds of reference problems
+ *             to (roughly) equivalent symmetric key sizes.
+ *
+ *               * Given the bit length of %$p$%, @keysz_fromdl@ returns a
+ *                 key size representing the difficulty of computing
+ *                 discrete logarithms in %$\gf{p}$%, for %$p$% prime or a
+ *                 small power of a prime.
+ *
+ *               * Given the bit length of %$r$%, @keysz_fromschnorr@
+ *                 returns a key size representing the difficulty of
+ *                 computing discrete logarithms in a subgroup of %$\gf{q}$%
+ *                 of order %$r$%.
+ *
+ *               * Given the bit length of %$n$%, @keysz_fromif@ returns a
+ *                 key size representing the difficulty of factoring a
+ *                 `hard' number %$n = p q$%, where %$p$% and %$q$% are
+ *                 primes of (near enough) the same length.
+ *
+ *               * Given the bit length of %$r$%, @keysz_fromec@ returns a
+ *                 key size representing the difficulty of computing
+ *                 discrete logarithms in a subgroup of order-%$r$% of an
+ *                 elliptic curve over a finite field.
+ *
+ *             These functions take and return @double@ rather than an
+ *             integer type in order to preserve precision between
+ *             conversions.
+ */
+
+extern double keysz_fromdl(double /*nbits*/);
+extern double keysz_fromschnorr(double /*nbits*/);
+extern double keysz_fromif(double /*nbits*/);
+extern double keysz_fromec(double /*nbits*/);
+
+/* --- @keysz_todl@, @_toschnorr@, @_toif@, @_toec@ --- *
+ *
+ * Arguments:  @unsigned long nbits@ = symmetric key size
+ *
+ * Returns:    Equivalent key size.
+ *
+ * Use:                Converts symmetric key sizes to (roughly) equivalent key
+ *             sizes for various kinds of reference problems.  These are the
+ *             approximate inverses of the functions above.
+ */
+
+extern double keysz_todl(double /*nbits*/);
+extern double keysz_toschnorr(double /*nbits*/);
+extern double keysz_toif(double /*nbits*/);
+extern double keysz_toec(double /*nbits*/);
+
 /*----- That's all, folks -------------------------------------------------*/
 
 #ifdef __cplusplus