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/key.h>
60 #include <catacomb/passphrase.h>
62 #include <catacomb/mp.h>
63 #include <catacomb/gf.h>
64 #include <catacomb/ec.h>
65 #include <catacomb/field.h>
66 #include <catacomb/mpint.h>
67 #include <catacomb/mpmul.h>
68 #include <catacomb/mprand.h>
69 #include <catacomb/mpcrt.h>
70 #include <catacomb/mpmont.h>
71 #include <catacomb/mpbarrett.h>
72 #include <catacomb/mpreduce.h>
73 #include <catacomb/gfreduce.h>
75 #include <catacomb/pfilt.h>
76 #include <catacomb/rabin.h>
77 #include <catacomb/pgen.h>
78 #include <catacomb/limlee.h>
79 #include <catacomb/strongprime.h>
81 /*----- Misc support ------------------------------------------------------*/
83 struct consttab
{ const char *name
; UV val
; };
85 extern U32
findconst(const struct consttab
*cc
,
86 const char *pkg
, const char *name
);
87 extern void ptrtosv(SV
**sv
, void *p
, const char *type
);
88 extern void *ptrfromsv(SV
*sv
, const char *type
, const char *what
, ...);
89 #define SET(sv, ob, ty) sv_setref_pv((sv), (char *)(ty), (void *)(ob))
90 #define MAKE(ob, ty) SET(NEWSV(0, 0), ob, ty)
91 #define RET(ob, ty) SET(sv_newmortal(), ob, ty)
93 /*----- Crypto algorithms -------------------------------------------------*/
95 struct randtab
{ const char *name
; grand
*(*rand
)(const void *, size_t); };
97 typedef const octet keysize
;
101 typedef grand Rand_True
, Rand_DSA
;
103 extern const struct randtab mgftab
[], ctrtab
[], ofbtab
[];
105 extern SV
*findrand(const struct randtab
*rt
, const char *cls
,
106 const char *name
, SV
*k
);
107 extern void listrand(const struct randtab
*rt
);
109 /*------ Key mangling -----------------------------------------------------*/
117 typedef key_data Key_Data
;
118 typedef key_file Key_File
;
120 extern void warn_keyreporter(const char *file
, int line
,
121 const char *err
, void *p
);
122 extern SV
*keyerr(int rc
);
124 /*------ Multiprecision maths ---------------------------------------------*/
127 typedef mpmont MP_Mont
;
128 typedef mpbarrett MP_Barrett
;
129 typedef mpcrt MP_CRT
;
131 typedef mpreduce MP_Reduce
;
132 typedef gfreduce GF_Reduce
;
135 typedef ec_curve EC_Curve
;
138 #define XSINTERFACE_FUNC_SETMP(cv, f) \
139 CvXSUBANY(cv).any_dptr = (void (*) _((void *)))(mp_##f)
140 #define XSINTERFACE_FUNC_SETGF(cv, f) \
141 CvXSUBANY(cv).any_dptr = (void (*) _((void *)))(gf_##f)
143 #define SET_MP(sv, x) SET(sv, x, "Catacomb::MP")
144 #define RET_MP(x) RET(x, "Catacomb::MP")
146 #define SET_GF(sv, x) SET(sv, x, "Catacomb::GF")
147 #define RET_GF(x) RET(x, "Catacomb::GF")
149 extern mp
*mp_fromiv(mp
*d
, IV iv
);
150 extern IV
mp_toiv(mp
*x
);
151 extern mp
*mp_readsv(mp
*m
, SV
*sv
, STRLEN
*off
, int radix
);
152 extern int mp_writesv(mp
*m
, SV
*sv
, int radix
);
153 extern mp
*mp_fromsv(SV
*sv
, const char *what
, const char *ty
,
154 int radix
, int keep
, ...);
156 /*----- Prime generation --------------------------------------------------*/
158 typedef struct { pfilt pf
; int rc
; } MP_Prime_Filter
;
159 typedef rabin MP_Prime_Rabin
;
160 typedef SV MP_Prime_Gen_Proc
, MP_Prime_Gen_NullProc
;
161 typedef struct { pgen_proc
*p
; void *ctx
; } pgmagic
, MP_Prime_Gen_MagicProc
;
162 typedef struct { pgmagic mg
; pgen_filterctx f
; } MP_Prime_Gen_FilterStepper
;
163 typedef struct { pgmagic mg
; pgen_jumpctx j
; pfilt pf
; }
164 MP_Prime_Gen_JumpStepper
;
165 typedef struct { pgmagic mg
; rabin r
; } MP_Prime_Gen_RabinTester
;
166 typedef struct pgen_event MP_Prime_Gen_Event
;
168 extern void pgproc_get(SV
*sv
, pgen_proc
**p
, void **ctx
);
170 /*----- That's all, folks -------------------------------------------------*/