3 * $Id: catacomb-perl.h,v 1.1 2004/04/02 18:04:01 mdw Exp $
5 * Main header file for Catacomb/Perl
7 * (c) 2001 Straylight/Edgeware
10 /*----- Licensing notice --------------------------------------------------*
12 * This file is part of the Perl interface to Catacomb.
14 * Catacomb/Perl is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * Catacomb/Perl is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Catacomb/Perl; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 /*----- Revision history --------------------------------------------------*
31 * $Log: catacomb-perl.h,v $
32 * Revision 1.1 2004/04/02 18:04:01 mdw
37 #ifndef CATACOMB_PERL_H
38 #define CATACOMB_PERL_H
44 /*----- Header files ------------------------------------------------------*/
56 #include <catacomb/gcipher.h>
57 #include <catacomb/ghash.h>
58 #include <catacomb/gmac.h>
60 #include <catacomb/grand.h>
61 #include <catacomb/fibrand.h>
62 #include <catacomb/lcrand.h>
63 #include <catacomb/dsarand.h>
64 #include <catacomb/rand.h>
65 #include <catacomb/noise.h>
67 #include <catacomb/passphrase.h>
69 #include <catacomb/mp.h>
70 #include <catacomb/mpint.h>
71 #include <catacomb/mpmul.h>
72 #include <catacomb/mprand.h>
73 #include <catacomb/mpcrt.h>
74 #include <catacomb/mpmont.h>
75 #include <catacomb/mpbarrett.h>
77 #include <catacomb/pfilt.h>
78 #include <catacomb/rabin.h>
79 #include <catacomb/pgen.h>
80 #include <catacomb/limlee.h>
81 #include <catacomb/strongprime.h>
83 /*----- Misc support ------------------------------------------------------*/
85 struct consttab { const char *name; UV val; };
87 extern U32 findconst(const struct consttab *cc,
88 const char *pkg, const char *name);
90 #define SET(sv, ob, ty) sv_setref_pv((sv), (char *)(ty), (void *)(ob))
91 #define MAKE(ob, ty) SET(NEWSV(0, 0), ob, ty)
92 #define RET(ob, ty) SET(sv_newmortal(), ob, ty)
94 /*----- Crypto algorithms -------------------------------------------------*/
96 struct randtab { const char *name; grand *(*rand)(const void *, size_t); };
98 typedef const octet keysize;
102 typedef grand Rand_True, Rand_DSA;
104 extern const gccipher *ciphertab[];
105 extern const gchash *hashtab[];
106 extern const gcmac *mactab[];
107 extern const struct randtab mgftab[], ctrtab[], ofbtab[];
109 extern SV *findrand(const struct randtab *rt, const char *cls,
110 const char *name, SV *k);
111 extern void listrand(const struct randtab *rt);
113 /*------ Multiprecision maths ---------------------------------------------*/
115 typedef mpmont MP_Mont;
116 typedef mpbarrett MP_Barrett;
117 typedef mpcrt MP_CRT;
119 #define XSINTERFACE_FUNC_SETMP(cv, f) \
120 CvXSUBANY(cv).any_dptr = (void (*) _((void *)))(mp_##f)
122 #define SET_MP(sv, x) SET(sv, x, "Catacomb::MP")
123 #define RET_MP(x) RET(x, "Catacomb::MP")
125 extern mp *mp_fromiv(mp *d, IV iv);
126 extern IV mp_toiv(mp *x);
127 extern mp *mp_readsv(mp *m, SV *sv, STRLEN *off, int radix);
128 extern int mp_writesv(mp *m, SV *sv, int radix);
129 extern mp *mp_fromsv(SV *sv, const char *what, int radix, int keep, ...);
131 /*----- Prime generation --------------------------------------------------*/
133 typedef struct { pfilt pf; int rc; } MP_Prime_Filter;
134 typedef rabin MP_Prime_Rabin;
135 typedef SV MP_Prime_Gen_Proc, MP_Prime_Gen_NullProc;
136 typedef struct { pgen_proc *p; void *ctx; } pgmagic, MP_Prime_Gen_MagicProc;
137 typedef struct { pgmagic mg; pgen_filterctx f; } MP_Prime_Gen_FilterStepper;
138 typedef struct { pgmagic mg; pgen_jumpctx j; pfilt pf; }
139 MP_Prime_Gen_JumpStepper;
140 typedef struct { pgmagic mg; rabin r; } MP_Prime_Gen_RabinTester;
141 typedef struct pgen_event MP_Prime_Gen_Event;
143 extern void pgproc_get(SV *sv, pgen_proc **p, void **ctx);
145 /*----- That's all, folks -------------------------------------------------*/