File Coverage

Perl.c
Criterion Covered Total %
statement 125 157 79.6
branch 27 78 34.6
condition n/a
subroutine n/a
pod n/a
total 152 235 64.6


line stmt bran cond sub pod time code
1             /*
2             * This file was generated automatically by ExtUtils::ParseXS version 3.57 from the
3             * contents of Perl.xs. Do not edit this file, edit Perl.xs instead.
4             *
5             * ANY CHANGES MADE HERE WILL BE LOST!
6             *
7             */
8              
9             #line 1 "Perl.xs"
10             #define PERL_NO_GET_CONTEXT
11             #include "EXTERN.h"
12             #include "perl.h"
13             #include "XSUB.h"
14             #include "ppport.h"
15              
16             typedef struct chacha_ctx *Crypt__OpenSSH__ChachaPoly;
17              
18             /* work around unportable mess in fixedint.h */
19             /* taken from libecb */
20             #ifdef _WIN32
21             typedef signed char int8_t;
22             typedef unsigned char uint8_t;
23             typedef signed short int16_t;
24             typedef unsigned short uint16_t;
25             typedef signed int int32_t;
26             typedef unsigned int uint32_t;
27             #if __GNUC__
28             typedef signed long long int64_t;
29             typedef unsigned long long uint64_t;
30             #else /* _MSC_VER || __BORLANDC__ */
31             typedef signed __int64 int64_t;
32             typedef unsigned __int64 uint64_t;
33             #endif
34             #define UINT64_C(v) v
35             #else
36             #include
37             #endif
38             #define FIXEDINT_H_INCLUDED
39              
40             #line 41 "Perl.c"
41             #ifndef PERL_UNUSED_VAR
42             # define PERL_UNUSED_VAR(var) if (0) var = var
43             #endif
44              
45             #ifndef dVAR
46             # define dVAR dNOOP
47             #endif
48              
49              
50             /* This stuff is not part of the API! You have been warned. */
51             #ifndef PERL_VERSION_DECIMAL
52             # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
53             #endif
54             #ifndef PERL_DECIMAL_VERSION
55             # define PERL_DECIMAL_VERSION \
56             PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
57             #endif
58             #ifndef PERL_VERSION_GE
59             # define PERL_VERSION_GE(r,v,s) \
60             (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
61             #endif
62             #ifndef PERL_VERSION_LE
63             # define PERL_VERSION_LE(r,v,s) \
64             (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
65             #endif
66              
67             /* XS_INTERNAL is the explicit static-linkage variant of the default
68             * XS macro.
69             *
70             * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
71             * "STATIC", ie. it exports XSUB symbols. You probably don't want that
72             * for anything but the BOOT XSUB.
73             *
74             * See XSUB.h in core!
75             */
76              
77              
78             /* TODO: This might be compatible further back than 5.10.0. */
79             #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
80             # undef XS_EXTERNAL
81             # undef XS_INTERNAL
82             # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
83             # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
84             # define XS_INTERNAL(name) STATIC XSPROTO(name)
85             # endif
86             # if defined(__SYMBIAN32__)
87             # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
88             # define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
89             # endif
90             # ifndef XS_EXTERNAL
91             # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
92             # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
93             # define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
94             # else
95             # ifdef __cplusplus
96             # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
97             # define XS_INTERNAL(name) static XSPROTO(name)
98             # else
99             # define XS_EXTERNAL(name) XSPROTO(name)
100             # define XS_INTERNAL(name) STATIC XSPROTO(name)
101             # endif
102             # endif
103             # endif
104             #endif
105              
106             /* perl >= 5.10.0 && perl <= 5.15.1 */
107              
108              
109             /* The XS_EXTERNAL macro is used for functions that must not be static
110             * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
111             * macro defined, the best we can do is assume XS is the same.
112             * Dito for XS_INTERNAL.
113             */
114             #ifndef XS_EXTERNAL
115             # define XS_EXTERNAL(name) XS(name)
116             #endif
117             #ifndef XS_INTERNAL
118             # define XS_INTERNAL(name) XS(name)
119             #endif
120              
121             /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
122             * internal macro that we're free to redefine for varying linkage due
123             * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
124             * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
125             */
126              
127             #undef XS_EUPXS
128             #if defined(PERL_EUPXS_ALWAYS_EXPORT)
129             # define XS_EUPXS(name) XS_EXTERNAL(name)
130             #else
131             /* default to internal */
132             # define XS_EUPXS(name) XS_INTERNAL(name)
133             #endif
134              
135             #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
136             #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
137              
138             /* prototype to pass -Wmissing-prototypes */
139             STATIC void
140             S_croak_xs_usage(const CV *const cv, const char *const params);
141              
142             STATIC void
143             S_croak_xs_usage(const CV *const cv, const char *const params)
144             {
145             const GV *const gv = CvGV(cv);
146              
147             PERL_ARGS_ASSERT_CROAK_XS_USAGE;
148              
149             if (gv) {
150             const char *const gvname = GvNAME(gv);
151             const HV *const stash = GvSTASH(gv);
152             const char *const hvname = stash ? HvNAME(stash) : NULL;
153              
154             if (hvname)
155             Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
156             else
157             Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
158             } else {
159             /* Pants. I don't think that it should be possible to get here. */
160             Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
161             }
162             }
163             #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
164              
165             #define croak_xs_usage S_croak_xs_usage
166              
167             #endif
168              
169             /* NOTE: the prototype of newXSproto() is different in versions of perls,
170             * so we define a portable version of newXSproto()
171             */
172             #ifdef newXS_flags
173             #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
174             #else
175             #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
176             #endif /* !defined(newXS_flags) */
177              
178             #if PERL_VERSION_LE(5, 21, 5)
179             # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
180             #else
181             # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
182             #endif
183              
184             /* simple backcompat versions of the TARGx() macros with no optimisation */
185             #ifndef TARGi
186             # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
187             # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
188             # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
189             #endif
190              
191             #line 192 "Perl.c"
192              
193             /* INCLUDE: Including 'lib/Net/SSH/Perl/Key/Ed25519.xs' from 'Perl.xs' */
194              
195              
196             /* INCLUDE: Including 'lib/Net/SSH/Perl/Cipher/ChachaPoly.xs' from 'lib/Net/SSH/Perl/Key/Ed25519.xs' */
197              
198             #include "src/chacha/chacha.c"
199              
200             #include "src/chacha/poly1305.c"
201              
202             XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_new); /* prototype to pass -Wmissing-prototypes */
203 12           XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_new)
204             {
205 12           dVAR; dXSARGS;
206 12 50         if (items != 2)
207 0           croak_xs_usage(cv, "class, key");
208             {
209 12           SV * class = ST(0)
210             ;
211 12 50         SV * key = ST(1)
212             ;
213             Crypt__OpenSSH__ChachaPoly RETVAL;
214             #line 13 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
215             {
216             STRLEN keysize;
217             keysize = SvCUR(key);
218              
219             if (keysize != 16 && keysize != 32)
220             croak ("The key must be 128 or 256 bits long");
221              
222             Newxz(RETVAL, 1, struct chacha_ctx);
223             chacha_keysetup(RETVAL, (unsigned char *) SvPV_nolen(key), keysize*8);
224             }
225             #line 226 "Perl.c"
226             {
227             SV * RETVALSV;
228 12           RETVALSV = sv_newmortal();
229 12           sv_setref_pv(RETVALSV, "Crypt::OpenSSH::ChachaPoly", (void*)RETVAL);
230 12           ST(0) = RETVALSV;
231             }
232             }
233 12           XSRETURN(1);
234             }
235              
236              
237             XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_encrypt); /* prototype to pass -Wmissing-prototypes */
238 12           XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_encrypt)
239             {
240 12           dVAR; dXSARGS;
241 12           dXSI32;
242 12 50         if (items != 2)
243 0           croak_xs_usage(cv, "self, data");
244             {
245             Crypt__OpenSSH__ChachaPoly self;
246 12           SV * data = ST(1)
247             ;
248             SV * RETVAL;
249              
250 12 50         if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) {
    50          
251 12           IV tmp = SvIV((SV*)SvRV(ST(0)));
252 12           self = INT2PTR(Crypt__OpenSSH__ChachaPoly,tmp);
253             }
254             else {
255 0 0         const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
    0          
256 0           Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
257 0           GvNAME(CvGV(cv)),
258             "self", "Crypt::OpenSSH::ChachaPoly",
259 0           refstr, ST(0)
260             );
261             }
262             ;
263             #line 33 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
264             {
265             STRLEN size;
266             void *bytes = SvPV(data,size);
267              
268             if (size) {
269             RETVAL = NEWSV (0, size);
270             SvPOK_only (RETVAL);
271             SvCUR_set (RETVAL, size);
272             chacha_encrypt_bytes(self, bytes, (unsigned char *) SvPV_nolen(RETVAL), (int) size);
273             } else {
274             RETVAL = newSVpv ("", 0);
275             }
276              
277             }
278             #line 279 "Perl.c"
279 12           RETVAL = sv_2mortal(RETVAL);
280 12           ST(0) = RETVAL;
281             }
282 12           XSRETURN(1);
283             }
284              
285              
286             XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_ivsetup); /* prototype to pass -Wmissing-prototypes */
287 12           XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_ivsetup)
288             {
289 12           dVAR; dXSARGS;
290 12 50         if (items != 3)
291 0           croak_xs_usage(cv, "self, iv, counter");
292             {
293             Crypt__OpenSSH__ChachaPoly self;
294 12           SV * iv = ST(1)
295             ;
296 12           SV * counter = ST(2)
297             ;
298              
299 12 50         if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) {
    50          
300 12           IV tmp = SvIV((SV*)SvRV(ST(0)));
301 12           self = INT2PTR(Crypt__OpenSSH__ChachaPoly,tmp);
302             }
303             else {
304 0 0         const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
    0          
305 0           Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
306             "Crypt::OpenSSH::ChachaPoly::ivsetup",
307             "self", "Crypt::OpenSSH::ChachaPoly",
308 0           refstr, ST(0)
309             );
310             }
311             ;
312             #line 56 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
313             {
314             STRLEN iv_l ; unsigned char *iv_p = (unsigned char *) SvPVbyte (iv, iv_l);
315             /* anything beyond 64 bits is ignored */
316             if (iv_l < 8) {
317             croak("ivsetup: iv must be 64 bits long!");
318             }
319             STRLEN counter_l ; unsigned char *counter_p = (unsigned char *) SvPVbyte (counter, counter_l);
320             if (counter_l == 0)
321             counter_p = NULL;
322             /* anything beyond 8 chars is ignored */
323             else if (counter_l < 8)
324             croak ("ivsetup: counter must be 64 bits long!");
325             chacha_ivsetup(self, iv_p, counter_p);
326             }
327             #line 328 "Perl.c"
328             }
329 12           XSRETURN_EMPTY;
330             }
331              
332              
333             XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_DESTROY); /* prototype to pass -Wmissing-prototypes */
334 12           XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_DESTROY)
335             {
336 12           dVAR; dXSARGS;
337 12 50         if (items != 1)
338 0           croak_xs_usage(cv, "self");
339             {
340             Crypt__OpenSSH__ChachaPoly self;
341              
342 12 50         if (SvROK(ST(0))) {
343 12           IV tmp = SvIV((SV*)SvRV(ST(0)));
344 12           self = INT2PTR(Crypt__OpenSSH__ChachaPoly,tmp);
345             }
346             else
347 0           Perl_croak_nocontext("%s: %s is not a reference",
348             "Crypt::OpenSSH::ChachaPoly::DESTROY",
349             "self")
350             ;
351             #line 75 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
352             Safefree(self);
353             #line 354 "Perl.c"
354             }
355 12           XSRETURN_EMPTY;
356             }
357              
358              
359             XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_poly1305); /* prototype to pass -Wmissing-prototypes */
360 6           XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_poly1305)
361             {
362 6           dVAR; dXSARGS;
363 6 50         if (items != 3)
364 0           croak_xs_usage(cv, "self, data, key");
365             {
366             Crypt__OpenSSH__ChachaPoly self;
367 6           SV * data = ST(1)
368             ;
369 6           SV * key = ST(2)
370             ;
371             SV * RETVAL;
372              
373 6 50         if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) {
    50          
374 6           IV tmp = SvIV((SV*)SvRV(ST(0)));
375 6           self = INT2PTR(Crypt__OpenSSH__ChachaPoly,tmp);
376             }
377             else {
378 0 0         const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
    0          
379 0           Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
380             "Crypt::OpenSSH::ChachaPoly::poly1305",
381             "self", "Crypt::OpenSSH::ChachaPoly",
382 0           refstr, ST(0)
383             );
384             }
385             ;
386             #line 83 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
387             {
388             STRLEN size;
389             void *databytes = SvPV(data,size);
390              
391             STRLEN keysize;
392             keysize = SvCUR(key);
393             if (keysize != POLY1305_KEYLEN)
394             croak("Key is incorrect size");
395             void *keybytes = SvPV_nolen(key);
396              
397             RETVAL = NEWSV(0, POLY1305_TAGLEN);
398             SvPOK_only (RETVAL);
399             SvCUR_set (RETVAL, POLY1305_TAGLEN);
400             poly1305_auth((unsigned char *) SvPV_nolen(RETVAL),databytes,(int) size,keybytes);
401             }
402             #line 403 "Perl.c"
403 6           RETVAL = sv_2mortal(RETVAL);
404 6           ST(0) = RETVAL;
405             }
406 6           XSRETURN(1);
407             }
408              
409              
410             /* INCLUDE: Returning to 'lib/Net/SSH/Perl/Key/Ed25519.xs' from 'lib/Net/SSH/Perl/Cipher/ChachaPoly.xs' */
411              
412             #include "src/blowfish/blowfish.c"
413              
414             #include "src/ed25519/keypair.c"
415             #include "src/ed25519/sign.c"
416             #include "src/ed25519/verify.c"
417             #include "src/ed25519/sha512.c"
418             #define select(a,b,c) ed25519_select (a, b, c)
419             #include "src/ed25519/ge.c"
420             #include "src/ed25519/fe.c"
421             #define load_3(x) sc_load_3(x)
422             #define load_4(x) sc_load_4(x)
423             #include "src/ed25519/sc.c"
424              
425             XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_init); /* prototype to pass -Wmissing-prototypes */
426 32           XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_init)
427             {
428 32           dVAR; dXSARGS;
429 32 50         if (items != 0)
430 0           croak_xs_usage(cv, "");
431             {
432             blf_ctx * RETVAL;
433             #line 20 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
434             {
435             Newxz(RETVAL, 1, blf_ctx);
436             Blowfish_initstate(RETVAL);
437             }
438             #line 439 "Perl.c"
439             {
440             SV * RETVALSV;
441 32           RETVALSV = sv_newmortal();
442 32           sv_setref_pv(RETVALSV, "blf_ctxPtr", (void*)RETVAL);
443 32           ST(0) = RETVALSV;
444             }
445             }
446 32           XSRETURN(1);
447             }
448              
449              
450             XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_expandstate); /* prototype to pass -Wmissing-prototypes */
451 32           XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_expandstate)
452             {
453 32           dVAR; dXSARGS;
454 32 50         if (items != 3)
455 0           croak_xs_usage(cv, "ctx, sv_data, sv_key");
456             {
457             blf_ctx * ctx;
458 32           SV * sv_data = ST(1)
459             ;
460 32           SV * sv_key = ST(2)
461             ;
462              
463 32 50         if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) {
    50          
464 32           IV tmp = SvIV((SV*)SvRV(ST(0)));
465 32           ctx = INT2PTR(blf_ctx *,tmp);
466             }
467             else {
468 0 0         const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
    0          
469 0           Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
470             "Net::SSH::Perl::Key::Ed25519::bf_expandstate",
471             "ctx", "blf_ctxPtr",
472 0           refstr, ST(0)
473             );
474             }
475             ;
476             #line 33 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
477             {
478             STRLEN datalen; unsigned char *data = (unsigned char *) SvPVbyte(sv_data,datalen);
479             STRLEN keylen; unsigned char *key = (unsigned char *) SvPVbyte(sv_key,keylen);
480             Blowfish_expandstate(ctx, data, datalen, key, keylen);
481             }
482             #line 483 "Perl.c"
483             }
484 32           XSRETURN_EMPTY;
485             }
486              
487              
488             XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_expand0state); /* prototype to pass -Wmissing-prototypes */
489 4096           XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_expand0state)
490             {
491 4096           dVAR; dXSARGS;
492 4096 50         if (items != 2)
493 0           croak_xs_usage(cv, "ctx, sv_key");
494             {
495             blf_ctx * ctx;
496 4096           SV * sv_key = ST(1)
497             ;
498              
499 4096 50         if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) {
    50          
500 4096           IV tmp = SvIV((SV*)SvRV(ST(0)));
501 4096           ctx = INT2PTR(blf_ctx *,tmp);
502             }
503             else {
504 0 0         const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
    0          
505 0           Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
506             "Net::SSH::Perl::Key::Ed25519::bf_expand0state",
507             "ctx", "blf_ctxPtr",
508 0           refstr, ST(0)
509             );
510             }
511             ;
512             #line 44 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
513             {
514             STRLEN keylen;
515             unsigned char *key = (unsigned char *) SvPVbyte(sv_key,keylen);
516             Blowfish_expand0state(ctx,key,keylen);
517             }
518             #line 519 "Perl.c"
519             }
520 4096           XSRETURN_EMPTY;
521             }
522              
523              
524             XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_encrypt_iterate); /* prototype to pass -Wmissing-prototypes */
525 32           XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_encrypt_iterate)
526             {
527 32           dVAR; dXSARGS;
528 32 50         if (items != 3)
529 0           croak_xs_usage(cv, "ctx, sv_data, sv_rounds");
530             {
531             blf_ctx * ctx;
532 32           SV * sv_data = ST(1)
533             ;
534 32           SV * sv_rounds = ST(2)
535             ;
536             SV * RETVAL;
537              
538 32 50         if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) {
    50          
539 32           IV tmp = SvIV((SV*)SvRV(ST(0)));
540 32           ctx = INT2PTR(blf_ctx *,tmp);
541             }
542             else {
543 0 0         const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
    0          
544 0           Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
545             "Net::SSH::Perl::Key::Ed25519::bf_encrypt_iterate",
546             "ctx", "blf_ctxPtr",
547 0           refstr, ST(0)
548             );
549             }
550             ;
551             #line 56 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
552             {
553             STRLEN datalen;
554             unsigned char *data = (unsigned char *) SvPVbyte(sv_mortalcopy(sv_data),datalen);
555             if (datalen % 8)
556             croak("data must be in 8-byte chunks");
557              
558             uint16_t words = datalen / 4;
559             uint32_t cdata[words];
560             uint16_t j = 0;
561             int i;
562             int rounds = SvIVx(sv_rounds);
563              
564             for (i=0; i
565             cdata[i] = Blowfish_stream2word(data, datalen, &j);
566             for (i=0; i
567             blf_enc(ctx, cdata, sizeof(cdata) / sizeof(uint64_t));
568              
569             for (i=0; i
570             data[4 * i + 3] = (cdata[i] >> 24) & 0xff;
571             data[4 * i + 2] = (cdata[i] >> 16) & 0xff;
572             data[4 * i + 1] = (cdata[i] >> 8) & 0xff;
573             data[4 * i ] = cdata[i] & 0xff;
574             }
575             RETVAL = newSVpvn ((char *) data, datalen);
576             }
577             #line 578 "Perl.c"
578 32           RETVAL = sv_2mortal(RETVAL);
579 32           ST(0) = RETVAL;
580             }
581 32           XSRETURN(1);
582             }
583              
584              
585             XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_generate_keypair); /* prototype to pass -Wmissing-prototypes */
586 1           XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_generate_keypair)
587             {
588 1           dVAR; dXSARGS;
589 1 50         if (items != 1)
590 0           croak_xs_usage(cv, "secret");
591             PERL_UNUSED_VAR(ax); /* -Wall */
592 1           SP -= items;
593             {
594 1           SV * secret = ST(0)
595             ;
596             #line 88 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
597             {
598             STRLEN secret_l; unsigned char *secret_p;
599              
600             unsigned char public_key[32];
601             unsigned char private_key[64];
602              
603             secret_p = (unsigned char *)SvPVbyte (secret, secret_l);
604              
605             if (secret_l != 32)
606             croak ("secret has wrong length (!= 32)");
607              
608             ed25519_create_keypair (public_key, private_key, (unsigned char *)secret_p);
609              
610             EXTEND (SP, 2);
611             PUSHs (sv_2mortal (newSVpvn ((char *)public_key, sizeof public_key)));
612             PUSHs (sv_2mortal (newSVpvn ((char *)private_key, sizeof private_key)));
613             }
614             #line 615 "Perl.c"
615 1           PUTBACK;
616 1           return;
617             }
618             }
619              
620              
621             XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_sign_message); /* prototype to pass -Wmissing-prototypes */
622 1           XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_sign_message)
623             {
624 1           dVAR; dXSARGS;
625 1 50         if (items != 2)
626 0           croak_xs_usage(cv, "message, private_key");
627             {
628 1           SV * message = ST(0)
629             ;
630 1           SV * private_key = ST(1)
631             ;
632             SV * RETVAL;
633             #line 111 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
634             {
635             unsigned char signature[64];
636              
637             STRLEN message_l ; char *message_p = SvPVbyte (message , message_l );
638             STRLEN private_key_l; char *private_key_p = SvPVbyte (private_key, private_key_l);
639              
640             if (private_key_l != 64)
641             croak ("private key has wrong length (!= 64)");
642              
643             ed25519_sign (signature, (unsigned char *)message_p, message_l, (unsigned char *)private_key_p);
644              
645             RETVAL = newSVpvn ((char *)signature, sizeof signature);
646             }
647             #line 648 "Perl.c"
648 1           RETVAL = sv_2mortal(RETVAL);
649 1           ST(0) = RETVAL;
650             }
651 1           XSRETURN(1);
652             }
653              
654              
655             XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_verify_message); /* prototype to pass -Wmissing-prototypes */
656 1           XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_verify_message)
657             {
658 1           dVAR; dXSARGS;
659 1 50         if (items != 3)
660 0           croak_xs_usage(cv, "message, public_key, signature");
661             {
662             bool RETVAL;
663 1           SV * message = ST(0)
664             ;
665 1           SV * public_key = ST(1)
666             ;
667 1           SV * signature = ST(2)
668             ;
669             #line 130 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
670             {
671             STRLEN signature_l ; char *signature_p = SvPVbyte (signature , signature_l );
672             STRLEN message_l ; char *message_p = SvPVbyte (message , message_l );
673             STRLEN public_key_l; char *public_key_p = SvPVbyte (public_key, public_key_l);
674              
675             if (public_key_l != 32)
676             croak ("public key has wrong length (!= 32)");
677              
678             RETVAL = ed25519_verify ((unsigned char *)signature_p, (unsigned char *)message_p, message_l, (unsigned char *)public_key_p);
679             }
680             #line 681 "Perl.c"
681 1 50         ST(0) = boolSV(RETVAL);
682             }
683 1           XSRETURN(1);
684             }
685              
686              
687             /* INCLUDE: Returning to 'Perl.xs' from 'lib/Net/SSH/Perl/Key/Ed25519.xs' */
688              
689             #ifdef __cplusplus
690             extern "C" {
691             #endif
692             XS_EXTERNAL(boot_Net__SSH__Perl); /* prototype to pass -Wmissing-prototypes */
693 2           XS_EXTERNAL(boot_Net__SSH__Perl)
694             {
695             #if PERL_VERSION_LE(5, 21, 5)
696             dVAR; dXSARGS;
697             #else
698 2           dVAR; dXSBOOTARGSXSAPIVERCHK;
699             #endif
700             #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
701             char* file = __FILE__;
702             #else
703 2           const char* file = __FILE__;
704             #endif
705              
706             PERL_UNUSED_VAR(file);
707              
708             PERL_UNUSED_VAR(cv); /* -W */
709             PERL_UNUSED_VAR(items); /* -W */
710             #if PERL_VERSION_LE(5, 21, 5)
711             XS_VERSION_BOOTCHECK;
712             # ifdef XS_APIVERSION_BOOTCHECK
713             XS_APIVERSION_BOOTCHECK;
714             # endif
715             #endif
716              
717 2           (void)newXSproto_portable("Crypt::OpenSSH::ChachaPoly::new", XS_Crypt__OpenSSH__ChachaPoly_new, file, "$$");
718 2           cv = newXSproto_portable("Crypt::OpenSSH::ChachaPoly::decrypt", XS_Crypt__OpenSSH__ChachaPoly_encrypt, file, "$$");
719 2           XSANY.any_i32 = 1;
720 2           cv = newXSproto_portable("Crypt::OpenSSH::ChachaPoly::encrypt", XS_Crypt__OpenSSH__ChachaPoly_encrypt, file, "$$");
721 2           XSANY.any_i32 = 0;
722 2           (void)newXSproto_portable("Crypt::OpenSSH::ChachaPoly::ivsetup", XS_Crypt__OpenSSH__ChachaPoly_ivsetup, file, "$$$");
723 2           (void)newXSproto_portable("Crypt::OpenSSH::ChachaPoly::DESTROY", XS_Crypt__OpenSSH__ChachaPoly_DESTROY, file, "$");
724 2           (void)newXSproto_portable("Crypt::OpenSSH::ChachaPoly::poly1305", XS_Crypt__OpenSSH__ChachaPoly_poly1305, file, "$$$");
725 2           (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::bf_init", XS_Net__SSH__Perl__Key__Ed25519_bf_init, file, "");
726 2           (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::bf_expandstate", XS_Net__SSH__Perl__Key__Ed25519_bf_expandstate, file, "$$$");
727 2           (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::bf_expand0state", XS_Net__SSH__Perl__Key__Ed25519_bf_expand0state, file, "$$");
728 2           (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::bf_encrypt_iterate", XS_Net__SSH__Perl__Key__Ed25519_bf_encrypt_iterate, file, "$$$");
729 2           (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::ed25519_generate_keypair", XS_Net__SSH__Perl__Key__Ed25519_ed25519_generate_keypair, file, "$");
730 2           (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::ed25519_sign_message", XS_Net__SSH__Perl__Key__Ed25519_ed25519_sign_message, file, "$$");
731 2           (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::ed25519_verify_message", XS_Net__SSH__Perl__Key__Ed25519_ed25519_verify_message, file, "$$$");
732             #if PERL_VERSION_LE(5, 21, 5)
733             # if PERL_VERSION_GE(5, 9, 0)
734             if (PL_unitcheckav)
735             call_list(PL_scopestack_ix, PL_unitcheckav);
736             # endif
737             XSRETURN_YES;
738             #else
739 2           Perl_xs_boot_epilog(aTHX_ ax);
740             #endif
741 2           }
742              
743             #ifdef __cplusplus
744             }
745             #endif