3 * $Id: catacomb-perl.h,v 1.2 2004/04/08 01:36:21 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 #ifndef CATACOMB_PERL_H
30 #define CATACOMB_PERL_H
36 /*----- Header files ------------------------------------------------------*/
48 #include <catacomb/gcipher.h>
49 #include <catacomb/ghash.h>
50 #include <catacomb/gmac.h>
52 #include <catacomb/grand.h>
53 #include <catacomb/fibrand.h>
54 #include <catacomb/lcrand.h>
55 #include <catacomb/dsarand.h>
56 #include <catacomb/rand.h>
57 #include <catacomb/noise.h>
59 #include <catacomb/passphrase.h>
61 #include <catacomb/mp.h>
62 #include <catacomb/mpint.h>
63 #include <catacomb/mpmul.h>
64 #include <catacomb/mprand.h>
65 #include <catacomb/mpcrt.h>
66 #include <catacomb/mpmont.h>
67 #include <catacomb/mpbarrett.h>
69 #include <catacomb/pfilt.h>
70 #include <catacomb/rabin.h>
71 #include <catacomb/pgen.h>
72 #include <catacomb/limlee.h>
73 #include <catacomb/strongprime.h>
75 /*----- Misc support ------------------------------------------------------*/
77 struct consttab
{ const char *name
; UV val
; };
79 extern U32
findconst(const struct consttab
*cc
,
80 const char *pkg
, const char *name
);
82 #define SET(sv, ob, ty) sv_setref_pv((sv), (char *)(ty), (void *)(ob))
83 #define MAKE(ob, ty) SET(NEWSV(0, 0), ob, ty)
84 #define RET(ob, ty) SET(sv_newmortal(), ob, ty)
86 /*----- Crypto algorithms -------------------------------------------------*/
88 struct randtab
{ const char *name
; grand
*(*rand
)(const void *, size_t); };
90 typedef const octet keysize
;
94 typedef grand Rand_True
, Rand_DSA
;
96 extern const gccipher
*ciphertab
[];
97 extern const gchash
*hashtab
[];
98 extern const gcmac
*mactab
[];
99 extern const struct randtab mgftab
[], ctrtab
[], ofbtab
[];
101 extern SV
*findrand(const struct randtab
*rt
, const char *cls
,
102 const char *name
, SV
*k
);
103 extern void listrand(const struct randtab
*rt
);
105 /*------ Multiprecision maths ---------------------------------------------*/
107 typedef mpmont MP_Mont
;
108 typedef mpbarrett MP_Barrett
;
109 typedef mpcrt MP_CRT
;
111 #define XSINTERFACE_FUNC_SETMP(cv, f) \
112 CvXSUBANY(cv).any_dptr = (void (*) _((void *)))(mp_##f)
114 #define SET_MP(sv, x) SET(sv, x, "Catacomb::MP")
115 #define RET_MP(x) RET(x, "Catacomb::MP")
117 extern mp
*mp_fromiv(mp
*d
, IV iv
);
118 extern IV
mp_toiv(mp
*x
);
119 extern mp
*mp_readsv(mp
*m
, SV
*sv
, STRLEN
*off
, int radix
);
120 extern int mp_writesv(mp
*m
, SV
*sv
, int radix
);
121 extern mp
*mp_fromsv(SV
*sv
, const char *what
, int radix
, int keep
, ...);
123 /*----- Prime generation --------------------------------------------------*/
125 typedef struct { pfilt pf
; int rc
; } MP_Prime_Filter
;
126 typedef rabin MP_Prime_Rabin
;
127 typedef SV MP_Prime_Gen_Proc
, MP_Prime_Gen_NullProc
;
128 typedef struct { pgen_proc
*p
; void *ctx
; } pgmagic
, MP_Prime_Gen_MagicProc
;
129 typedef struct { pgmagic mg
; pgen_filterctx f
; } MP_Prime_Gen_FilterStepper
;
130 typedef struct { pgmagic mg
; pgen_jumpctx j
; pfilt pf
; }
131 MP_Prime_Gen_JumpStepper
;
132 typedef struct { pgmagic mg
; rabin r
; } MP_Prime_Gen_RabinTester
;
133 typedef struct pgen_event MP_Prime_Gen_Event
;
135 extern void pgproc_get(SV
*sv
, pgen_proc
**p
, void **ctx
);
137 /*----- That's all, folks -------------------------------------------------*/