/* -*-c-*-
*
- * $Id: acconfig.h,v 1.1 1999/09/03 08:41:11 mdw Exp $
+ * $Id: acconfig.h,v 1.2 1999/12/10 23:30:08 mdw Exp $
*
* Configuration header for Catacomb
*
/*----- Revision history --------------------------------------------------*
*
* $Log: acconfig.h,v $
+ * Revision 1.2 1999/12/10 23:30:08 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:11 mdw
* Initial import.
*
*/
-#ifndef ACCONFIG_H
-#define ACCONFIG_H
+#ifndef CATACOMB_ACCONFIG_H
+#define CATACOMB_ACCONFIG_H
#ifdef __cplusplus
extern "C" {
/* -*-c-*-
*
- * $Id: bf_ikey.h,v 1.1 1999/09/03 08:41:11 mdw Exp $
+ * $Id: bf_ikey.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Blowfish initial key data
*
/*----- Revision history --------------------------------------------------*
*
* $Log: bf_ikey.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:11 mdw
* Initial import.
*
*/
-#ifndef BF_IKEY_H
-#define BF_IKEY_H
+#ifndef CATACOMB_BF_IKEY_H
+#define CATACOMB_BF_IKEY_H
/*----- Macros ------------------------------------------------------------*/
/* -*-c-*-
*
- * $Id: blkc.h,v 1.1 1999/09/03 08:41:11 mdw Exp $
+ * $Id: blkc.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Common definitions for block ciphers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: blkc.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:11 mdw
* Initial import.
*
*/
-#ifndef BLKC_H
-#define BLKC_H
+#ifndef CATACOMB_BLKC_H
+#define CATACOMB_BLKC_H
#ifdef __cplusplus
extern "C" {
#define BLKC_FIRST(x, y, z) x
#define BLKC_SECOND(x, y, z) y
#define BLKC_THIRD(x, y, z) z
-#define BLKC_TYPE(PRE) BLKC_APPLY(BLKC_FIRST, PRE ## _CLASS)
-#define BLKC_ENDIAN(PRE) BLKC_APPLY(BLKC_SECOND, PRE ## _CLASS)
-#define BLKC_BITS(PRE) BLKC_APPLY(BLKC_THIRD, PRE ## _CLASS)
+#define BLKC_TYPE(PRE) BLKC_APPLY(BLKC_FIRST, PRE##_CLASS)
+#define BLKC_ENDIAN(PRE) BLKC_APPLY(BLKC_SECOND, PRE##_CLASS)
+#define BLKC_BITS(PRE) BLKC_APPLY(BLKC_THIRD, PRE##_CLASS)
#define BLKC_STORE_E(PRE) BLKC_GLUE(STORE32_, BLKC_ENDIAN(PRE))
#define BLKC_LOAD_E(PRE) BLKC_GLUE(LOAD32_, BLKC_ENDIAN(PRE))
#define BLKC_SKEL_X(PRE, decl, guts) \
BLKC_SKEL(PRE, int _i; decl, \
- for (_i = 0; _i < PRE ## _BLKSZ / 4; _i++) { \
+ for (_i = 0; _i < PRE##_BLKSZ / 4; _i++) { \
guts \
})
\
static int verify(dstr *v) \
{ \
- pre ## _ctx k; \
- uint32 p[PRE ## _BLKSZ / 4]; \
- uint32 c[PRE ## _BLKSZ / 4]; \
- uint32 d[PRE ## _BLKSZ / 4]; \
+ pre##_ctx k; \
+ uint32 p[PRE##_BLKSZ / 4]; \
+ uint32 c[PRE##_BLKSZ / 4]; \
+ uint32 d[PRE##_BLKSZ / 4]; \
dstr b = DSTR_INIT; \
int ok = 1; \
\
/* --- Initialize the key buffer --- */ \
\
- dstr_ensure(&b, PRE ## _BLKSZ); \
- b.len = PRE ## _BLKSZ; \
- pre ## _init(&k, v[0].buf, v[0].len); \
+ dstr_ensure(&b, PRE##_BLKSZ); \
+ b.len = PRE##_BLKSZ; \
+ pre##_init(&k, v[0].buf, v[0].len); \
BLKC_LOAD(PRE, p, v[1].buf); \
BLKC_LOAD(PRE, c, v[2].buf); \
\
/* --- Test encryption --- */ \
\
BLKC_MOVE(PRE, d, p); \
- pre ## _eblk(&k, d, d); \
+ pre##_eblk(&k, d, d); \
BLKC_STORE(PRE, b.buf, d); \
- if (memcmp(b.buf, v[2].buf, PRE ## _BLKSZ)) { \
+ if (memcmp(b.buf, v[2].buf, PRE##_BLKSZ)) { \
ok = 0; \
printf("\nfail encryption:" \
"\n\tkey = "); \
/* --- Test decryption --- */ \
\
BLKC_MOVE(PRE, d, c); \
- pre ## _dblk(&k, d, d); \
+ pre##_dblk(&k, d, d); \
BLKC_STORE(PRE, b.buf, d); \
- if (memcmp(b.buf, v[1].buf, PRE ## _BLKSZ)) { \
+ if (memcmp(b.buf, v[1].buf, PRE##_BLKSZ)) { \
ok = 0; \
printf("\nfail decryption:" \
"\n\tkey = "); \
/* -*-c-*-
*
- * $Id: blowfish.h,v 1.1 1999/09/03 08:41:11 mdw Exp $
+ * $Id: blowfish.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* The Blowfish block cipher
*
/*----- Revision history --------------------------------------------------*
*
* $Log: blowfish.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:11 mdw
* Initial import.
*
* has a particularly heavyweight key schedule.
*/
-#ifndef BLOWFISH_H
-#define BLOWFISH_H
+#ifndef CATACOMB_BLOWFISH_H
+#define CATACOMB_BLOWFISH_H
#ifdef __cplusplus
extern "C" {
/* -*-c-*-
*
- * $Id: daftstory.h,v 1.2 1999/11/11 00:58:38 mdw Exp $
+ * $Id: daftstory.h,v 1.3 1999/12/10 23:29:48 mdw Exp $
*
* Daft story for use in test encryptions
*
/*----- Revision history --------------------------------------------------*
*
* $Log: daftstory.h,v $
+ * Revision 1.3 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.2 1999/11/11 00:58:38 mdw
* Use fewer copies of the silly story to improve performance.
*
*
*/
-#ifndef DAFTSTORY_H
-#define DAFTSTORY_H
+#ifndef CATACOMB_DAFTSTORY_H
+#define CATACOMB_DAFTSTORY_H
#ifdef __cplusplus
extern "C" {
/* -*-c-*-
*
- * $Id: des-base.h,v 1.1 1999/09/03 08:41:11 mdw Exp $
+ * $Id: des-base.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Common features for DES implementation
*
/*----- Revision history --------------------------------------------------*
*
* $Log: des-base.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:11 mdw
* Initial import.
*
*/
-#ifndef DES_BASE_H
-#define DES_BASE_H
+#ifndef CATACOMB_DES_BASE_H
+#define CATACOMB_DES_BASE_H
#ifdef __cplusplus
extern "C" {
/* -*-c-*-
*
- * $Id: des.h,v 1.1 1999/09/03 08:41:11 mdw Exp $
+ * $Id: des.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* The Data Encryption Standard
*
/*----- Revision history --------------------------------------------------*
*
* $Log: des.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:11 mdw
* Initial import.
*
* @des3@ interface which implements proper strong triple-DES.
*/
-#ifndef DES_H
-#define DES_H
+#ifndef CATACOMB_DES_H
+#define CATACOMB_DES_H
#ifdef __cplusplus
extern "C" {
/* -*-c-*-
*
- * $Id: des3.h,v 1.1 1999/09/03 08:41:11 mdw Exp $
+ * $Id: des3.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Implementation of double- and triple-DES
*
/*----- Revision history --------------------------------------------------*
*
* $Log: des3.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:11 mdw
* Initial import.
*
*/
-#ifndef DES3_H
-#define DES3_H
+#ifndef CATACOMB_DES3_H
+#define CATACOMB_DES3_H
#ifdef __cplusplus
extern "C" {
#include <mLib/bits.h>
-#ifndef DES_H
+#ifndef CATACOMB_DES_H
# include "des.h"
#endif
/* -*-c-*-
*
- * $Id: dh.h,v 1.1 1999/11/20 22:24:44 mdw Exp $
+ * $Id: dh.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* [Diffie-Hellman key negotiation *
* (c) 1999 Straylight/Edgeware
/*----- Revision history --------------------------------------------------*
*
* $Log: dh.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/11/20 22:24:44 mdw
* Add Diffie-Hellman support.
*
*/
-#ifndef DH_H
-#define DH_H
+#ifndef CATACOMB_DH_H
+#define CATACOMB_DH_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef MP_H
+#ifndef CATACOMB_MP_H
# include "mp.h"
#endif
/* -*-c-*-
*
- * $Id: dsa.h,v 1.2 1999/11/20 22:23:48 mdw Exp $
+ * $Id: dsa.h,v 1.3 1999/12/10 23:29:48 mdw Exp $
*
* Digital Signature Algorithm
*
/*----- Revision history --------------------------------------------------*
*
* $Log: dsa.h,v $
+ * Revision 1.3 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.2 1999/11/20 22:23:48 mdw
* Allow event handler to abort the search process.
*
*
*/
-#ifndef DSA_H
-#define DSA_H
+#ifndef CATACOMB_DSA_H
+#define CATACOMB_DSA_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef MP_H
+#ifndef CATACOMB_MP_H
# include "mp.h"
#endif
enum {
DSAEV_OK, /* Everything is fine */
+ DSAEV_FINDQ, /* Search for a @q@ */
DSAEV_FAILQ, /* @q@ failed primality test */
DSAEV_PASSQ, /* @q@ passeed one iteration */
DSAEV_GOODQ, /* Found good prime @q@ */
+ DSAEV_FINDP, /* Search for a @p@ */
DSAEV_TRYP, /* Try prospective @p@ */
DSAEV_FAILP, /* @p@ failed primality test */
DSAEV_PASSP, /* @p@ passed one iteration */
DSAEV_GOODP, /* @p@ accepted as being prime */
+ DSAEV_FINDG, /* Search for a @g@ */
DSAEV_TRYH, /* Try prospective @h@ */
DSAEV_FAILH, /* @h@ failed */
DSAEV_GOODG /* @g@ accepted as a generator */
/* --- @dsa_mksig@ --- *
*
* Arguments: @const dsa_param *dp@ = pointer to DSA parameters
- * @const mp *a@ = secret signing key
- * @const mp *m@ = message to be signed
- * @const mp *k@ = random data
+ * @mp *a@ = secret signing key
+ * @mp *m@ = message to be signed
+ * @mp *k@ = random data
* @mp **rr, **ss@ = where to put output parameters
*
* Returns: ---
* Use: Computes a DSA signature of a message.
*/
-extern void dsa_mksig(const dsa_param */*dp*/, const mp */*a*/,
- const mp */*m*/, const mp */*k*/,
+extern void dsa_mksig(const dsa_param */*dp*/, mp */*a*/,
+ mp */*m*/, mp */*k*/,
mp **/*rr*/, mp **/*ss*/);
/* --- @dsa_sign@ --- *
/* --- @dsa_vrfy@ --- *
*
* Arguments: @const dsa_param *dp@ = pointer to DSA parameters
- * @const mp *y@ = public verification key
- * @const mp *m@ = message which was signed
- * @const mp *r, *s@ = the signature
+ * @mp *y@ = public verification key
+ * @mp *m@ = message which was signed
+ * @mp *r, *s@ = the signature
*
* Returns: Zero if the signature is a forgery, nonzero if it's valid.
*
* Use: Verifies a DSA digital signature.
*/
-extern int dsa_vrfy(const dsa_param */*dp*/, const mp */*y*/,
- const mp */*m*/, const mp */*r*/, const mp */*s*/);
+extern int dsa_vrfy(const dsa_param */*dp*/, mp */*y*/,
+ mp */*m*/, mp */*r*/, mp */*s*/);
/* --- @dsa_verify@ --- *
*
* Arguments: @const dsa_param *dp@ = pointer to DSA parameters
- * @const mp *y@ = public verification key
+ * @mp *y@ = public verification key
* @const void *m@ = pointer to message block
* @size_t msz@ = size of message block
* @const void *r@ = pointer to @r@ signature half
* Use: Verifies a DSA digital signature.
*/
-extern int dsa_verify(const dsa_param */*dp*/, const mp */*y*/,
+extern int dsa_verify(const dsa_param */*dp*/, mp */*y*/,
const void */*m*/, size_t /*msz*/,
const void */*r*/, size_t /*rsz*/,
const void */*s*/, size_t /*ssz*/);
/* -*-c-*-
*
- * $Id: idea.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: idea.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Implementation of the IDEA cipher
*
/*----- Revision history --------------------------------------------------*
*
* $Log: idea.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:12 mdw
* Initial import.
*
* domain.
*/
-#ifndef IDEA_H
-#define IDEA_H
+#ifndef CATACOMB_IDEA_H
+#define CATACOMB_IDEA_H
#ifdef __cplusplus
extern "C" {
/* -*-c-*-
*
- * $Id: key.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: key.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Simple key management
*
/*----- Revision history --------------------------------------------------*
*
* $Log: key.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:12 mdw
* Initial import.
*
*/
-#ifndef KEY_H
-#define KEY_H
+#ifndef CATACOMB_KEY_H
+#define CATACOMB_KEY_H
#ifdef __cplusplus
extern "C" {
/* -*-c-*-
*
- * $Id: mpalloc.h,v 1.1 1999/11/17 18:02:16 mdw Exp $
+ * $Id: mpalloc.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Allocation and freeing of MP buffers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpalloc.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/11/17 18:02:16 mdw
* New multiprecision integer arithmetic suite.
*
*/
-#ifndef MPARENA_H
-#define MPARENA_H
+#ifndef CATACOMB_MPARENA_H
+#define CATACOMB_MPARENA_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef MPW_H
+#ifndef CATACOMB_MPW_H
# include "mpw.h"
#endif
/* -*-c-*-
*
- * $Id: mpmont.h,v 1.2 1999/11/19 13:17:43 mdw Exp $
+ * $Id: mpmont.h,v 1.3 1999/12/10 23:29:48 mdw Exp $
*
* Montgomery reduction
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpmont.h,v $
+ * Revision 1.3 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.2 1999/11/19 13:17:43 mdw
* Add extra interface to exponentiation which returns a Montgomerized
* result. Add simultaneous exponentiation interface.
*
*/
-#ifndef MPMONT_H
-#define MPMONT_H
+#ifndef CATACOMB_MPMONT_H
+#define CATACOMB_MPMONT_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef MP_H
+#ifndef CATACOMB_MP_H
# include "mp.h"
#endif
-/*----- What's going on here? ---------------------------------------------*
+/*----- Notes on Montgomery reduction -------------------------------------*
*
* Given a little bit of precomputation, Montgomery reduction enables modular
* reductions of products to be calculated rather rapidly, without recourse
* Before starting, you need to do a little work. In particular, the
* following things need to be worked out:
*
- * * %$m$%, which is the modulus you'll be working with.
+ * * %$m$%, which is the modulus you'll be working with. This must be odd,
+ * otherwise the whole thing doesn't work. You're better off using
+ * Barrett reduction if your modulus might be even.
*
* * %$b$%, the radix of the number system you're in (here, it's
* @MPW_MAX + 1@).
* The result of a Montgomery reduction of %$x$% is %$x R^{-1} \bmod m$%,
* which doesn't look ever-so useful. The trick is to initially apply a
* factor of %$R$% to all of your numbers so that when you multiply and
- * perform a Montgomery reduction you get %$(xR \cdot yR)R^{-1} \bmod m$%,
- * which is just %$xyR \bmod m$%. Thanks to distributivity, even additions
+ * perform a Montgomery reduction you get %$(x R \cdot y R) R^{-1} \bmod m$%,
+ * which is just %$x y R \bmod m$%. Thanks to distributivity, even additions
* and subtractions can be performed on numbers in this form -- the extra
* factor of %$R$% just runs through all the calculations until it's finally
* stripped out by a final reduction operation.
* Returns: ---
*
* Use: Initializes a Montgomery reduction context ready for use.
+ * The argument @m@ must be a positive odd integer.
*/
extern void mpmont_create(mpmont */*mm*/, mp */*m*/);
*
* Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
* @mp *d@ = destination
- * @const mp *a@ = source, assumed positive
+ * @mp *a@ = source, assumed positive
*
* Returns: Result, %$a R^{-1} \bmod m$%.
*/
-extern mp *mpmont_reduce(mpmont */*mm*/, mp */*d*/, const mp */*a*/);
+extern mp *mpmont_reduce(mpmont */*mm*/, mp */*d*/, mp */*a*/);
/* --- @mpmont_mul@ --- *
*
* Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
* @mp *d@ = destination
- * @const mp *a, *b@ = sources, assumed positive
+ * @mp *a, *b@ = sources, assumed positive
*
* Returns: Result, %$a b R^{-1} \bmod m$%.
*/
-extern mp *mpmont_mul(mpmont */*mm*/, mp */*d*/,
- const mp */*a*/, const mp */*b*/);
+extern mp *mpmont_mul(mpmont */*mm*/, mp */*d*/, mp */*a*/, mp */*b*/);
/* --- @mpmont_expr@ --- *
*
* Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
- * @const mp *a@ = base
- * @const mp *e@ = exponent
+ * @mp *d@ = fake destination
+ * @mp *a@ = base
+ * @mp *e@ = exponent
*
* Returns: Result, %$a^e R \bmod m$%. This is useful if further modular
* arithmetic is to be performed on the result.
*/
-extern mp *mpmont_expr(mpmont */*mm*/, const mp */*a*/, const mp */*e*/);
+extern mp *mpmont_expr(mpmont */*mm*/, mp */*d*/, mp */*a*/, mp */*e*/);
/* --- @mpmont_exp@ --- *
*
* Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
- * @const mp *a@ = base
- * @const mp *e@ = exponent
+ * @mp *d@ = fake destination
+ * @mp *a@ = base
+ * @mp *e@ = exponent
*
* Returns: Result, %$a^e \bmod m$%.
*/
-extern mp *mpmont_exp(mpmont */*mm*/, const mp */*a*/, const mp */*e*/);
+extern mp *mpmont_exp(mpmont */*mm*/, mp */*d*/, mp */*a*/, mp */*e*/);
/* --- @mpmont_mexpr@ --- *
*
* Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
+ * @mp *d@ = fake destination
* @mpmont_factor *f@ = pointer to array of factors
* @size_t n@ = number of factors supplied
*
* %$g_0^{e_0} g_1^{e_1} \ldots g_{n-1}^{e_{n-1}} R \bmod m$%
*/
-extern mp *mpmont_mexpr(mpmont */*mm*/, mpmont_factor */*f*/, size_t /*n*/);
+extern mp *mpmont_mexpr(mpmont */*mm*/, mp */*d*/,
+ mpmont_factor */*f*/, size_t /*n*/);
/* --- @mpmont_mexp@ --- *
*
* Arguments: @mpmont *mm@ = pointer to Montgomery reduction context
+ * @mp *d@ = fake destination
* @mpmont_factor *f@ = pointer to array of factors
* @size_t n@ = number of factors supplied
*
* Use: Convenient interface over @mpmont_mexpr@.
*/
-extern mp *mpmont_mexp(mpmont */*mm*/, mpmont_factor */*f*/, size_t /*n*/);
+extern mp *mpmont_mexp(mpmont */*mm*/, mp */*d*/,
+ mpmont_factor */*f*/, size_t /*n*/);
/*----- That's all, folks -------------------------------------------------*/
/* -*-c-*-
*
- * $Id: mpscan.h,v 1.2 1999/11/13 01:55:10 mdw Exp $
+ * $Id: mpscan.h,v 1.3 1999/12/10 23:29:48 mdw Exp $
*
* Sequential bit scan of multiprecision integers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpscan.h,v $
+ * Revision 1.3 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.2 1999/11/13 01:55:10 mdw
* Fixed so that they compile. Minor interface changes.
*
*
*/
-#ifndef MPSCAN_H
-#define MPSCAN_H
+#ifndef CATACOMB_MPSCAN_H
+#define CATACOMB_MPSCAN_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef MPW_H
+#ifndef CATACOMB_MPW_H
# include "mpw.h"
#endif
/* -*-c-*-
*
- * $Id: mptext.h,v 1.1 1999/11/17 18:02:16 mdw Exp $
+ * $Id: mptext.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Textual representation of multiprecision numbers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mptext.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/11/17 18:02:16 mdw
* New multiprecision integer arithmetic suite.
*
*/
-#ifndef MPTEXT_H
-#define MPTEXT_H
+#ifndef CATACOMB_MPTEXT_H
+#define CATACOMB_MPTEXT_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef MP_H
+#ifndef CATACOMB_MP_H
# include "mp.h"
#endif
/* -*-c-*-
*
- * $Id: mptypes.c,v 1.2 1999/11/13 01:54:32 mdw Exp $
+ * $Id: mptypes.c,v 1.3 1999/12/10 23:29:48 mdw Exp $
*
* Generate `mptypes.h' header file for current architecture
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mptypes.c,v $
+ * Revision 1.3 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.2 1999/11/13 01:54:32 mdw
* Format source code properly ;-). Attach suffixes to the `max'
* constants.
* mptypes.h [generated]\n\
*/\n\
\n\
-#ifndef MPTYPES_H\n\
-#define MPTYPES_H\n\
+#ifndef CATACOMB_MPTYPES_H\n\
+#define CATACOMB_MPTYPES_H\n\
");
if ((mpd->flags | mpw->flags) & f_stdint) {
puts("\
/* -*-c-*-
*
- * $Id: mpw.h,v 1.1 1999/11/13 01:52:34 mdw Exp $
+ * $Id: mpw.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Very low-level multiprecision definitions
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mpw.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/11/13 01:52:34 mdw
* Very low-level definitions for MP types.
*
*
*/
-#ifndef MPW_H
-#define MPW_H
+#ifndef CATACOMB_MPW_H
+#define CATACOMB_MPW_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef BITS_H
+#ifndef CATACOMB_BITS_H
# include <mLib/bits.h>
#endif
-#ifndef MPTYPES_H
+#ifndef CATACOMB_MPTYPES_H
# include "mptypes.h"
#endif
/* -*-c-*-
*
- * $Id: noise.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: noise.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Acquisition of environmental noise (Unix specific)
*
/*----- Revision history --------------------------------------------------*
*
* $Log: noise.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:12 mdw
* Initial import.
*
*/
-#ifndef NOISE_H
-#define NOISE_H
+#ifndef CATACOMB_NOISE_H
+#define CATACOMB_NOISE_H
#ifdef __cplusplus
extern "C" {
#include <sys/types.h>
-#ifndef RAND_H
+#ifndef CATACOMB_RAND_H
# include "rand.h"
#endif
/* -*-c-*-
*
- * $Id: paranoia.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: paranoia.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Macros and functions for cryptographic paranoia
*
/*----- Revision history --------------------------------------------------*
*
* $Log: paranoia.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:12 mdw
* Initial import.
*
*/
-#ifndef PARANOIA_H
-#define PARANOIA_H
+#ifndef CATACOMB_PARANOIA_H
+#define CATACOMB_PARANOIA_H
#ifdef __cplusplus
extern "C" {
/* -*-c-*-
*
- * $Id: pgen.h,v 1.2 1999/11/20 22:23:05 mdw Exp $
+ * $Id: pgen.h,v 1.3 1999/12/10 23:29:48 mdw Exp $
*
* Finding and testing prime numbers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: pgen.h,v $
+ * Revision 1.3 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.2 1999/11/20 22:23:05 mdw
* Add multiply-and-add function for Diffie-Hellman safe prime generation.
*
*
*/
-#ifndef PGEN_H
-#define PGEN_H
+#ifndef CATACOMB_PGEN_H
+#define CATACOMB_PGEN_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef MP_H
+#ifndef CATACOMB_MP_H
# include "mp.h"
#endif
-#ifndef PTAB_H
+#ifndef CATACOMB_PTAB_H
# include "ptab.h"
#endif
/* -*-c-*-
*
- * $Id: rabin.c,v 1.1 1999/11/19 13:17:57 mdw Exp $
+ * $Id: rabin.c,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Miller-Rabin primality test
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rabin.c,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/11/19 13:17:57 mdw
* Prime number generator and tester.
*
* @y@ here has an extra factor of %$R$%.
*/
- y = mpmont_expr(&r->mm, g, r->r);
+ y = mpmont_expr(&r->mm, MP_NEW, g, r->r);
if (MP_CMP(y, ==, r->mm.r) || MP_CMP(y, ==, r->m1)) {
rc = PGEN_MAYBE;
goto done;
/* -*-c-*-
*
- * $Id: rabin.h,v 1.1 1999/11/19 13:17:57 mdw Exp $
+ * $Id: rabin.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* Miller-Rabin primality test
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rabin.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/11/19 13:17:57 mdw
* Prime number generator and tester.
*
*/
-#ifndef RABIN_H
-#define RABIN_H
+#ifndef CATACOMB_RABIN_H
+#define CATACOMB_RABIN_H
#ifdef __cplusplus
extern "C" {
/*----- Header files ------------------------------------------------------*/
-#ifndef MP_H
+#ifndef CATACOMB_MP_H
# include "mp.h"
#endif
-#ifndef MPMONT_H
+#ifndef CATACOMB_MPMONT_H
# include "mpmont.h"
#endif
-#ifndef PGEN_H
+#ifndef CATACOMB_PGEN_H
# include "pgen.h"
#endif
/* -*-c-*-
*
- * $Id: rand.h,v 1.3 1999/10/15 21:04:30 mdw Exp $
+ * $Id: rand.h,v 1.4 1999/12/10 23:29:48 mdw Exp $
*
* Secure random number generator
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rand.h,v $
+ * Revision 1.4 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.3 1999/10/15 21:04:30 mdw
* Increase output buffer a bit for performance.
*
* concerns I expressed about the Linux generator in a Usenet article to
* sci.crypt.
*
- * The generator is divided into two parts: an input pool and an outpu
+ * The generator is divided into two parts: an input pool and an output
* buffer. New random data is placed into the pool in the way described
* below, which is shamelessly stolen from the Linux /dev/random generator.
* The only interaction that the pool has on the output buffer is through the
* an adversary has to guess before predicting generator output.
*/
-#ifndef RAND_H
-#define RAND_H
+#ifndef CATACOMB_RAND_H
+#define CATACOMB_RAND_H
#ifdef __cplusplus
extern "C" {
#include <stddef.h>
-#include "rmd160-hmac.h"
+#ifndef CATACOMB_GRAND_H
+# include "grand.h"
+#endif
+
+#ifndef CATACOMB_RMD160_HMAC_H
+# include "rmd160-hmac.h"
+#endif
/*----- Magic numbers -----------------------------------------------------*/
extern void rand_getgood(rand_pool */*r*/, void */*p*/, size_t /*sz*/);
+/*----- Generic random number generator interface -------------------------*/
+
+/* --- Miscellaneous operations --- */
+
+enum {
+ RAND_GATE = GRAND_SPECIFIC, /* No args */
+ RAND_STRETCH, /* No args */
+ RAND_KEY, /* @const void *k, size_t sz@ */
+ RAND_NOISESRC /* @const rand_source *s@ */
+};
+
+/* --- Default random number generator --- */
+
+extern grand rand_global;
+
+/* --- @rand_create@ --- *
+ *
+ * Arguments: ---
+ *
+ * Returns: Pointer to a generic generator.
+ *
+ * Use: Constructs a generic generator interface over a Catacomb
+ * entropy pool generator.
+ */
+
+extern grand *rand_create(void);
+
/*----- That's all, folks -------------------------------------------------*/
#ifdef __cplusplus
/* -*-c-*-
*
- * $Id: rc5.h,v 1.1 1999/09/03 08:41:12 mdw Exp $
+ * $Id: rc5.h,v 1.2 1999/12/10 23:29:48 mdw Exp $
*
* The RC5-32/12 block cipher
*
/*----- Revision history --------------------------------------------------*
*
* $Log: rc5.h,v $
+ * Revision 1.2 1999/12/10 23:29:48 mdw
+ * Change header file guard names.
+ *
* Revision 1.1 1999/09/03 08:41:12 mdw
* Initial import.
*
*/
-#ifndef RC5_H
-#define RC5_H
+#ifndef CATACOMB_RC5_H
+#define CATACOMB_RC5_H
#ifdef __cplusplus
extern "C" {