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