5 # Miscellaneous function interfaces
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.
28 MODULE = Catacomb PACKAGE = Catacomb::Share::GF PREFIX = gfshare_
36 RETVAL = CREATE(Share_GF);
38 croak("share threshhold out of range");
39 gfshare_create(RETVAL, t, sz);
76 mkshares(s, x, r = &rand_global)
86 croak("secret length mismatch");
87 gfshare_mkshares(s, r, p);
97 croak("share index out of range");
99 croak("not making shares");
100 RETVAL = NEWSV(0, s->sz);
102 gfshare_get(s, i, SvPVX(RETVAL));
103 SvCUR_set(RETVAL, s->sz);
118 croak("secret length mismatch");
120 croak("making shares");
122 croak("share index out of range");
124 croak("too many shares");
125 RETVAL = gfshare_add(s, i, p);
134 croak("making shares");
136 croak("not enough shares yet");
137 RETVAL = NEWSV(0, s->sz);
139 gfshare_combine(s, SvPVX(RETVAL));
140 SvCUR_set(RETVAL, s->sz);
144 MODULE = Catacomb PACKAGE = Catacomb::Share::Prime PREFIX = share_
147 new(me, t, p = &PL_sv_undef)
152 RETVAL = CREATE(Share_Prime);
153 if (t < 1 || t > MPW_MAX)
154 croak("share threshhold out of range");
155 share_create(RETVAL, t);
157 RETVAL->p = mp_fromsv(p, "p", 0, 1);
167 RETVAL = MP_COPY(s->p);
196 mkshares(s, x, r = &rand_global)
201 if (s->p && MP_CMP(s->p, <=, x))
202 croak("secret out of range");
203 share_mkshares(s, r, x);
213 croak("share index out of range");
215 croak("not making shares");
226 croak("no prime set");
228 croak("making shares");
230 croak("share index out of range");
232 croak("too many shares");
241 croak("making shares");
243 croak("not enough shares yet");
245 MODULE = Catacomb PACKAGE = Catacomb::Passphrase
248 read(me, tag, len = 256)
253 RETVAL = NEWSV(0, len);
254 if (passphrase_read(tag, PMODE_READ, SvPVX(RETVAL), len + 1))
256 SvCUR_set(RETVAL, strlen(SvPVX(RETVAL)));
262 verify(me, tag, len = 256)
267 RETVAL = NEWSV(0, len);
268 if (passphrase_read(tag, PMODE_VERIFY, SvPVX(RETVAL), len + 1))
270 SvCUR_set(RETVAL, strlen(SvPVX(RETVAL)));
280 passphrase_cancel(tag);
283 MODULE = Catacomb PACKAGE = Catacomb::KeySize
290 RETVAL = keysz(sz, ksz);
302 XPUSHs(sv_2mortal(newSVpv("ANY", 0)));
303 XPUSHs(sv_2mortal(newSViv(ksz[1])));
306 XPUSHs(sv_2mortal(newSVpv("RANGE", 0)));
307 for (i = 1; i < 5; i++)
308 XPUSHs(sv_2mortal(newSViv(ksz[i])));
311 XPUSHs(sv_2mortal(newSVpv("SET", 0)));
312 for (i = 1; ksz[i]; i++)
313 XPUSHs(sv_2mortal(newSViv(ksz[i])));
319 #----- That's all, folks ----------------------------------------------------