/* -*-c-*-
*
- * $Id: catacomb-perl.h,v 1.2 2004/04/08 01:36:21 mdw Exp $
+ * $Id$
*
* Main header file for Catacomb/Perl
*
/*----- Header files ------------------------------------------------------*/
+#include <EXTERN.h>
+#include <perl.h>
+#include <XSUB.h>
+
#include <assert.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include <EXTERN.h>
-#include <perl.h>
-#include <XSUB.h>
-
#include <catacomb/gcipher.h>
#include <catacomb/ghash.h>
#include <catacomb/gmac.h>
#include <catacomb/rand.h>
#include <catacomb/noise.h>
+#include <catacomb/key.h>
#include <catacomb/passphrase.h>
#include <catacomb/mp.h>
+#include <catacomb/gf.h>
+#include <catacomb/ec.h>
+#include <catacomb/field.h>
#include <catacomb/mpint.h>
#include <catacomb/mpmul.h>
#include <catacomb/mprand.h>
#include <catacomb/mpcrt.h>
#include <catacomb/mpmont.h>
#include <catacomb/mpbarrett.h>
+#include <catacomb/mpreduce.h>
+#include <catacomb/gfreduce.h>
#include <catacomb/pfilt.h>
#include <catacomb/rabin.h>
extern U32 findconst(const struct consttab *cc,
const char *pkg, const char *name);
-
+extern void ptrtosv(SV **sv, void *p, const char *type);
+extern void *ptrfromsv(SV *sv, const char *type, const char *what, ...);
#define SET(sv, ob, ty) sv_setref_pv((sv), (char *)(ty), (void *)(ob))
#define MAKE(ob, ty) SET(NEWSV(0, 0), ob, ty)
#define RET(ob, ty) SET(sv_newmortal(), ob, ty)
typedef grand Rand_True, Rand_DSA;
-extern const gccipher *ciphertab[];
-extern const gchash *hashtab[];
-extern const gcmac *mactab[];
extern const struct randtab mgftab[], ctrtab[], ofbtab[];
extern SV *findrand(const struct randtab *rt, const char *cls,
const char *name, SV *k);
extern void listrand(const struct randtab *rt);
+/*------ Key mangling -----------------------------------------------------*/
+
+typedef struct Key {
+ key_file *kf;
+ key *k;
+} Key;
+
+typedef int KeyErr;
+typedef key_data Key_Data;
+typedef key_file Key_File;
+
+extern void warn_keyreporter(const char *file, int line,
+ const char *err, void *p);
+extern SV *keyerr(int rc);
+
/*------ Multiprecision maths ---------------------------------------------*/
+typedef mp gf;
typedef mpmont MP_Mont;
typedef mpbarrett MP_Barrett;
typedef mpcrt MP_CRT;
+typedef mpreduce MP_Reduce;
+typedef gfreduce GF_Reduce;
+
+typedef ec EC_Point;
+typedef ec_curve EC_Curve;
+typedef field Field;
+
#define XSINTERFACE_FUNC_SETMP(cv, f) \
CvXSUBANY(cv).any_dptr = (void (*) _((void *)))(mp_##f)
+#define XSINTERFACE_FUNC_SETGF(cv, f) \
+ CvXSUBANY(cv).any_dptr = (void (*) _((void *)))(gf_##f)
#define SET_MP(sv, x) SET(sv, x, "Catacomb::MP")
#define RET_MP(x) RET(x, "Catacomb::MP")
+#define SET_GF(sv, x) SET(sv, x, "Catacomb::GF")
+#define RET_GF(x) RET(x, "Catacomb::GF")
+
extern mp *mp_fromiv(mp *d, IV iv);
extern IV mp_toiv(mp *x);
extern mp *mp_readsv(mp *m, SV *sv, STRLEN *off, int radix);
extern int mp_writesv(mp *m, SV *sv, int radix);
-extern mp *mp_fromsv(SV *sv, const char *what, int radix, int keep, ...);
+extern mp *mp_fromsv(SV *sv, const char *what, const char *ty,
+ int radix, int keep, ...);
/*----- Prime generation --------------------------------------------------*/