Perl.c

filter: Statementstmt 0.0% 0 / 157 Branchbran 0.0% 0 / 78 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 235 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/Net/SSH/Perl/Cipher/IDEA.pm ↑ Summary lib/Net/SSH/Perl/Cipher/ChachaPoly.xs »
1 /*
2 * This file was generated automatically by ExtUtils::ParseXS version 3.63 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 <inttypes.h>
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 #include "src/blowfish/blowfish.c"
196 #include "src/ed25519/keypair.c"
197 #include "src/ed25519/sign.c"
198 #include "src/ed25519/verify.c"
199 #include "src/ed25519/sha512.c"
200 #define select(a,b,c) ed25519_select (a, b, c)
201 #include "src/ed25519/ge.c"
202 #include "src/ed25519/fe.c"
203 #define load_3(x) sc_load_3(x)
204 #define load_4(x) sc_load_4(x)
205 #include "src/ed25519/sc.c"
206  
207 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_init); /* prototype to pass -Wmissing-prototypes */
208 0 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_init)
209 {
210 0 dVAR; dXSARGS;
211 0 ▶ if (items != 0)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 0) 0 0 0
212 0 croak_xs_usage(cv, "");
213 {
214 blf_ctx * RETVAL;
215 #line 20 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
216 {
217 Newxz(RETVAL, 1, blf_ctx);
218 Blowfish_initstate(RETVAL);
219 }
220 #line 221 "Perl.c"
221 {
222 SV * RETVALSV;
223 0 RETVALSV = sv_newmortal();
224 0 sv_setref_pv(RETVALSV, "blf_ctxPtr", (void*)RETVAL);
225 0 ST(0) = RETVALSV;
226 }
227 }
228 0 XSRETURN(1);
229 }
230  
231  
232 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_expandstate); /* prototype to pass -Wmissing-prototypes */
233 0 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_expandstate)
234 {
235 0 dVAR; dXSARGS;
236 0 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 0 0
237 0 croak_xs_usage(cv, "ctx, sv_data, sv_key");
238 {
239 blf_ctx * ctx;
240 0 SV * sv_data = ST(1)
241 ;
242 0 SV * sv_key = ST(2)
243 ;
244  
245 0 ▶ if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) { 0 0 0
if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) { 0 0 0
246 0 IV tmp = SvIV((SV*)SvRV(ST(0)));
247 0 ctx = INT2PTR(blf_ctx *,tmp);
248 }
249 else {
250 0 ▶ const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
Branch: 2 branches
BranchTrueFalseTotal
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
251 0 Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
252 "Net::SSH::Perl::Key::Ed25519::bf_expandstate",
253 "ctx", "blf_ctxPtr",
254 0 refstr, ST(0)
255 );
256 }
257 ;
258 #line 33 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
259 {
260 STRLEN datalen; unsigned char *data = (unsigned char *) SvPVbyte(sv_data,datalen);
261 STRLEN keylen; unsigned char *key = (unsigned char *) SvPVbyte(sv_key,keylen);
262 Blowfish_expandstate(ctx, data, datalen, key, keylen);
263 }
264 #line 265 "Perl.c"
265 }
266 0 XSRETURN_EMPTY;
267 }
268  
269  
270 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_expand0state); /* prototype to pass -Wmissing-prototypes */
271 0 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_expand0state)
272 {
273 0 dVAR; dXSARGS;
274 0 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 0 0
275 0 croak_xs_usage(cv, "ctx, sv_key");
276 {
277 blf_ctx * ctx;
278 0 SV * sv_key = ST(1)
279 ;
280  
281 0 ▶ if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) { 0 0 0
if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) { 0 0 0
282 0 IV tmp = SvIV((SV*)SvRV(ST(0)));
283 0 ctx = INT2PTR(blf_ctx *,tmp);
284 }
285 else {
286 0 ▶ const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
Branch: 2 branches
BranchTrueFalseTotal
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
287 0 Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
288 "Net::SSH::Perl::Key::Ed25519::bf_expand0state",
289 "ctx", "blf_ctxPtr",
290 0 refstr, ST(0)
291 );
292 }
293 ;
294 #line 44 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
295 {
296 STRLEN keylen;
297 unsigned char *key = (unsigned char *) SvPVbyte(sv_key,keylen);
298 Blowfish_expand0state(ctx,key,keylen);
299 }
300 #line 301 "Perl.c"
301 }
302 0 XSRETURN_EMPTY;
303 }
304  
305  
306 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_encrypt_iterate); /* prototype to pass -Wmissing-prototypes */
307 0 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_bf_encrypt_iterate)
308 {
309 0 dVAR; dXSARGS;
310 0 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 0 0
311 0 croak_xs_usage(cv, "ctx, sv_data, sv_rounds");
312 {
313 blf_ctx * ctx;
314 0 SV * sv_data = ST(1)
315 ;
316 0 SV * sv_rounds = ST(2)
317 ;
318 SV * RETVAL;
319  
320 0 ▶ if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) { 0 0 0
if (SvROK(ST(0)) && sv_derived_from(ST(0), "blf_ctxPtr")) { 0 0 0
321 0 IV tmp = SvIV((SV*)SvRV(ST(0)));
322 0 ctx = INT2PTR(blf_ctx *,tmp);
323 }
324 else {
325 0 ▶ const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
Branch: 2 branches
BranchTrueFalseTotal
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
326 0 Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
327 "Net::SSH::Perl::Key::Ed25519::bf_encrypt_iterate",
328 "ctx", "blf_ctxPtr",
329 0 refstr, ST(0)
330 );
331 }
332 ;
333 #line 56 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
334 {
335 STRLEN datalen;
336 unsigned char *data = (unsigned char *) SvPVbyte(sv_mortalcopy(sv_data),datalen);
337 if (datalen % 8)
338 croak("data must be in 8-byte chunks");
339  
340 uint16_t words = datalen / 4;
341 uint32_t cdata[words];
342 uint16_t j = 0;
343 int i;
344 int rounds = SvIVx(sv_rounds);
345  
346 for (i=0; i<words; i++)
347 cdata[i] = Blowfish_stream2word(data, datalen, &j);
348 for (i=0; i<rounds; i++)
349 blf_enc(ctx, cdata, sizeof(cdata) / sizeof(uint64_t));
350  
351 for (i=0; i<words; i++) {
352 data[4 * i + 3] = (cdata[i] >> 24) & 0xff;
353 data[4 * i + 2] = (cdata[i] >> 16) & 0xff;
354 data[4 * i + 1] = (cdata[i] >> 8) & 0xff;
355 data[4 * i ] = cdata[i] & 0xff;
356 }
357 RETVAL = newSVpvn ((char *) data, datalen);
358 }
359 #line 360 "Perl.c"
360 0 RETVAL = sv_2mortal(RETVAL);
361 0 ST(0) = RETVAL;
362 }
363 0 XSRETURN(1);
364 }
365  
366  
367 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_generate_keypair); /* prototype to pass -Wmissing-prototypes */
368 0 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_generate_keypair)
369 {
370 0 dVAR; dXSARGS;
371 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
372 0 croak_xs_usage(cv, "secret");
373 PERL_UNUSED_VAR(ax); /* -Wall */
374 0 SP -= items;
375 {
376 0 SV * secret = ST(0)
377 ;
378 #line 88 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
379 {
380 STRLEN secret_l; unsigned char *secret_p;
381  
382 unsigned char public_key[32];
383 unsigned char private_key[64];
384  
385 secret_p = (unsigned char *)SvPVbyte (secret, secret_l);
386  
387 if (secret_l != 32)
388 croak ("secret has wrong length (!= 32)");
389  
390 ed25519_create_keypair (public_key, private_key, (unsigned char *)secret_p);
391  
392 EXTEND (SP, 2);
393 PUSHs (sv_2mortal (newSVpvn ((char *)public_key, sizeof public_key)));
394 PUSHs (sv_2mortal (newSVpvn ((char *)private_key, sizeof private_key)));
395 }
396 #line 397 "Perl.c"
397 0 PUTBACK;
398 0 return;
399 }
400 }
401  
402  
403 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_sign_message); /* prototype to pass -Wmissing-prototypes */
404 0 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_sign_message)
405 {
406 0 dVAR; dXSARGS;
407 0 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 0 0
408 0 croak_xs_usage(cv, "message, private_key");
409 {
410 0 SV * message = ST(0)
411 ;
412 0 SV * private_key = ST(1)
413 ;
414 SV * RETVAL;
415 #line 111 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
416 {
417 unsigned char signature[64];
418  
419 STRLEN message_l ; char *message_p = SvPVbyte (message , message_l );
420 STRLEN private_key_l; char *private_key_p = SvPVbyte (private_key, private_key_l);
421  
422 if (private_key_l != 64)
423 croak ("private key has wrong length (!= 64)");
424  
425 ed25519_sign (signature, (unsigned char *)message_p, message_l, (unsigned char *)private_key_p);
426  
427 RETVAL = newSVpvn ((char *)signature, sizeof signature);
428 }
429 #line 430 "Perl.c"
430 0 RETVAL = sv_2mortal(RETVAL);
431 0 ST(0) = RETVAL;
432 }
433 0 XSRETURN(1);
434 }
435  
436  
437 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_verify_message); /* prototype to pass -Wmissing-prototypes */
438 0 XS_EUPXS(XS_Net__SSH__Perl__Key__Ed25519_ed25519_verify_message)
439 {
440 0 dVAR; dXSARGS;
441 0 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 0 0
442 0 croak_xs_usage(cv, "message, public_key, signature");
443 {
444 bool RETVAL;
445 0 SV * message = ST(0)
446 ;
447 0 SV * public_key = ST(1)
448 ;
449 0 SV * signature = ST(2)
450 ;
451 #line 130 "./lib/Net/SSH/Perl/Key/Ed25519.xs"
452 {
453 STRLEN signature_l ; char *signature_p = SvPVbyte (signature , signature_l );
454 STRLEN message_l ; char *message_p = SvPVbyte (message , message_l );
455 STRLEN public_key_l; char *public_key_p = SvPVbyte (public_key, public_key_l);
456  
457 if (public_key_l != 32)
458 croak ("public key has wrong length (!= 32)");
459  
460 RETVAL = ed25519_verify ((unsigned char *)signature_p, (unsigned char *)message_p, message_l, (unsigned char *)public_key_p);
461 }
462 #line 463 "Perl.c"
463 0 ▶ ST(0) = boolSV(RETVAL);
Branch: 1 branch
BranchTrueFalseTotal
ST(0) = boolSV(RETVAL); 0 0 0
464 }
465 0 XSRETURN(1);
466 }
467  
468  
469 /* INCLUDE: Returning to 'Perl.xs' from 'lib/Net/SSH/Perl/Key/Ed25519.xs' */
470  
471  
472 /* INCLUDE: Including 'lib/Net/SSH/Perl/Cipher/ChachaPoly.xs' from 'Perl.xs' */
473  
474 #include "src/chacha/chacha.c"
475 #include "src/chacha/poly1305.c"
476  
477 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_new); /* prototype to pass -Wmissing-prototypes */
478 0 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_new)
479 {
480 0 dVAR; dXSARGS;
481 0 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 0 0
482 0 croak_xs_usage(cv, "class, key");
483 {
484 0 SV * class = ST(0)
485 ;
486 0 ▶ SV * key = ST(1)
Branch: 1 branch
BranchTrueFalseTotal
SV * key = ST(1) 0 0 0
487 ;
488 Crypt__OpenSSH__ChachaPoly RETVAL;
489 #line 13 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
490 {
491 STRLEN keysize;
492 keysize = SvCUR(key);
493  
494 if (keysize != 16 && keysize != 32)
495 croak ("The key must be 128 or 256 bits long");
496  
497 Newxz(RETVAL, 1, struct chacha_ctx);
498 chacha_keysetup(RETVAL, (unsigned char *) SvPV_nolen(key), keysize*8);
499 }
500 #line 501 "Perl.c"
501 {
502 SV * RETVALSV;
503 0 RETVALSV = sv_newmortal();
504 0 sv_setref_pv(RETVALSV, "Crypt::OpenSSH::ChachaPoly", (void*)RETVAL);
505 0 ST(0) = RETVALSV;
506 }
507 }
508 0 XSRETURN(1);
509 }
510  
511  
512 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_encrypt); /* prototype to pass -Wmissing-prototypes */
513 0 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_encrypt)
514 {
515 0 dVAR; dXSARGS;
516 0 dXSI32;
517 0 ▶ if (items != 2)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 2) 0 0 0
518 0 croak_xs_usage(cv, "self, data");
519 {
520 Crypt__OpenSSH__ChachaPoly self;
521 0 SV * data = ST(1)
522 ;
523 SV * RETVAL;
524  
525 0 ▶ if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) { 0 0 0
if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) { 0 0 0
526 0 IV tmp = SvIV((SV*)SvRV(ST(0)));
527 0 self = INT2PTR(Crypt__OpenSSH__ChachaPoly,tmp);
528 }
529 else {
530 0 ▶ const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
Branch: 2 branches
BranchTrueFalseTotal
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
531 0 Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
532 0 GvNAME(CvGV(cv)),
533 "self", "Crypt::OpenSSH::ChachaPoly",
534 0 refstr, ST(0)
535 );
536 }
537 ;
538 #line 33 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
539 {
540 STRLEN size;
541 void *bytes = SvPV(data,size);
542  
543 if (size) {
544 RETVAL = NEWSV (0, size);
545 SvPOK_only (RETVAL);
546 SvCUR_set (RETVAL, size);
547 chacha_encrypt_bytes(self, bytes, (unsigned char *) SvPV_nolen(RETVAL), (int) size);
548 } else {
549 RETVAL = newSVpv ("", 0);
550 }
551  
552 }
553 #line 554 "Perl.c"
554 0 RETVAL = sv_2mortal(RETVAL);
555 0 ST(0) = RETVAL;
556 }
557 0 XSRETURN(1);
558 }
559  
560  
561 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_ivsetup); /* prototype to pass -Wmissing-prototypes */
562 0 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_ivsetup)
563 {
564 0 dVAR; dXSARGS;
565 0 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 0 0
566 0 croak_xs_usage(cv, "self, iv, counter");
567 {
568 Crypt__OpenSSH__ChachaPoly self;
569 0 SV * iv = ST(1)
570 ;
571 0 SV * counter = ST(2)
572 ;
573  
574 0 ▶ if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) { 0 0 0
if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) { 0 0 0
575 0 IV tmp = SvIV((SV*)SvRV(ST(0)));
576 0 self = INT2PTR(Crypt__OpenSSH__ChachaPoly,tmp);
577 }
578 else {
579 0 ▶ const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
Branch: 2 branches
BranchTrueFalseTotal
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
580 0 Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
581 "Crypt::OpenSSH::ChachaPoly::ivsetup",
582 "self", "Crypt::OpenSSH::ChachaPoly",
583 0 refstr, ST(0)
584 );
585 }
586 ;
587 #line 56 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
588 {
589 STRLEN iv_l ; unsigned char *iv_p = (unsigned char *) SvPVbyte (iv, iv_l);
590 /* anything beyond 64 bits is ignored */
591 if (iv_l < 8) {
592 croak("ivsetup: iv must be 64 bits long!");
593 }
594 STRLEN counter_l ; unsigned char *counter_p = (unsigned char *) SvPVbyte (counter, counter_l);
595 if (counter_l == 0)
596 counter_p = NULL;
597 /* anything beyond 8 chars is ignored */
598 else if (counter_l < 8)
599 croak ("ivsetup: counter must be 64 bits long!");
600 chacha_ivsetup(self, iv_p, counter_p);
601 }
602 #line 603 "Perl.c"
603 }
604 0 XSRETURN_EMPTY;
605 }
606  
607  
608 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_DESTROY); /* prototype to pass -Wmissing-prototypes */
609 0 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_DESTROY)
610 {
611 0 dVAR; dXSARGS;
612 0 ▶ if (items != 1)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 1) 0 0 0
613 0 croak_xs_usage(cv, "self");
614 {
615 Crypt__OpenSSH__ChachaPoly self;
616  
617 0 ▶ if (SvROK(ST(0))) {
Branch: 1 branch
BranchTrueFalseTotal
if (SvROK(ST(0))) { 0 0 0
618 0 IV tmp = SvIV((SV*)SvRV(ST(0)));
619 0 self = INT2PTR(Crypt__OpenSSH__ChachaPoly,tmp);
620 }
621 else
622 0 Perl_croak_nocontext("%s: %s is not a reference",
623 "Crypt::OpenSSH::ChachaPoly::DESTROY",
624 "self")
625 ;
626 #line 75 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
627 Safefree(self);
628 #line 629 "Perl.c"
629 }
630 0 XSRETURN_EMPTY;
631 }
632  
633  
634 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_poly1305); /* prototype to pass -Wmissing-prototypes */
635 0 XS_EUPXS(XS_Crypt__OpenSSH__ChachaPoly_poly1305)
636 {
637 0 dVAR; dXSARGS;
638 0 ▶ if (items != 3)
Branch: 1 branch
BranchTrueFalseTotal
if (items != 3) 0 0 0
639 0 croak_xs_usage(cv, "self, data, key");
640 {
641 Crypt__OpenSSH__ChachaPoly self;
642 0 SV * data = ST(1)
643 ;
644 0 SV * key = ST(2)
645 ;
646 SV * RETVAL;
647  
648 0 ▶ if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) {
Branch: 2 branches
BranchTrueFalseTotal
if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) { 0 0 0
if (SvROK(ST(0)) && sv_derived_from(ST(0), "Crypt::OpenSSH::ChachaPoly")) { 0 0 0
649 0 IV tmp = SvIV((SV*)SvRV(ST(0)));
650 0 self = INT2PTR(Crypt__OpenSSH__ChachaPoly,tmp);
651 }
652 else {
653 0 ▶ const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef";
Branch: 2 branches
BranchTrueFalseTotal
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
const char* refstr = SvROK(ST(0)) ? "" : SvOK(ST(0)) ? "scalar " : "undef"; 0 0 0
654 0 Perl_croak_nocontext("%s: Expected %s to be of type %s; got %s%" SVf " instead",
655 "Crypt::OpenSSH::ChachaPoly::poly1305",
656 "self", "Crypt::OpenSSH::ChachaPoly",
657 0 refstr, ST(0)
658 );
659 }
660 ;
661 #line 83 "./lib/Net/SSH/Perl/Cipher/ChachaPoly.xs"
662 {
663 STRLEN size;
664 void *databytes = SvPV(data,size);
665  
666 STRLEN keysize;
667 keysize = SvCUR(key);
668 if (keysize != POLY1305_KEYLEN)
669 croak("Key is incorrect size");
670 void *keybytes = SvPV_nolen(key);
671  
672 RETVAL = NEWSV(0, POLY1305_TAGLEN);
673 SvPOK_only (RETVAL);
674 SvCUR_set (RETVAL, POLY1305_TAGLEN);
675 poly1305_auth((unsigned char *) SvPV_nolen(RETVAL),databytes,(int) size,keybytes);
676 }
677 #line 678 "Perl.c"
678 0 RETVAL = sv_2mortal(RETVAL);
679 0 ST(0) = RETVAL;
680 }
681 0 XSRETURN(1);
682 }
683  
684  
685 /* INCLUDE: Returning to 'Perl.xs' from 'lib/Net/SSH/Perl/Cipher/ChachaPoly.xs' */
686  
687 #ifdef __cplusplus
688 extern "C" {
689 #endif
690 XS_EXTERNAL(boot_Crypt__OpenSSH__ChachaPoly); /* prototype to pass -Wmissing-prototypes */
691 0 XS_EXTERNAL(boot_Crypt__OpenSSH__ChachaPoly)
692 {
693 #if PERL_VERSION_LE(5, 21, 5)
694 dVAR; dXSARGS;
695 #else
696 0 dVAR; dXSBOOTARGSXSAPIVERCHK;
697 #endif
698 #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
699 char* file = __FILE__;
700 #else
701 0 const char* file = __FILE__;
702 #endif
703  
704 PERL_UNUSED_VAR(file);
705  
706 PERL_UNUSED_VAR(cv); /* -W */
707 PERL_UNUSED_VAR(items); /* -W */
708 #if PERL_VERSION_LE(5, 21, 5)
709 XS_VERSION_BOOTCHECK;
710 # ifdef XS_APIVERSION_BOOTCHECK
711 XS_APIVERSION_BOOTCHECK;
712 # endif
713 #endif
714  
715 {
716 CV * cv;
717  
718 0 (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::bf_init", XS_Net__SSH__Perl__Key__Ed25519_bf_init, file, "");
719 0 (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::bf_expandstate", XS_Net__SSH__Perl__Key__Ed25519_bf_expandstate, file, "$$$");
720 0 (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::bf_expand0state", XS_Net__SSH__Perl__Key__Ed25519_bf_expand0state, file, "$$");
721 0 (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::bf_encrypt_iterate", XS_Net__SSH__Perl__Key__Ed25519_bf_encrypt_iterate, file, "$$$");
722 0 (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::ed25519_generate_keypair", XS_Net__SSH__Perl__Key__Ed25519_ed25519_generate_keypair, file, "$");
723 0 (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::ed25519_sign_message", XS_Net__SSH__Perl__Key__Ed25519_ed25519_sign_message, file, "$$");
724 0 (void)newXSproto_portable("Net::SSH::Perl::Key::Ed25519::ed25519_verify_message", XS_Net__SSH__Perl__Key__Ed25519_ed25519_verify_message, file, "$$$");
725 0 (void)newXSproto_portable("Crypt::OpenSSH::ChachaPoly::new", XS_Crypt__OpenSSH__ChachaPoly_new, file, "$$");
726 0 cv = newXSproto_portable("Crypt::OpenSSH::ChachaPoly::decrypt", XS_Crypt__OpenSSH__ChachaPoly_encrypt, file, "$$");
727 0 XSANY.any_i32 = 1;
728 0 cv = newXSproto_portable("Crypt::OpenSSH::ChachaPoly::encrypt", XS_Crypt__OpenSSH__ChachaPoly_encrypt, file, "$$");
729 0 XSANY.any_i32 = 0;
730 0 (void)newXSproto_portable("Crypt::OpenSSH::ChachaPoly::ivsetup", XS_Crypt__OpenSSH__ChachaPoly_ivsetup, file, "$$$");
731 0 (void)newXSproto_portable("Crypt::OpenSSH::ChachaPoly::DESTROY", XS_Crypt__OpenSSH__ChachaPoly_DESTROY, file, "$");
732 0 (void)newXSproto_portable("Crypt::OpenSSH::ChachaPoly::poly1305", XS_Crypt__OpenSSH__ChachaPoly_poly1305, file, "$$$");
733 }
734 #if PERL_VERSION_LE(5, 21, 5)
735 # if PERL_VERSION_GE(5, 9, 0)
736 if (PL_unitcheckav)
737 call_list(PL_scopestack_ix, PL_unitcheckav);
738 # endif
739 XSRETURN_YES;
740 #else
741 0 Perl_xs_boot_epilog(aTHX_ ax);
742 #endif
743 0 }
744  
745 #ifdef __cplusplus
746 }
747 #endif
« blib/lib/Net/SSH/Perl/Cipher/IDEA.pm ↑ Summary lib/Net/SSH/Perl/Cipher/ChachaPoly.xs »