| 1 |
|
| /* |
| 2 |
|
| * This file was generated automatically by ExtUtils::ParseXS version 3.63 from the |
| 3 |
|
| * contents of PSAML.xs. Do not edit this file, edit PSAML.xs instead. |
| 4 |
|
| * |
| 5 |
|
| * ANY CHANGES MADE HERE WILL BE LOST! |
| 6 |
|
| * |
| 7 |
|
| */ |
| 8 |
|
| |
| 9 |
|
| #line 1 "PSAML.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 |
|
| /* Punk::SAML is one shared object. Every module under lib/Punk/SAML and |
| 17 |
|
| * lib/Punk/Plugin/SAML.pm does `use Punk::SAML ()` and nothing else, so |
| 18 |
|
| * the bundle is bootstrapped once by whichever is loaded first, and each |
| 19 |
|
| * package is declared below with its own MODULE = / PACKAGE = line. |
| 20 |
|
| * |
| 21 |
|
| * The rules this distribution is built under, recorded here where every |
| 22 |
|
| * later phase sees them: |
| 23 |
|
| * |
| 24 |
|
| * 1. The include order below is a dependency order, not an alphabet. |
| 25 |
|
| * psaml_compat.h is first because every other header uses its |
| 26 |
|
| * shims; psaml_abi.h is second because the primitives above the |
| 27 |
|
| * resolvers are the only code that may run before they resolve. |
| 28 |
|
| * |
| 29 |
|
| * 2. Nothing in this dist matches an XML element by prefix. SAML |
| 30 |
|
| * documents choose their own prefixes and every finder goes |
| 31 |
|
| * through a namespace URI and a local name. |
| 32 |
|
| * |
| 33 |
|
| * 3. No structs on the application. Plugin state is keys on the |
| 34 |
|
| * application HV (psaml_reg.h). The only aggregates are the |
| 35 |
|
| * closure capture and the per-document frx_doc *. |
| 36 |
|
| * |
| 37 |
|
| * 4. Every frx_doc this dist parses is freed on every exit path |
| 38 |
|
| * including the croak path, through SAVEDESTRUCTOR_X. A leaked |
| 39 |
|
| * document per failed login is the slow leak nobody finds. |
| 40 |
|
| * |
| 41 |
|
| * THE ONE EXCEPTION, and it is a double free rather than a leak if |
| 42 |
|
| * it is got wrong: frx_abi's doc_to_sv TAKES OWNERSHIP. It is the |
| 43 |
|
| * only entry in that table that does. A document handed to Perl |
| 44 |
|
| * through it belongs to the SV's magic from that moment, so the |
| 45 |
|
| * SAVEDESTRUCTOR_X must be cancelled or never installed on that |
| 46 |
|
| * path. Parse, verify, and only then hand it over. |
| 47 |
|
| * |
| 48 |
|
| * 5. Every refusal throws a blessed Punk::SAML::Error with a code. |
| 49 |
|
| * The code is the interface; the message is for the log and never |
| 50 |
|
| * reaches the browser. |
| 51 |
|
| * |
| 52 |
|
| * 6. The ABI resolvers compare >= against the version whose members |
| 53 |
|
| * this dist calls, never == and never against the installed |
| 54 |
|
| * header's constant. See psaml_abi.h. |
| 55 |
|
| * |
| 56 |
|
| * 7. Adding a header means re-running Makefile.PL: the depend glob |
| 57 |
|
| * that makes a header edit rebuild the object is evaluated at |
| 58 |
|
| * configure time. |
| 59 |
|
| */ |
| 60 |
|
| |
| 61 |
|
| #include "psaml/psaml_compat.h" /* what the 5.10 floor costs; first */ |
| 62 |
|
| #include "psaml/psaml_abi.h" /* the three resolvers: frx, jws, fetch */ |
| 63 |
|
| #include "psaml/psaml_error.h" /* the codes; throwing a blessed error */ |
| 64 |
|
| #include "psaml/psaml_b64.h" /* standard base64, strict decode */ |
| 65 |
|
| #include "psaml/psaml_deflate.h" /* raw DEFLATE, stored blocks */ |
| 66 |
|
| #include "psaml/psaml_time.h" /* xs:dateTime both ways */ |
| 67 |
|
| #include "psaml/psaml_xml.h" /* the escape; the finders over frx */ |
| 68 |
|
| #include "psaml/psaml_clos.h" /* the closure device; predicates */ |
| 69 |
|
| #include "psaml/psaml_reg.h" /* the registrar surface, through Perl */ |
| 70 |
|
| #include "psaml/psaml_request.h" /* the AuthnRequest and the redirect */ |
| 71 |
|
| #include "psaml/psaml_signature.h"/* XML-DSig, verified */ |
| 72 |
|
| #include "psaml/psaml_response.h" /* the checks in order; the parse guard */ |
| 73 |
|
| #include "psaml/psaml_idp.h" /* a provider, read from metadata bytes */ |
| 74 |
|
| #include "psaml/psaml_metadata.h" /* the fetch, and SP metadata out */ |
| 75 |
|
| #include "psaml/psaml_flow.h" /* the flow cookie, SameSite=None */ |
| 76 |
|
| #include "psaml/psaml_boot.h" /* register, the keywords, the routes: |
| 77 |
|
| * last, because it reads metadata, |
| 78 |
|
| * mounts routes and writes the cookie */ |
| 79 |
|
| |
| 80 |
|
| #line 81 "PSAML.c" |
| 81 |
|
| #ifndef PERL_UNUSED_VAR |
| 82 |
|
| # define PERL_UNUSED_VAR(var) if (0) var = var |
| 83 |
|
| #endif |
| 84 |
|
| |
| 85 |
|
| #ifndef dVAR |
| 86 |
|
| # define dVAR dNOOP |
| 87 |
|
| #endif |
| 88 |
|
| |
| 89 |
|
| |
| 90 |
|
| /* This stuff is not part of the API! You have been warned. */ |
| 91 |
|
| #ifndef PERL_VERSION_DECIMAL |
| 92 |
|
| # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s) |
| 93 |
|
| #endif |
| 94 |
|
| #ifndef PERL_DECIMAL_VERSION |
| 95 |
|
| # define PERL_DECIMAL_VERSION \ |
| 96 |
|
| PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION) |
| 97 |
|
| #endif |
| 98 |
|
| #ifndef PERL_VERSION_GE |
| 99 |
|
| # define PERL_VERSION_GE(r,v,s) \ |
| 100 |
|
| (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s)) |
| 101 |
|
| #endif |
| 102 |
|
| #ifndef PERL_VERSION_LE |
| 103 |
|
| # define PERL_VERSION_LE(r,v,s) \ |
| 104 |
|
| (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s)) |
| 105 |
|
| #endif |
| 106 |
|
| |
| 107 |
|
| /* XS_INTERNAL is the explicit static-linkage variant of the default |
| 108 |
|
| * XS macro. |
| 109 |
|
| * |
| 110 |
|
| * XS_EXTERNAL is the same as XS_INTERNAL except it does not include |
| 111 |
|
| * "static", ie. it exports XSUB symbols. You probably don't want that |
| 112 |
|
| * for anything but the BOOT XSUB. |
| 113 |
|
| * |
| 114 |
|
| * See XSUB.h in core! |
| 115 |
|
| */ |
| 116 |
|
| |
| 117 |
|
| |
| 118 |
|
| /* TODO: This might be compatible further back than 5.10.0. */ |
| 119 |
|
| #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1) |
| 120 |
|
| # undef XS_EXTERNAL |
| 121 |
|
| # undef XS_INTERNAL |
| 122 |
|
| # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING) |
| 123 |
|
| # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name) |
| 124 |
|
| # define XS_INTERNAL(name) static XSPROTO(name) |
| 125 |
|
| # endif |
| 126 |
|
| # if defined(__SYMBIAN32__) |
| 127 |
|
| # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name) |
| 128 |
|
| # define XS_INTERNAL(name) EXPORT_C static XSPROTO(name) |
| 129 |
|
| # endif |
| 130 |
|
| # ifndef XS_EXTERNAL |
| 131 |
|
| # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus) |
| 132 |
|
| # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__) |
| 133 |
|
| # define XS_INTERNAL(name) static void name(pTHX_ CV* cv __attribute__unused__) |
| 134 |
|
| # else |
| 135 |
|
| # ifdef __cplusplus |
| 136 |
|
| # define XS_EXTERNAL(name) extern "C" XSPROTO(name) |
| 137 |
|
| # define XS_INTERNAL(name) static XSPROTO(name) |
| 138 |
|
| # else |
| 139 |
|
| # define XS_EXTERNAL(name) XSPROTO(name) |
| 140 |
|
| # define XS_INTERNAL(name) static XSPROTO(name) |
| 141 |
|
| # endif |
| 142 |
|
| # endif |
| 143 |
|
| # endif |
| 144 |
|
| #endif |
| 145 |
|
| |
| 146 |
|
| /* perl >= 5.10.0 && perl <= 5.15.1 */ |
| 147 |
|
| |
| 148 |
|
| |
| 149 |
|
| /* The XS_EXTERNAL macro is used for functions that must not be static |
| 150 |
|
| * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL |
| 151 |
|
| * macro defined, the best we can do is assume XS is the same. |
| 152 |
|
| * Dito for XS_INTERNAL. |
| 153 |
|
| */ |
| 154 |
|
| #ifndef XS_EXTERNAL |
| 155 |
|
| # define XS_EXTERNAL(name) XS(name) |
| 156 |
|
| #endif |
| 157 |
|
| #ifndef XS_INTERNAL |
| 158 |
|
| # define XS_INTERNAL(name) XS(name) |
| 159 |
|
| #endif |
| 160 |
|
| |
| 161 |
|
| /* Now, finally, after all this mess, we want an ExtUtils::ParseXS |
| 162 |
|
| * internal macro that we're free to redefine for varying linkage due |
| 163 |
|
| * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use |
| 164 |
|
| * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to! |
| 165 |
|
| */ |
| 166 |
|
| |
| 167 |
|
| #undef XS_EUPXS |
| 168 |
|
| #if defined(PERL_EUPXS_ALWAYS_EXPORT) |
| 169 |
|
| # define XS_EUPXS(name) XS_EXTERNAL(name) |
| 170 |
|
| #else |
| 171 |
|
| /* default to internal */ |
| 172 |
|
| # define XS_EUPXS(name) XS_INTERNAL(name) |
| 173 |
|
| #endif |
| 174 |
|
| |
| 175 |
|
| #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE |
| 176 |
|
| #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params) |
| 177 |
|
| |
| 178 |
|
| /* prototype to pass -Wmissing-prototypes */ |
| 179 |
|
| static void |
| 180 |
|
| S_croak_xs_usage(const CV *const cv, const char *const params); |
| 181 |
|
| |
| 182 |
|
| static void |
| 183 |
|
| S_croak_xs_usage(const CV *const cv, const char *const params) |
| 184 |
|
| { |
| 185 |
|
| const GV *const gv = CvGV(cv); |
| 186 |
|
| |
| 187 |
|
| PERL_ARGS_ASSERT_CROAK_XS_USAGE; |
| 188 |
|
| |
| 189 |
|
| if (gv) { |
| 190 |
|
| const char *const gvname = GvNAME(gv); |
| 191 |
|
| const HV *const stash = GvSTASH(gv); |
| 192 |
|
| const char *const hvname = stash ? HvNAME(stash) : NULL; |
| 193 |
|
| |
| 194 |
|
| if (hvname) |
| 195 |
|
| Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params); |
| 196 |
|
| else |
| 197 |
|
| Perl_croak_nocontext("Usage: %s(%s)", gvname, params); |
| 198 |
|
| } else { |
| 199 |
|
| /* Pants. I don't think that it should be possible to get here. */ |
| 200 |
|
| Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params); |
| 201 |
|
| } |
| 202 |
|
| } |
| 203 |
|
| #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE |
| 204 |
|
| |
| 205 |
|
| #define croak_xs_usage S_croak_xs_usage |
| 206 |
|
| |
| 207 |
|
| #endif |
| 208 |
|
| |
| 209 |
|
| /* NOTE: the prototype of newXSproto() is different in versions of perls, |
| 210 |
|
| * so we define a portable version of newXSproto() |
| 211 |
|
| */ |
| 212 |
|
| #ifdef newXS_flags |
| 213 |
|
| #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0) |
| 214 |
|
| #else |
| 215 |
|
| #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv) |
| 216 |
|
| #endif /* !defined(newXS_flags) */ |
| 217 |
|
| |
| 218 |
|
| #if PERL_VERSION_LE(5, 21, 5) |
| 219 |
|
| # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file) |
| 220 |
|
| #else |
| 221 |
|
| # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b) |
| 222 |
|
| #endif |
| 223 |
|
| |
| 224 |
|
| /* simple backcompat versions of the TARGx() macros with no optimisation */ |
| 225 |
|
| #ifndef TARGi |
| 226 |
|
| # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv) |
| 227 |
|
| # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv) |
| 228 |
|
| # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv) |
| 229 |
|
| #endif |
| 230 |
|
| |
| 231 |
|
| #line 232 "PSAML.c" |
| 232 |
|
| |
| 233 |
|
| /* INCLUDE: Including 'xs/util.xs' from 'PSAML.xs' */ |
| 234 |
|
| |
| 235 |
|
| |
| 236 |
|
| XS_EUPXS(XS_Punk__SAML__b64_encode); /* prototype to pass -Wmissing-prototypes */ |
| 237 |
16 |
| XS_EUPXS(XS_Punk__SAML__b64_encode) |
| 238 |
|
| { |
| 239 |
16 |
| dVAR; dXSARGS; |
| 240 |
16 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
16 |
16 |
|
| 241 |
0 |
| croak_xs_usage(cv, "bytes"); |
| 242 |
|
| { |
| 243 |
16 |
| SV * bytes = ST(0) |
| 244 |
|
| ; |
| 245 |
|
| SV * RETVAL; |
| 246 |
|
| #line 15 "./xs/util.xs" |
| 247 |
|
| STRLEN n, out; |
| 248 |
|
| const char *p = SvPVbyte(bytes, n); |
| 249 |
|
| RETVAL = newSV(psaml_b64_encoded_len(n) + 1); |
| 250 |
|
| SvPOK_on(RETVAL); |
| 251 |
|
| out = psaml_b64_encode(SvPVX(RETVAL), (const unsigned char *)p, n); |
| 252 |
|
| SvCUR_set(RETVAL, out); |
| 253 |
|
| *SvEND(RETVAL) = '\0'; |
| 254 |
|
| #line 255 "PSAML.c" |
| 255 |
16 |
| RETVAL = sv_2mortal(RETVAL); |
| 256 |
16 |
| ST(0) = RETVAL; |
| 257 |
|
| } |
| 258 |
16 |
| XSRETURN(1); |
| 259 |
|
| } |
| 260 |
|
| |
| 261 |
|
| |
| 262 |
|
| XS_EUPXS(XS_Punk__SAML__b64_decode); /* prototype to pass -Wmissing-prototypes */ |
| 263 |
21 |
| XS_EUPXS(XS_Punk__SAML__b64_decode) |
| 264 |
|
| { |
| 265 |
21 |
| dVAR; dXSARGS; |
| 266 |
21 |
▶ | if (items < 1 || items > 2) |
Branch: 2 branches
| Branch | True | False | Total |
| if (items < 1 || items > 2) |
21 |
0 |
21 |
| if (items < 1 || items > 2) |
0 |
21 |
21 |
|
| 267 |
0 |
| croak_xs_usage(cv, "str, allow_ws = 0"); |
| 268 |
|
| { |
| 269 |
21 |
| SV * str = ST(0) |
| 270 |
|
| ; |
| 271 |
|
| int allow_ws; |
| 272 |
|
| SV * RETVAL; |
| 273 |
|
| |
| 274 |
21 |
▶ | if (items < 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 2) |
18 |
3 |
21 |
|
| 275 |
18 |
| allow_ws = 0; |
| 276 |
|
| else { |
| 277 |
3 |
| allow_ws = (int)SvIV(ST(1)) |
| 278 |
|
| ; |
| 279 |
|
| } |
| 280 |
|
| #line 30 "./xs/util.xs" |
| 281 |
|
| STRLEN n, out; |
| 282 |
|
| const char *p = SvPVbyte(str, n); |
| 283 |
|
| RETVAL = newSV(psaml_b64_decoded_max(n) + 1); |
| 284 |
|
| SvPOK_on(RETVAL); |
| 285 |
|
| out = psaml_b64_decode_ws((unsigned char *)SvPVX(RETVAL), p, n, |
| 286 |
|
| allow_ws); |
| 287 |
|
| if (out == (STRLEN)-1) { |
| 288 |
|
| SvREFCNT_dec(RETVAL); |
| 289 |
|
| XSRETURN_UNDEF; |
| 290 |
|
| } |
| 291 |
|
| SvCUR_set(RETVAL, out); |
| 292 |
|
| *SvEND(RETVAL) = '\0'; |
| 293 |
|
| #line 294 "PSAML.c" |
| 294 |
9 |
| RETVAL = sv_2mortal(RETVAL); |
| 295 |
9 |
| ST(0) = RETVAL; |
| 296 |
|
| } |
| 297 |
9 |
| XSRETURN(1); |
| 298 |
|
| } |
| 299 |
|
| |
| 300 |
|
| |
| 301 |
|
| XS_EUPXS(XS_Punk__SAML__deflate); /* prototype to pass -Wmissing-prototypes */ |
| 302 |
4 |
| XS_EUPXS(XS_Punk__SAML__deflate) |
| 303 |
|
| { |
| 304 |
4 |
| dVAR; dXSARGS; |
| 305 |
4 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
4 |
4 |
|
| 306 |
0 |
| croak_xs_usage(cv, "bytes"); |
| 307 |
|
| { |
| 308 |
4 |
| SV * bytes = ST(0) |
| 309 |
|
| ; |
| 310 |
|
| SV * RETVAL; |
| 311 |
|
| #line 49 "./xs/util.xs" |
| 312 |
|
| STRLEN n, out; |
| 313 |
|
| const char *p = SvPVbyte(bytes, n); |
| 314 |
|
| RETVAL = newSV(psaml_deflate_bound(n) + 1); |
| 315 |
|
| SvPOK_on(RETVAL); |
| 316 |
|
| out = psaml_deflate_stored((unsigned char *)SvPVX(RETVAL), |
| 317 |
|
| (const unsigned char *)p, n); |
| 318 |
|
| SvCUR_set(RETVAL, out); |
| 319 |
|
| *SvEND(RETVAL) = '\0'; |
| 320 |
|
| #line 321 "PSAML.c" |
| 321 |
4 |
| RETVAL = sv_2mortal(RETVAL); |
| 322 |
4 |
| ST(0) = RETVAL; |
| 323 |
|
| } |
| 324 |
4 |
| XSRETURN(1); |
| 325 |
|
| } |
| 326 |
|
| |
| 327 |
|
| |
| 328 |
|
| XS_EUPXS(XS_Punk__SAML__xml_escape); /* prototype to pass -Wmissing-prototypes */ |
| 329 |
3 |
| XS_EUPXS(XS_Punk__SAML__xml_escape) |
| 330 |
|
| { |
| 331 |
3 |
| dVAR; dXSARGS; |
| 332 |
3 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
3 |
3 |
|
| 333 |
0 |
| croak_xs_usage(cv, "str"); |
| 334 |
|
| { |
| 335 |
3 |
| SV * str = ST(0) |
| 336 |
|
| ; |
| 337 |
|
| SV * RETVAL; |
| 338 |
|
| #line 64 "./xs/util.xs" |
| 339 |
|
| STRLEN n, out; |
| 340 |
|
| const char *p = SvPVbyte(str, n); |
| 341 |
|
| RETVAL = newSV(psaml_xml_escaped_max(n) + 1); |
| 342 |
|
| SvPOK_on(RETVAL); |
| 343 |
|
| out = psaml_xml_escape(SvPVX(RETVAL), p, n); |
| 344 |
|
| SvCUR_set(RETVAL, out); |
| 345 |
|
| *SvEND(RETVAL) = '\0'; |
| 346 |
|
| #line 347 "PSAML.c" |
| 347 |
3 |
| RETVAL = sv_2mortal(RETVAL); |
| 348 |
3 |
| ST(0) = RETVAL; |
| 349 |
|
| } |
| 350 |
3 |
| XSRETURN(1); |
| 351 |
|
| } |
| 352 |
|
| |
| 353 |
|
| |
| 354 |
|
| XS_EUPXS(XS_Punk__SAML__time_parse); /* prototype to pass -Wmissing-prototypes */ |
| 355 |
25 |
| XS_EUPXS(XS_Punk__SAML__time_parse) |
| 356 |
|
| { |
| 357 |
25 |
| dVAR; dXSARGS; |
| 358 |
25 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
25 |
25 |
|
| 359 |
0 |
| croak_xs_usage(cv, "str"); |
| 360 |
|
| { |
| 361 |
25 |
| SV * str = ST(0) |
| 362 |
|
| ; |
| 363 |
|
| SV * RETVAL; |
| 364 |
|
| #line 82 "./xs/util.xs" |
| 365 |
|
| STRLEN n; |
| 366 |
|
| const char *p = SvPVbyte(str, n); |
| 367 |
|
| IV t; |
| 368 |
|
| if (!psaml_time_parse(p, n, &t)) |
| 369 |
|
| XSRETURN_UNDEF; |
| 370 |
|
| RETVAL = newSViv(t); |
| 371 |
|
| #line 372 "PSAML.c" |
| 372 |
10 |
| RETVAL = sv_2mortal(RETVAL); |
| 373 |
10 |
| ST(0) = RETVAL; |
| 374 |
|
| } |
| 375 |
10 |
| XSRETURN(1); |
| 376 |
|
| } |
| 377 |
|
| |
| 378 |
|
| |
| 379 |
|
| XS_EUPXS(XS_Punk__SAML__time_format); /* prototype to pass -Wmissing-prototypes */ |
| 380 |
1 |
| XS_EUPXS(XS_Punk__SAML__time_format) |
| 381 |
|
| { |
| 382 |
1 |
| dVAR; dXSARGS; |
| 383 |
1 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
1 |
1 |
|
| 384 |
0 |
| croak_xs_usage(cv, "epoch"); |
| 385 |
|
| { |
| 386 |
1 |
| IV epoch = (IV)SvIV(ST(0)) |
| 387 |
|
| ; |
| 388 |
|
| SV * RETVAL; |
| 389 |
|
| #line 95 "./xs/util.xs" |
| 390 |
|
| char buf[64]; |
| 391 |
|
| STRLEN n = psaml_time_format(buf, sizeof buf, epoch); |
| 392 |
|
| RETVAL = newSVpvn(buf, n); |
| 393 |
|
| #line 394 "PSAML.c" |
| 394 |
1 |
| RETVAL = sv_2mortal(RETVAL); |
| 395 |
1 |
| ST(0) = RETVAL; |
| 396 |
|
| } |
| 397 |
1 |
| XSRETURN(1); |
| 398 |
|
| } |
| 399 |
|
| |
| 400 |
|
| |
| 401 |
|
| XS_EUPXS(XS_Punk__SAML__throw); /* prototype to pass -Wmissing-prototypes */ |
| 402 |
1 |
| XS_EUPXS(XS_Punk__SAML__throw) |
| 403 |
|
| { |
| 404 |
1 |
| dVAR; dXSARGS; |
| 405 |
1 |
▶ | if (items < 1 || items > 2) |
Branch: 2 branches
| Branch | True | False | Total |
| if (items < 1 || items > 2) |
1 |
0 |
1 |
| if (items < 1 || items > 2) |
0 |
1 |
1 |
|
| 406 |
0 |
| croak_xs_usage(cv, "code, message = NULL"); |
| 407 |
|
| { |
| 408 |
1 |
| const char * code = (const char *)SvPV_nolen(ST(0)) |
| 409 |
|
| ; |
| 410 |
|
| SV * message; |
| 411 |
|
| |
| 412 |
1 |
▶ | if (items < 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 2) |
1 |
0 |
1 |
|
| 413 |
1 |
| message = NULL; |
| 414 |
|
| else { |
| 415 |
0 |
| message = ST(1) |
| 416 |
|
| ; |
| 417 |
|
| } |
| 418 |
|
| #line 110 "./xs/util.xs" |
| 419 |
|
| PERL_UNUSED_VAR(message); |
| 420 |
|
| psaml_throw(aTHX_ code, NULL); |
| 421 |
|
| #line 422 "PSAML.c" |
| 422 |
|
| } |
| 423 |
0 |
| XSRETURN_EMPTY; |
| 424 |
|
| } |
| 425 |
|
| |
| 426 |
|
| |
| 427 |
|
| XS_EUPXS(XS_Punk__SAML__croak_sv_selftest); /* prototype to pass -Wmissing-prototypes */ |
| 428 |
2 |
| XS_EUPXS(XS_Punk__SAML__croak_sv_selftest) |
| 429 |
|
| { |
| 430 |
2 |
| dVAR; dXSARGS; |
| 431 |
2 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
2 |
2 |
|
| 432 |
0 |
| croak_xs_usage(cv, "sv"); |
| 433 |
|
| { |
| 434 |
2 |
| SV * sv = ST(0) |
| 435 |
|
| ; |
| 436 |
|
| #line 123 "./xs/util.xs" |
| 437 |
|
| psaml_croak_sv(aTHX_ sv); |
| 438 |
|
| #line 439 "PSAML.c" |
| 439 |
|
| } |
| 440 |
0 |
| XSRETURN_EMPTY; |
| 441 |
|
| } |
| 442 |
|
| |
| 443 |
|
| |
| 444 |
|
| XS_EUPXS(XS_Punk__SAML__abi_versions); /* prototype to pass -Wmissing-prototypes */ |
| 445 |
2 |
| XS_EUPXS(XS_Punk__SAML__abi_versions) |
| 446 |
|
| { |
| 447 |
2 |
| dVAR; dXSARGS; |
| 448 |
2 |
▶ | if (items != 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 0) |
0 |
2 |
2 |
|
| 449 |
0 |
| croak_xs_usage(cv, ""); |
| 450 |
|
| PERL_UNUSED_VAR(ax); /* -Wall */ |
| 451 |
2 |
| SP -= items; |
| 452 |
|
| { |
| 453 |
|
| #line 131 "./xs/util.xs" |
| 454 |
|
| int v_frx, v_jws, v_fetch; |
| 455 |
|
| v_frx = psaml_frx(aTHX)->abi_version; |
| 456 |
|
| v_jws = psaml_jws(aTHX)->version; |
| 457 |
|
| v_fetch = psaml_fetch(aTHX)->abi_version; |
| 458 |
|
| SPAGAIN; |
| 459 |
|
| EXTEND(SP, 3); |
| 460 |
|
| mPUSHi(v_frx); |
| 461 |
|
| mPUSHi(v_jws); |
| 462 |
|
| mPUSHi(v_fetch); |
| 463 |
|
| #line 464 "PSAML.c" |
| 464 |
2 |
| PUTBACK; |
| 465 |
2 |
| return; |
| 466 |
|
| } |
| 467 |
|
| } |
| 468 |
|
| |
| 469 |
|
| |
| 470 |
|
| XS_EUPXS(XS_Punk__SAML__abi_needs); /* prototype to pass -Wmissing-prototypes */ |
| 471 |
1 |
| XS_EUPXS(XS_Punk__SAML__abi_needs) |
| 472 |
|
| { |
| 473 |
1 |
| dVAR; dXSARGS; |
| 474 |
1 |
▶ | if (items != 0) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 0) |
0 |
1 |
1 |
|
| 475 |
0 |
| croak_xs_usage(cv, ""); |
| 476 |
|
| PERL_UNUSED_VAR(ax); /* -Wall */ |
| 477 |
1 |
▶ | SP -= items; |
Branch: 1 branch
| Branch | True | False | Total |
| SP -= items; |
0 |
1 |
1 |
|
| 478 |
|
| { |
| 479 |
|
| #line 149 "./xs/util.xs" |
| 480 |
|
| EXTEND(SP, 3); |
| 481 |
|
| mPUSHi(PSAML_FRX_NEED); |
| 482 |
|
| mPUSHi(PSAML_JWS_NEED); |
| 483 |
|
| mPUSHi(PSAML_FETCH_NEED); |
| 484 |
|
| #line 485 "PSAML.c" |
| 485 |
1 |
| PUTBACK; |
| 486 |
1 |
| return; |
| 487 |
|
| } |
| 488 |
|
| } |
| 489 |
|
| |
| 490 |
|
| |
| 491 |
|
| /* INCLUDE: Returning to 'PSAML.xs' from 'xs/util.xs' */ |
| 492 |
|
| |
| 493 |
|
| |
| 494 |
|
| /* INCLUDE: Including 'xs/plugin.xs' from 'PSAML.xs' */ |
| 495 |
|
| |
| 496 |
|
| |
| 497 |
|
| XS_EUPXS(XS_Punk__Plugin__SAML_import); /* prototype to pass -Wmissing-prototypes */ |
| 498 |
50 |
| XS_EUPXS(XS_Punk__Plugin__SAML_import) |
| 499 |
|
| { |
| 500 |
50 |
| dVAR; dXSARGS; |
| 501 |
50 |
▶ | if (items < 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 1) |
0 |
50 |
50 |
|
| 502 |
0 |
| croak_xs_usage(cv, "class, ..."); |
| 503 |
|
| { |
| 504 |
50 |
▶ | SV * class = ST(0) |
Branch: 1 branch
| Branch | True | False | Total |
| SV * class = ST(0) |
50 |
0 |
50 |
|
| 505 |
|
| ; |
| 506 |
|
| #line 25 "./xs/plugin.xs" |
| 507 |
|
| const char *pkg = CopSTASHPV(PL_curcop); |
| 508 |
|
| SV *pkgsv, *appsv; |
| 509 |
|
| PERL_UNUSED_VAR(class); |
| 510 |
|
| PERL_UNUSED_VAR(items); |
| 511 |
|
| if (!pkg) XSRETURN_EMPTY; |
| 512 |
|
| pkgsv = sv_2mortal(newSVpv(pkg, 0)); |
| 513 |
|
| if (!psaml_can(aTHX_ pkgsv, "punk_app")) XSRETURN_EMPTY; |
| 514 |
|
| appsv = sv_2mortal(psaml_call(aTHX_ pkgsv, "punk_app", NULL, 0)); |
| 515 |
|
| if (appsv && SvROK(appsv)) psaml_install_kw(aTHX_ appsv); |
| 516 |
|
| XSRETURN_EMPTY; |
| 517 |
|
| #line 518 "PSAML.c" |
| 518 |
|
| } |
| 519 |
|
| XSRETURN_EMPTY; |
| 520 |
|
| } |
| 521 |
|
| |
| 522 |
|
| |
| 523 |
|
| XS_EUPXS(XS_Punk__Plugin__SAML_new); /* prototype to pass -Wmissing-prototypes */ |
| 524 |
49 |
| XS_EUPXS(XS_Punk__Plugin__SAML_new) |
| 525 |
|
| { |
| 526 |
49 |
| dVAR; dXSARGS; |
| 527 |
49 |
▶ | if (items < 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 1) |
0 |
49 |
49 |
|
| 528 |
0 |
| croak_xs_usage(cv, "class, ..."); |
| 529 |
|
| { |
| 530 |
49 |
| SV * class = ST(0) |
| 531 |
|
| ; |
| 532 |
|
| SV * RETVAL; |
| 533 |
|
| #line 40 "./xs/plugin.xs" |
| 534 |
|
| HV *self = newHV(); |
| 535 |
|
| PERL_UNUSED_VAR(items); |
| 536 |
|
| RETVAL = sv_bless(newRV_noinc((SV *)self), |
| 537 |
|
| gv_stashsv(class, GV_ADD)); |
| 538 |
|
| #line 539 "PSAML.c" |
| 539 |
49 |
| RETVAL = sv_2mortal(RETVAL); |
| 540 |
49 |
| ST(0) = RETVAL; |
| 541 |
|
| } |
| 542 |
49 |
| XSRETURN(1); |
| 543 |
|
| } |
| 544 |
|
| |
| 545 |
|
| |
| 546 |
|
| XS_EUPXS(XS_Punk__Plugin__SAML_register); /* prototype to pass -Wmissing-prototypes */ |
| 547 |
49 |
| XS_EUPXS(XS_Punk__Plugin__SAML_register) |
| 548 |
|
| { |
| 549 |
49 |
| dVAR; dXSARGS; |
| 550 |
49 |
▶ | if (items < 2 || items > 3) |
Branch: 2 branches
| Branch | True | False | Total |
| if (items < 2 || items > 3) |
49 |
0 |
49 |
| if (items < 2 || items > 3) |
0 |
49 |
49 |
|
| 551 |
0 |
| croak_xs_usage(cv, "self, app, opts = &PL_sv_undef"); |
| 552 |
|
| { |
| 553 |
49 |
| SV * self = ST(0) |
| 554 |
|
| ; |
| 555 |
49 |
| SV * app = ST(1) |
| 556 |
|
| ; |
| 557 |
|
| SV * opts; |
| 558 |
|
| |
| 559 |
49 |
▶ | if (items < 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 3) |
0 |
49 |
49 |
|
| 560 |
0 |
| opts = &PL_sv_undef; |
| 561 |
|
| else { |
| 562 |
49 |
| opts = ST(2) |
| 563 |
|
| ; |
| 564 |
|
| } |
| 565 |
|
| #line 55 "./xs/plugin.xs" |
| 566 |
|
| HV *validated; |
| 567 |
|
| PERL_UNUSED_VAR(self); |
| 568 |
|
| if (!app || !SvROK(app)) |
| 569 |
|
| croak("%s: register needs the Punk::App", PSAML_WHO); |
| 570 |
|
| validated = psaml_opts(aTHX_ app, opts); |
| 571 |
|
| psaml_app_set(aTHX_ app, PSAML_K_OPTS, |
| 572 |
|
| newRV_noinc((SV *)validated)); |
| 573 |
|
| /* Again, for `plugin 'SAML'` with no `use`: the parenthesised form |
| 574 |
|
| * of a keyword resolves at runtime, and this is what it finds. */ |
| 575 |
|
| psaml_install_kw(aTHX_ app); |
| 576 |
|
| psaml_install_rest(aTHX_ app); |
| 577 |
|
| #line 578 "PSAML.c" |
| 578 |
|
| } |
| 579 |
40 |
| XSRETURN_EMPTY; |
| 580 |
|
| } |
| 581 |
|
| |
| 582 |
|
| |
| 583 |
|
| XS_EUPXS(XS_Punk__Plugin__SAML__refetch_idp); /* prototype to pass -Wmissing-prototypes */ |
| 584 |
6 |
| XS_EUPXS(XS_Punk__Plugin__SAML__refetch_idp) |
| 585 |
|
| { |
| 586 |
6 |
| dVAR; dXSARGS; |
| 587 |
6 |
▶ | if (items != 4) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 4) |
0 |
6 |
6 |
|
| 588 |
0 |
| croak_xs_usage(cv, "class, app, name, now"); |
| 589 |
|
| { |
| 590 |
6 |
| SV * class = ST(0) |
| 591 |
|
| ; |
| 592 |
6 |
| SV * app = ST(1) |
| 593 |
|
| ; |
| 594 |
6 |
| SV * name = ST(2) |
| 595 |
|
| ; |
| 596 |
6 |
| IV now = (IV)SvIV(ST(3)) |
| 597 |
|
| ; |
| 598 |
|
| IV RETVAL; |
| 599 |
6 |
▶ | dXSTARG; |
Branch: 2 branches
| Branch | True | False | Total |
| dXSTARG; |
0 |
6 |
6 |
| dXSTARG; |
6 |
0 |
6 |
|
| 600 |
|
| #line 85 "./xs/plugin.xs" |
| 601 |
|
| HV *opts; |
| 602 |
|
| HV *cfg = NULL; |
| 603 |
|
| SV *idpsv; |
| 604 |
|
| PERL_UNUSED_VAR(class); |
| 605 |
|
| if (!app || !SvROK(app)) |
| 606 |
|
| croak("%s: _refetch_idp needs the Punk::App", PSAML_WHO); |
| 607 |
|
| opts = psaml_opts_of(aTHX_ app); |
| 608 |
|
| idpsv = psaml_app_get(aTHX_ app, PSAML_K_IDPS); |
| 609 |
|
| if (opts && idpsv && SvROK(idpsv) && name && SvOK(name)) { |
| 610 |
|
| STRLEN nl; |
| 611 |
|
| const char *np = SvPV_const(name, nl); |
| 612 |
|
| SV **e = hv_fetch((HV *)SvRV(idpsv), np, (I32)nl, 0); |
| 613 |
|
| if (e && *e && SvROK(*e)) cfg = (HV *)SvRV(*e); |
| 614 |
|
| } |
| 615 |
|
| RETVAL = cfg ? psaml_idp_refetch(aTHX_ app, opts, name, cfg, now) : 0; |
| 616 |
|
| #line 617 "PSAML.c" |
| 617 |
6 |
▶ | TARGi((IV)RETVAL, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| TARGi((IV)RETVAL, 1); |
0 |
6 |
6 |
|
| 618 |
6 |
| ST(0) = TARG; |
| 619 |
|
| } |
| 620 |
6 |
| XSRETURN(1); |
| 621 |
|
| } |
| 622 |
|
| |
| 623 |
|
| |
| 624 |
|
| XS_EUPXS(XS_Punk__Plugin__SAML__state); /* prototype to pass -Wmissing-prototypes */ |
| 625 |
117 |
| XS_EUPXS(XS_Punk__Plugin__SAML__state) |
| 626 |
|
| { |
| 627 |
117 |
| dVAR; dXSARGS; |
| 628 |
117 |
▶ | if (items != 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 3) |
0 |
117 |
117 |
|
| 629 |
0 |
| croak_xs_usage(cv, "class, app, key"); |
| 630 |
|
| { |
| 631 |
117 |
| SV * class = ST(0) |
| 632 |
|
| ; |
| 633 |
117 |
| SV * app = ST(1) |
| 634 |
|
| ; |
| 635 |
234 |
| const char * key = (const char *)SvPV_nolen(ST(2)) |
| 636 |
|
| ; |
| 637 |
|
| SV * RETVAL; |
| 638 |
|
| #line 112 "./xs/plugin.xs" |
| 639 |
|
| SV *v; |
| 640 |
|
| PERL_UNUSED_VAR(class); |
| 641 |
|
| v = psaml_app_get(aTHX_ app, key); |
| 642 |
|
| /* XSRETURN_UNDEF, never `RETVAL = &PL_sv_undef`: xsubpp mortalises |
| 643 |
|
| * RETVAL, and a mortalise on an immortal spends a reference nobody |
| 644 |
|
| * took. Harmless from perl 5.20 and fatal before it. */ |
| 645 |
|
| if (!v) XSRETURN_UNDEF; |
| 646 |
|
| RETVAL = newSVsv(v); |
| 647 |
|
| #line 648 "PSAML.c" |
| 648 |
64 |
| RETVAL = sv_2mortal(RETVAL); |
| 649 |
64 |
| ST(0) = RETVAL; |
| 650 |
|
| } |
| 651 |
64 |
| XSRETURN(1); |
| 652 |
|
| } |
| 653 |
|
| |
| 654 |
|
| |
| 655 |
|
| /* INCLUDE: Returning to 'PSAML.xs' from 'xs/plugin.xs' */ |
| 656 |
|
| |
| 657 |
|
| |
| 658 |
|
| /* INCLUDE: Including 'xs/request.xs' from 'PSAML.xs' */ |
| 659 |
|
| |
| 660 |
|
| |
| 661 |
|
| XS_EUPXS(XS_Punk__SAML__Request_new_id); /* prototype to pass -Wmissing-prototypes */ |
| 662 |
50 |
| XS_EUPXS(XS_Punk__SAML__Request_new_id) |
| 663 |
|
| { |
| 664 |
50 |
| dVAR; dXSARGS; |
| 665 |
50 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
50 |
50 |
|
| 666 |
0 |
| croak_xs_usage(cv, "class"); |
| 667 |
|
| { |
| 668 |
50 |
| SV * class = ST(0) |
| 669 |
|
| ; |
| 670 |
|
| SV * RETVAL; |
| 671 |
|
| #line 11 "./xs/request.xs" |
| 672 |
|
| PERL_UNUSED_VAR(class); |
| 673 |
|
| RETVAL = psaml_request_id(aTHX); |
| 674 |
|
| #line 675 "PSAML.c" |
| 675 |
50 |
| RETVAL = sv_2mortal(RETVAL); |
| 676 |
50 |
| ST(0) = RETVAL; |
| 677 |
|
| } |
| 678 |
50 |
| XSRETURN(1); |
| 679 |
|
| } |
| 680 |
|
| |
| 681 |
|
| |
| 682 |
|
| XS_EUPXS(XS_Punk__SAML__Request_build); /* prototype to pass -Wmissing-prototypes */ |
| 683 |
8 |
| XS_EUPXS(XS_Punk__SAML__Request_build) |
| 684 |
|
| { |
| 685 |
8 |
| dVAR; dXSARGS; |
| 686 |
8 |
▶ | if (items < 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 1) |
0 |
8 |
8 |
|
| 687 |
0 |
| croak_xs_usage(cv, "class, ..."); |
| 688 |
|
| { |
| 689 |
8 |
▶ | SV * class = ST(0) |
Branch: 1 branch
| Branch | True | False | Total |
| SV * class = ST(0) |
0 |
8 |
8 |
|
| 690 |
|
| ; |
| 691 |
|
| SV * RETVAL; |
| 692 |
|
| #line 21 "./xs/request.xs" |
| 693 |
|
| HV *a; |
| 694 |
|
| int i; |
| 695 |
|
| PERL_UNUSED_VAR(class); |
| 696 |
|
| if ((items - 1) % 2) |
| 697 |
|
| croak("%s: Request->build takes a list of pairs", PSAML_WHO); |
| 698 |
|
| a = newHV(); |
| 699 |
|
| sv_2mortal((SV *)a); |
| 700 |
|
| for (i = 1; i + 1 < items; i += 2) { |
| 701 |
|
| STRLEN kl; |
| 702 |
|
| const char *k = SvPV_const(ST(i), kl); |
| 703 |
|
| (void)hv_store(a, k, (I32)kl, newSVsv(ST(i + 1)), 0); |
| 704 |
|
| } |
| 705 |
|
| RETVAL = psaml_authn_request(aTHX_ |
| 706 |
|
| psaml_hget(aTHX_ a, "id"), |
| 707 |
|
| psaml_hget(aTHX_ a, "instant"), |
| 708 |
|
| psaml_hget(aTHX_ a, "destination"), |
| 709 |
|
| psaml_hget(aTHX_ a, "acs_url"), |
| 710 |
|
| psaml_hget(aTHX_ a, "issuer"), |
| 711 |
|
| psaml_hget(aTHX_ a, "name_id_format"), |
| 712 |
|
| psaml_opt_bool(aTHX_ a, "force_authn", 0)); |
| 713 |
|
| #line 714 "PSAML.c" |
| 714 |
8 |
| RETVAL = sv_2mortal(RETVAL); |
| 715 |
8 |
| ST(0) = RETVAL; |
| 716 |
|
| } |
| 717 |
8 |
| XSRETURN(1); |
| 718 |
|
| } |
| 719 |
|
| |
| 720 |
|
| |
| 721 |
|
| XS_EUPXS(XS_Punk__SAML__Request_redirect_url); /* prototype to pass -Wmissing-prototypes */ |
| 722 |
6 |
| XS_EUPXS(XS_Punk__SAML__Request_redirect_url) |
| 723 |
|
| { |
| 724 |
6 |
| dVAR; dXSARGS; |
| 725 |
6 |
▶ | if (items < 3 || items > 5) |
Branch: 2 branches
| Branch | True | False | Total |
| if (items < 3 || items > 5) |
6 |
0 |
6 |
| if (items < 3 || items > 5) |
0 |
6 |
6 |
|
| 726 |
0 |
| croak_xs_usage(cv, "class, sso_url, xml, relay = &PL_sv_undef, key_pem = &PL_sv_undef"); |
| 727 |
|
| { |
| 728 |
6 |
| SV * class = ST(0) |
| 729 |
|
| ; |
| 730 |
6 |
| SV * sso_url = ST(1) |
| 731 |
|
| ; |
| 732 |
6 |
| SV * xml = ST(2) |
| 733 |
|
| ; |
| 734 |
|
| SV * relay; |
| 735 |
|
| SV * key_pem; |
| 736 |
|
| SV * RETVAL; |
| 737 |
|
| |
| 738 |
6 |
▶ | if (items < 4) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 4) |
0 |
6 |
6 |
|
| 739 |
0 |
| relay = &PL_sv_undef; |
| 740 |
|
| else { |
| 741 |
6 |
| relay = ST(3) |
| 742 |
|
| ; |
| 743 |
|
| } |
| 744 |
|
| |
| 745 |
6 |
▶ | if (items < 5) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 5) |
3 |
3 |
6 |
|
| 746 |
3 |
| key_pem = &PL_sv_undef; |
| 747 |
|
| else { |
| 748 |
3 |
| key_pem = ST(4) |
| 749 |
|
| ; |
| 750 |
|
| } |
| 751 |
|
| #line 53 "./xs/request.xs" |
| 752 |
|
| PERL_UNUSED_VAR(class); |
| 753 |
|
| RETVAL = psaml_redirect_url(aTHX_ sso_url, xml, relay, key_pem); |
| 754 |
|
| #line 755 "PSAML.c" |
| 755 |
5 |
| RETVAL = sv_2mortal(RETVAL); |
| 756 |
5 |
| ST(0) = RETVAL; |
| 757 |
|
| } |
| 758 |
5 |
| XSRETURN(1); |
| 759 |
|
| } |
| 760 |
|
| |
| 761 |
|
| |
| 762 |
|
| XS_EUPXS(XS_Punk__SAML__urlenc); /* prototype to pass -Wmissing-prototypes */ |
| 763 |
8 |
| XS_EUPXS(XS_Punk__SAML__urlenc) |
| 764 |
|
| { |
| 765 |
8 |
| dVAR; dXSARGS; |
| 766 |
8 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
8 |
8 |
|
| 767 |
0 |
| croak_xs_usage(cv, "str"); |
| 768 |
|
| { |
| 769 |
8 |
| SV * str = ST(0) |
| 770 |
|
| ; |
| 771 |
|
| SV * RETVAL; |
| 772 |
|
| #line 66 "./xs/request.xs" |
| 773 |
|
| RETVAL = psaml_urlenc(aTHX_ str); |
| 774 |
|
| #line 775 "PSAML.c" |
| 775 |
8 |
| RETVAL = sv_2mortal(RETVAL); |
| 776 |
8 |
| ST(0) = RETVAL; |
| 777 |
|
| } |
| 778 |
8 |
| XSRETURN(1); |
| 779 |
|
| } |
| 780 |
|
| |
| 781 |
|
| |
| 782 |
|
| XS_EUPXS(XS_Punk__SAML__deflate_b64); /* prototype to pass -Wmissing-prototypes */ |
| 783 |
1 |
| XS_EUPXS(XS_Punk__SAML__deflate_b64) |
| 784 |
|
| { |
| 785 |
1 |
| dVAR; dXSARGS; |
| 786 |
1 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
1 |
1 |
|
| 787 |
0 |
| croak_xs_usage(cv, "bytes"); |
| 788 |
|
| { |
| 789 |
1 |
| SV * bytes = ST(0) |
| 790 |
|
| ; |
| 791 |
|
| SV * RETVAL; |
| 792 |
|
| #line 74 "./xs/request.xs" |
| 793 |
|
| RETVAL = psaml_deflate_b64(aTHX_ bytes); |
| 794 |
|
| #line 795 "PSAML.c" |
| 795 |
1 |
| RETVAL = sv_2mortal(RETVAL); |
| 796 |
1 |
| ST(0) = RETVAL; |
| 797 |
|
| } |
| 798 |
1 |
| XSRETURN(1); |
| 799 |
|
| } |
| 800 |
|
| |
| 801 |
|
| |
| 802 |
|
| XS_EUPXS(XS_Punk__SAML__signed_string); /* prototype to pass -Wmissing-prototypes */ |
| 803 |
2 |
| XS_EUPXS(XS_Punk__SAML__signed_string) |
| 804 |
|
| { |
| 805 |
2 |
| dVAR; dXSARGS; |
| 806 |
2 |
▶ | if (items != 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 3) |
0 |
2 |
2 |
|
| 807 |
0 |
| croak_xs_usage(cv, "enc_req, enc_relay, enc_sigalg"); |
| 808 |
|
| { |
| 809 |
2 |
| SV * enc_req = ST(0) |
| 810 |
|
| ; |
| 811 |
2 |
| SV * enc_relay = ST(1) |
| 812 |
|
| ; |
| 813 |
2 |
▶ | SV * enc_sigalg = ST(2) |
Branch: 1 branch
| Branch | True | False | Total |
| SV * enc_sigalg = ST(2) |
2 |
0 |
2 |
|
| 814 |
|
| ; |
| 815 |
|
| SV * RETVAL; |
| 816 |
|
| #line 87 "./xs/request.xs" |
| 817 |
|
| RETVAL = psaml_signed_string(aTHX_ enc_req, |
| 818 |
|
| (SvOK(enc_relay) && SvCUR(enc_relay)) ? enc_relay : NULL, |
| 819 |
|
| enc_sigalg); |
| 820 |
|
| #line 821 "PSAML.c" |
| 821 |
2 |
| RETVAL = sv_2mortal(RETVAL); |
| 822 |
2 |
| ST(0) = RETVAL; |
| 823 |
|
| } |
| 824 |
2 |
| XSRETURN(1); |
| 825 |
|
| } |
| 826 |
|
| |
| 827 |
|
| |
| 828 |
|
| XS_EUPXS(XS_Punk__SAML__decode_field); /* prototype to pass -Wmissing-prototypes */ |
| 829 |
7 |
| XS_EUPXS(XS_Punk__SAML__decode_field) |
| 830 |
|
| { |
| 831 |
7 |
| dVAR; dXSARGS; |
| 832 |
7 |
▶ | if (items != 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 2) |
0 |
7 |
7 |
|
| 833 |
0 |
| croak_xs_usage(cv, "field, max_bytes"); |
| 834 |
|
| { |
| 835 |
7 |
| SV * field = ST(0) |
| 836 |
|
| ; |
| 837 |
7 |
| IV max_bytes = (IV)SvIV(ST(1)) |
| 838 |
|
| ; |
| 839 |
|
| SV * RETVAL; |
| 840 |
|
| #line 98 "./xs/request.xs" |
| 841 |
|
| RETVAL = psaml_decode_field(aTHX_ field, max_bytes); |
| 842 |
|
| #line 843 "PSAML.c" |
| 843 |
3 |
| RETVAL = sv_2mortal(RETVAL); |
| 844 |
3 |
| ST(0) = RETVAL; |
| 845 |
|
| } |
| 846 |
3 |
| XSRETURN(1); |
| 847 |
|
| } |
| 848 |
|
| |
| 849 |
|
| |
| 850 |
|
| XS_EUPXS(XS_Punk__SAML__verify_bytes); /* prototype to pass -Wmissing-prototypes */ |
| 851 |
4 |
| XS_EUPXS(XS_Punk__SAML__verify_bytes) |
| 852 |
|
| { |
| 853 |
4 |
| dVAR; dXSARGS; |
| 854 |
4 |
▶ | if (items != 4) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 4) |
0 |
4 |
4 |
|
| 855 |
0 |
| croak_xs_usage(cv, "pub_pem, alg, input, sig"); |
| 856 |
|
| { |
| 857 |
4 |
| SV * pub_pem = ST(0) |
| 858 |
|
| ; |
| 859 |
4 |
| SV * alg = ST(1) |
| 860 |
|
| ; |
| 861 |
4 |
| SV * input = ST(2) |
| 862 |
|
| ; |
| 863 |
4 |
| SV * sig = ST(3) |
| 864 |
|
| ; |
| 865 |
|
| int RETVAL; |
| 866 |
4 |
▶ | dXSTARG; |
Branch: 1 branch
| Branch | True | False | Total |
| dXSTARG; |
4 |
0 |
4 |
|
| 867 |
|
| #line 117 "./xs/request.xs" |
| 868 |
|
| const jws_abi *J = psaml_jws(aTHX); |
| 869 |
|
| STRLEN pl, al, il, sl; |
| 870 |
|
| const char *pp = SvPVbyte(pub_pem, pl); |
| 871 |
|
| const char *ap = SvPVbyte(alg, al); |
| 872 |
|
| const char *ip = SvPVbyte(input, il); |
| 873 |
|
| const char *gp = SvPVbyte(sig, sl); |
| 874 |
|
| void *k = J->key_from_pem(aTHX_ pp, pl); |
| 875 |
|
| if (!k) croak("%s: the public key will not parse", PSAML_WHO); |
| 876 |
|
| RETVAL = J->verify(aTHX_ k, ap, al, |
| 877 |
|
| (const unsigned char *)ip, il, |
| 878 |
|
| (const unsigned char *)gp, sl); |
| 879 |
|
| J->key_free(aTHX_ k); |
| 880 |
|
| #line 881 "PSAML.c" |
| 881 |
4 |
▶ | TARGi((IV)RETVAL, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| TARGi((IV)RETVAL, 1); |
2 |
2 |
4 |
|
| 882 |
4 |
| ST(0) = TARG; |
| 883 |
|
| } |
| 884 |
4 |
| XSRETURN(1); |
| 885 |
|
| } |
| 886 |
|
| |
| 887 |
|
| |
| 888 |
|
| /* INCLUDE: Returning to 'PSAML.xs' from 'xs/request.xs' */ |
| 889 |
|
| |
| 890 |
|
| |
| 891 |
|
| /* INCLUDE: Including 'xs/response.xs' from 'PSAML.xs' */ |
| 892 |
|
| |
| 893 |
|
| |
| 894 |
|
| XS_EUPXS(XS_Punk__SAML__Response_verify); /* prototype to pass -Wmissing-prototypes */ |
| 895 |
397 |
| XS_EUPXS(XS_Punk__SAML__Response_verify) |
| 896 |
|
| { |
| 897 |
397 |
| dVAR; dXSARGS; |
| 898 |
397 |
| dXSI32; |
| 899 |
397 |
▶ | if (items < 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 2) |
0 |
397 |
397 |
|
| 900 |
0 |
| croak_xs_usage(cv, "class, bytes, ..."); |
| 901 |
|
| { |
| 902 |
397 |
| SV * class = ST(0) |
| 903 |
|
| ; |
| 904 |
397 |
▶ | SV * bytes = ST(1) |
Branch: 1 branch
| Branch | True | False | Total |
| SV * bytes = ST(1) |
0 |
397 |
397 |
|
| 905 |
|
| ; |
| 906 |
|
| SV * RETVAL; |
| 907 |
|
| #line 17 "./xs/response.xs" |
| 908 |
|
| HV *a; |
| 909 |
|
| psaml_checks o; |
| 910 |
|
| SV *v; |
| 911 |
|
| int i; |
| 912 |
|
| PERL_UNUSED_VAR(class); |
| 913 |
|
| if ((items - 2) % 2) |
| 914 |
|
| croak("%s: Response->verify takes bytes and a list of pairs", |
| 915 |
|
| PSAML_WHO); |
| 916 |
|
| a = newHV(); |
| 917 |
|
| sv_2mortal((SV *)a); |
| 918 |
|
| for (i = 2; i + 1 < items; i += 2) { |
| 919 |
|
| STRLEN kl; |
| 920 |
|
| const char *k = SvPV_const(ST(i), kl); |
| 921 |
|
| (void)hv_store(a, k, (I32)kl, newSVsv(ST(i + 1)), 0); |
| 922 |
|
| } |
| 923 |
|
| |
| 924 |
|
| /* _verify_field is verify with the transport in front of it: the |
| 925 |
|
| * size cap on the ENCODED field, then the strict base64. It is an |
| 926 |
|
| * ALIAS rather than a wrapper that re-enters verify through |
| 927 |
|
| * call_method - the wrapper was written first, and pushing the |
| 928 |
|
| * caller\'s own arguments back onto the stack it was reading them |
| 929 |
|
| * from produced a freed-string panic. One body, two names. */ |
| 930 |
|
| if (ix == 1) |
| 931 |
|
| bytes = sv_2mortal(psaml_decode_field(aTHX_ bytes, |
| 932 |
|
| psaml_opt_iv(aTHX_ a, "max_response", 262144))); |
| 933 |
|
| |
| 934 |
|
| Zero(&o, 1, psaml_checks); |
| 935 |
|
| v = psaml_hget(aTHX_ a, "idp"); |
| 936 |
|
| o.idp_name = (v && SvOK(v)) ? SvPV_nolen(v) : ""; |
| 937 |
|
| v = psaml_hget(aTHX_ a, "entity_id"); |
| 938 |
|
| if (!v || !SvOK(v)) |
| 939 |
|
| croak("%s: Response->verify needs `entity_id`, this " |
| 940 |
|
| "application's own", PSAML_WHO); |
| 941 |
|
| o.entity_id = SvPV_nolen(v); |
| 942 |
|
| v = psaml_hget(aTHX_ a, "idp_entity_id"); |
| 943 |
|
| if (!v || !SvOK(v)) |
| 944 |
|
| croak("%s: Response->verify needs `idp_entity_id`, the " |
| 945 |
|
| "provider's", PSAML_WHO); |
| 946 |
|
| o.idp_entity_id = SvPV_nolen(v); |
| 947 |
|
| v = psaml_hget(aTHX_ a, "acs_url"); |
| 948 |
|
| if (!v || !SvOK(v)) |
| 949 |
|
| croak("%s: Response->verify needs `acs_url`", PSAML_WHO); |
| 950 |
|
| o.acs_url = SvPV_nolen(v); |
| 951 |
|
| |
| 952 |
|
| v = psaml_hget(aTHX_ a, "certs"); |
| 953 |
|
| if (!v || !SvROK(v) || SvTYPE(SvRV(v)) != SVt_PVAV) |
| 954 |
|
| croak("%s: Response->verify needs `certs`, an arrayref of the " |
| 955 |
|
| "provider's signing certificates", PSAML_WHO); |
| 956 |
|
| o.keys = (AV *)SvRV(v); |
| 957 |
|
| |
| 958 |
|
| v = psaml_hget(aTHX_ a, "now"); |
| 959 |
|
| o.now = (v && SvOK(v)) ? SvIV(v) : (IV)time(NULL); |
| 960 |
|
| o.skew = psaml_opt_iv(aTHX_ a, "skew", 120); |
| 961 |
|
| o.allow_sha1 = psaml_opt_bool(aTHX_ a, "allow_sha1", 0); |
| 962 |
|
| o.allow_idp_initiated = |
| 963 |
|
| psaml_opt_bool(aTHX_ a, "allow_idp_initiated", 0); |
| 964 |
|
| v = psaml_hget(aTHX_ a, "require_signed"); |
| 965 |
|
| o.require_signed = (v && SvOK(v)) ? SvPV_nolen(v) : "either"; |
| 966 |
|
| o.flow_id = psaml_hget(aTHX_ a, "in_response_to"); |
| 967 |
|
| o.seen_cb = psaml_hget(aTHX_ a, "seen"); |
| 968 |
|
| |
| 969 |
|
| RETVAL = psaml_verify_response(aTHX_ bytes, &o); |
| 970 |
|
| #line 971 "PSAML.c" |
| 971 |
78 |
| RETVAL = sv_2mortal(RETVAL); |
| 972 |
78 |
| ST(0) = RETVAL; |
| 973 |
|
| } |
| 974 |
78 |
| XSRETURN(1); |
| 975 |
|
| } |
| 976 |
|
| |
| 977 |
|
| |
| 978 |
|
| XS_EUPXS(XS_Punk__SAML__Response__replayed); /* prototype to pass -Wmissing-prototypes */ |
| 979 |
185 |
| XS_EUPXS(XS_Punk__SAML__Response__replayed) |
| 980 |
|
| { |
| 981 |
185 |
| dVAR; dXSARGS; |
| 982 |
185 |
▶ | if (items != 5) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 5) |
0 |
185 |
185 |
|
| 983 |
0 |
| croak_xs_usage(cv, "class, c, seen, identity, skew"); |
| 984 |
|
| { |
| 985 |
185 |
| SV * class = ST(0) |
| 986 |
|
| ; |
| 987 |
185 |
| SV * c = ST(1) |
| 988 |
|
| ; |
| 989 |
185 |
| SV * seen = ST(2) |
| 990 |
|
| ; |
| 991 |
185 |
| SV * identity = ST(3) |
| 992 |
|
| ; |
| 993 |
185 |
| IV skew = (IV)SvIV(ST(4)) |
| 994 |
|
| ; |
| 995 |
|
| IV RETVAL; |
| 996 |
185 |
▶ | dXSTARG; |
Branch: 1 branch
| Branch | True | False | Total |
| dXSTARG; |
159 |
26 |
185 |
|
| 997 |
|
| #line 100 "./xs/response.xs" |
| 998 |
|
| PERL_UNUSED_VAR(class); |
| 999 |
|
| RETVAL = psaml_replayed(aTHX_ c, seen, identity, skew); |
| 1000 |
|
| #line 1001 "PSAML.c" |
| 1001 |
131 |
▶ | TARGi((IV)RETVAL, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| TARGi((IV)RETVAL, 1); |
104 |
27 |
131 |
|
| 1002 |
131 |
| ST(0) = TARG; |
| 1003 |
|
| } |
| 1004 |
131 |
| XSRETURN(1); |
| 1005 |
|
| } |
| 1006 |
|
| |
| 1007 |
|
| |
| 1008 |
|
| XS_EUPXS(XS_Punk__SAML__sign_bytes); /* prototype to pass -Wmissing-prototypes */ |
| 1009 |
95 |
| XS_EUPXS(XS_Punk__SAML__sign_bytes) |
| 1010 |
|
| { |
| 1011 |
95 |
| dVAR; dXSARGS; |
| 1012 |
95 |
▶ | if (items != 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 3) |
0 |
95 |
95 |
|
| 1013 |
0 |
| croak_xs_usage(cv, "priv_pem, alg, input"); |
| 1014 |
|
| { |
| 1015 |
95 |
| SV * priv_pem = ST(0) |
| 1016 |
|
| ; |
| 1017 |
95 |
| SV * alg = ST(1) |
| 1018 |
|
| ; |
| 1019 |
95 |
| SV * input = ST(2) |
| 1020 |
|
| ; |
| 1021 |
|
| SV * RETVAL; |
| 1022 |
|
| #line 117 "./xs/response.xs" |
| 1023 |
|
| const jws_abi *J = psaml_jws(aTHX); |
| 1024 |
|
| STRLEN pl, al, il; |
| 1025 |
|
| const char *pp = SvPVbyte(priv_pem, pl); |
| 1026 |
|
| const char *ap = SvPVbyte(alg, al); |
| 1027 |
|
| const char *ip = SvPVbyte(input, il); |
| 1028 |
|
| void *k = J->key_from_pem(aTHX_ pp, pl); |
| 1029 |
|
| if (!k) croak("%s: the private key will not parse", PSAML_WHO); |
| 1030 |
|
| RETVAL = J->sign(aTHX_ k, ap, al, (const unsigned char *)ip, il); |
| 1031 |
|
| J->key_free(aTHX_ k); |
| 1032 |
|
| if (!RETVAL) croak("%s: signing failed", PSAML_WHO); |
| 1033 |
|
| #line 1034 "PSAML.c" |
| 1034 |
95 |
| RETVAL = sv_2mortal(RETVAL); |
| 1035 |
95 |
| ST(0) = RETVAL; |
| 1036 |
|
| } |
| 1037 |
95 |
| XSRETURN(1); |
| 1038 |
|
| } |
| 1039 |
|
| |
| 1040 |
|
| |
| 1041 |
|
| /* INCLUDE: Returning to 'PSAML.xs' from 'xs/response.xs' */ |
| 1042 |
|
| |
| 1043 |
|
| |
| 1044 |
|
| /* INCLUDE: Including 'xs/metadata.xs' from 'PSAML.xs' */ |
| 1045 |
|
| |
| 1046 |
|
| |
| 1047 |
|
| XS_EUPXS(XS_Punk__SAML__IdP_read); /* prototype to pass -Wmissing-prototypes */ |
| 1048 |
18 |
| XS_EUPXS(XS_Punk__SAML__IdP_read) |
| 1049 |
|
| { |
| 1050 |
18 |
| dVAR; dXSARGS; |
| 1051 |
18 |
▶ | if (items < 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 2) |
0 |
18 |
18 |
|
| 1052 |
0 |
| croak_xs_usage(cv, "class, bytes, ..."); |
| 1053 |
|
| { |
| 1054 |
18 |
| SV * class = ST(0) |
| 1055 |
|
| ; |
| 1056 |
18 |
▶ | SV * bytes = ST(1) |
Branch: 1 branch
| Branch | True | False | Total |
| SV * bytes = ST(1) |
0 |
18 |
18 |
|
| 1057 |
|
| ; |
| 1058 |
|
| SV * RETVAL; |
| 1059 |
|
| #line 12 "./xs/metadata.xs" |
| 1060 |
|
| HV *a; |
| 1061 |
|
| SV *want; |
| 1062 |
|
| int i; |
| 1063 |
|
| PERL_UNUSED_VAR(class); |
| 1064 |
|
| if ((items - 2) % 2) |
| 1065 |
|
| croak("%s: IdP->read takes bytes and a list of pairs", PSAML_WHO); |
| 1066 |
|
| a = newHV(); |
| 1067 |
|
| sv_2mortal((SV *)a); |
| 1068 |
|
| for (i = 2; i + 1 < items; i += 2) { |
| 1069 |
|
| STRLEN kl; |
| 1070 |
|
| const char *k = SvPV_const(ST(i), kl); |
| 1071 |
|
| (void)hv_store(a, k, (I32)kl, newSVsv(ST(i + 1)), 0); |
| 1072 |
|
| } |
| 1073 |
|
| want = psaml_hget(aTHX_ a, "entity_id"); |
| 1074 |
|
| RETVAL = psaml_idp_from_metadata(aTHX_ bytes, |
| 1075 |
|
| (want && SvOK(want)) ? SvPV_nolen(want) : NULL, |
| 1076 |
|
| psaml_opt_bool(aTHX_ a, "enforce_cert_validity", 0)); |
| 1077 |
|
| #line 1078 "PSAML.c" |
| 1078 |
7 |
| RETVAL = sv_2mortal(RETVAL); |
| 1079 |
7 |
| ST(0) = RETVAL; |
| 1080 |
|
| } |
| 1081 |
7 |
| XSRETURN(1); |
| 1082 |
|
| } |
| 1083 |
|
| |
| 1084 |
|
| |
| 1085 |
|
| XS_EUPXS(XS_Punk__SAML__Metadata_build); /* prototype to pass -Wmissing-prototypes */ |
| 1086 |
57 |
| XS_EUPXS(XS_Punk__SAML__Metadata_build) |
| 1087 |
|
| { |
| 1088 |
57 |
| dVAR; dXSARGS; |
| 1089 |
57 |
▶ | if (items < 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 1) |
0 |
57 |
57 |
|
| 1090 |
0 |
| croak_xs_usage(cv, "class, ..."); |
| 1091 |
|
| { |
| 1092 |
57 |
▶ | SV * class = ST(0) |
Branch: 1 branch
| Branch | True | False | Total |
| SV * class = ST(0) |
0 |
57 |
57 |
|
| 1093 |
|
| ; |
| 1094 |
|
| SV * RETVAL; |
| 1095 |
|
| #line 40 "./xs/metadata.xs" |
| 1096 |
|
| HV *a; |
| 1097 |
|
| int i; |
| 1098 |
|
| PERL_UNUSED_VAR(class); |
| 1099 |
|
| if ((items - 1) % 2) |
| 1100 |
|
| croak("%s: Metadata->build takes a list of pairs", PSAML_WHO); |
| 1101 |
|
| a = newHV(); |
| 1102 |
|
| sv_2mortal((SV *)a); |
| 1103 |
|
| for (i = 1; i + 1 < items; i += 2) { |
| 1104 |
|
| STRLEN kl; |
| 1105 |
|
| const char *k = SvPV_const(ST(i), kl); |
| 1106 |
|
| (void)hv_store(a, k, (I32)kl, newSVsv(ST(i + 1)), 0); |
| 1107 |
|
| } |
| 1108 |
|
| RETVAL = psaml_sp_metadata(aTHX_ |
| 1109 |
|
| psaml_hget(aTHX_ a, "entity_id"), |
| 1110 |
|
| psaml_hget(aTHX_ a, "acs_url"), |
| 1111 |
|
| psaml_hget(aTHX_ a, "cert"), |
| 1112 |
|
| psaml_hget(aTHX_ a, "name_id_format"), |
| 1113 |
|
| psaml_opt_bool(aTHX_ a, "authn_requests_signed", 0), |
| 1114 |
|
| psaml_opt_bool(aTHX_ a, "want_assertions_signed", 1)); |
| 1115 |
|
| #line 1116 "PSAML.c" |
| 1116 |
57 |
| RETVAL = sv_2mortal(RETVAL); |
| 1117 |
57 |
| ST(0) = RETVAL; |
| 1118 |
|
| } |
| 1119 |
57 |
| XSRETURN(1); |
| 1120 |
|
| } |
| 1121 |
|
| |
| 1122 |
|
| |
| 1123 |
|
| XS_EUPXS(XS_Punk__SAML__Metadata_sign); /* prototype to pass -Wmissing-prototypes */ |
| 1124 |
1 |
| XS_EUPXS(XS_Punk__SAML__Metadata_sign) |
| 1125 |
|
| { |
| 1126 |
1 |
| dVAR; dXSARGS; |
| 1127 |
1 |
▶ | if (items < 4 || items > 5) |
Branch: 2 branches
| Branch | True | False | Total |
| if (items < 4 || items > 5) |
1 |
0 |
1 |
| if (items < 4 || items > 5) |
0 |
1 |
1 |
|
| 1128 |
0 |
| croak_xs_usage(cv, "class, xml, id, key_pem, cert_pem = &PL_sv_undef"); |
| 1129 |
|
| { |
| 1130 |
1 |
| SV * class = ST(0) |
| 1131 |
|
| ; |
| 1132 |
1 |
| SV * xml = ST(1) |
| 1133 |
|
| ; |
| 1134 |
1 |
| SV * id = ST(2) |
| 1135 |
|
| ; |
| 1136 |
1 |
| SV * key_pem = ST(3) |
| 1137 |
|
| ; |
| 1138 |
|
| SV * cert_pem; |
| 1139 |
|
| SV * RETVAL; |
| 1140 |
|
| |
| 1141 |
1 |
▶ | if (items < 5) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items < 5) |
0 |
1 |
1 |
|
| 1142 |
0 |
| cert_pem = &PL_sv_undef; |
| 1143 |
|
| else { |
| 1144 |
1 |
| cert_pem = ST(4) |
| 1145 |
|
| ; |
| 1146 |
|
| } |
| 1147 |
|
| #line 72 "./xs/metadata.xs" |
| 1148 |
|
| PERL_UNUSED_VAR(class); |
| 1149 |
|
| RETVAL = psaml_sign_document(aTHX_ xml, id, key_pem, cert_pem); |
| 1150 |
|
| #line 1151 "PSAML.c" |
| 1151 |
1 |
| RETVAL = sv_2mortal(RETVAL); |
| 1152 |
1 |
| ST(0) = RETVAL; |
| 1153 |
|
| } |
| 1154 |
1 |
| XSRETURN(1); |
| 1155 |
|
| } |
| 1156 |
|
| |
| 1157 |
|
| |
| 1158 |
|
| XS_EUPXS(XS_Punk__SAML__Metadata_content_type); /* prototype to pass -Wmissing-prototypes */ |
| 1159 |
1 |
| XS_EUPXS(XS_Punk__SAML__Metadata_content_type) |
| 1160 |
|
| { |
| 1161 |
1 |
| dVAR; dXSARGS; |
| 1162 |
1 |
▶ | if (items != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 1) |
0 |
1 |
1 |
|
| 1163 |
0 |
| croak_xs_usage(cv, "class"); |
| 1164 |
|
| { |
| 1165 |
1 |
| SV * class = ST(0) |
| 1166 |
|
| ; |
| 1167 |
|
| SV * RETVAL; |
| 1168 |
|
| #line 81 "./xs/metadata.xs" |
| 1169 |
|
| PERL_UNUSED_VAR(class); |
| 1170 |
|
| RETVAL = newSVpvs(PSAML_CT_METADATA); |
| 1171 |
|
| #line 1172 "PSAML.c" |
| 1172 |
1 |
| RETVAL = sv_2mortal(RETVAL); |
| 1173 |
1 |
| ST(0) = RETVAL; |
| 1174 |
|
| } |
| 1175 |
1 |
| XSRETURN(1); |
| 1176 |
|
| } |
| 1177 |
|
| |
| 1178 |
|
| |
| 1179 |
|
| XS_EUPXS(XS_Punk__SAML__verify_document); /* prototype to pass -Wmissing-prototypes */ |
| 1180 |
2 |
| XS_EUPXS(XS_Punk__SAML__verify_document) |
| 1181 |
|
| { |
| 1182 |
2 |
| dVAR; dXSARGS; |
| 1183 |
2 |
▶ | if (items != 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 3) |
0 |
2 |
2 |
|
| 1184 |
0 |
| croak_xs_usage(cv, "xml, id, certs"); |
| 1185 |
|
| { |
| 1186 |
2 |
| SV * xml = ST(0) |
| 1187 |
|
| ; |
| 1188 |
2 |
| SV * id = ST(1) |
| 1189 |
|
| ; |
| 1190 |
2 |
| SV * certs = ST(2) |
| 1191 |
|
| ; |
| 1192 |
|
| int RETVAL; |
| 1193 |
2 |
▶ | dXSTARG; |
Branch: 1 branch
| Branch | True | False | Total |
| dXSTARG; |
2 |
0 |
2 |
|
| 1194 |
|
| #line 98 "./xs/metadata.xs" |
| 1195 |
|
| psaml_doc_guard *guard = NULL; |
| 1196 |
|
| frx_doc *doc; |
| 1197 |
|
| const frx_node *target; |
| 1198 |
|
| psaml_verify_ctx ctx; |
| 1199 |
|
| STRLEN il; |
| 1200 |
|
| const char *ip = SvPVbyte(id, il); |
| 1201 |
|
| if (!SvROK(certs) || SvTYPE(SvRV(certs)) != SVt_PVAV) |
| 1202 |
|
| croak("%s: _verify_document takes an arrayref of certificates", |
| 1203 |
|
| PSAML_WHO); |
| 1204 |
|
| doc = psaml_parse_response(aTHX_ xml, &guard); |
| 1205 |
|
| target = psaml_frx(aTHX)->by_id(doc, "ID", ip, il); |
| 1206 |
|
| if (!target) XSRETURN_NO; |
| 1207 |
|
| ctx.doc = doc; |
| 1208 |
|
| ctx.keys = (AV *)SvRV(certs); |
| 1209 |
|
| ctx.allow_sha1 = 0; |
| 1210 |
|
| RETVAL = psaml_verify_element(aTHX_ &ctx, target); |
| 1211 |
|
| #line 1212 "PSAML.c" |
| 1212 |
1 |
▶ | TARGi((IV)RETVAL, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| TARGi((IV)RETVAL, 1); |
0 |
1 |
1 |
|
| 1213 |
1 |
| ST(0) = TARG; |
| 1214 |
|
| } |
| 1215 |
1 |
| XSRETURN(1); |
| 1216 |
|
| } |
| 1217 |
|
| |
| 1218 |
|
| |
| 1219 |
|
| XS_EUPXS(XS_Punk__SAML__flow_serialise); /* prototype to pass -Wmissing-prototypes */ |
| 1220 |
0 |
| XS_EUPXS(XS_Punk__SAML__flow_serialise) |
| 1221 |
|
| { |
| 1222 |
0 |
| dVAR; dXSARGS; |
| 1223 |
0 |
▶ | if (items != 2) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 2) |
0 |
0 |
0 |
|
| 1224 |
0 |
| croak_xs_usage(cv, "records, secret"); |
| 1225 |
|
| { |
| 1226 |
0 |
| SV * records = ST(0) |
| 1227 |
|
| ; |
| 1228 |
0 |
▶ | SV * secret = ST(1) |
Branch: 1 branch
| Branch | True | False | Total |
| SV * secret = ST(1) |
0 |
0 |
0 |
|
| 1229 |
|
| ; |
| 1230 |
|
| SV * RETVAL; |
| 1231 |
|
| #line 128 "./xs/metadata.xs" |
| 1232 |
|
| if (!SvROK(records) || SvTYPE(SvRV(records)) != SVt_PVAV) |
| 1233 |
|
| croak("%s: _flow_serialise takes an arrayref", PSAML_WHO); |
| 1234 |
|
| RETVAL = psaml_flow_serialise(aTHX_ (AV *)SvRV(records), secret); |
| 1235 |
|
| #line 1236 "PSAML.c" |
| 1236 |
0 |
| RETVAL = sv_2mortal(RETVAL); |
| 1237 |
0 |
| ST(0) = RETVAL; |
| 1238 |
|
| } |
| 1239 |
0 |
| XSRETURN(1); |
| 1240 |
|
| } |
| 1241 |
|
| |
| 1242 |
|
| |
| 1243 |
|
| XS_EUPXS(XS_Punk__SAML__flow_parse); /* prototype to pass -Wmissing-prototypes */ |
| 1244 |
0 |
| XS_EUPXS(XS_Punk__SAML__flow_parse) |
| 1245 |
|
| { |
| 1246 |
0 |
| dVAR; dXSARGS; |
| 1247 |
0 |
▶ | if (items != 4) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 4) |
0 |
0 |
0 |
|
| 1248 |
0 |
| croak_xs_usage(cv, "cookie, secret, now, ttl"); |
| 1249 |
|
| { |
| 1250 |
0 |
| SV * cookie = ST(0) |
| 1251 |
|
| ; |
| 1252 |
0 |
| SV * secret = ST(1) |
| 1253 |
|
| ; |
| 1254 |
0 |
| IV now = (IV)SvIV(ST(2)) |
| 1255 |
|
| ; |
| 1256 |
0 |
| IV ttl = (IV)SvIV(ST(3)) |
| 1257 |
|
| ; |
| 1258 |
|
| SV * RETVAL; |
| 1259 |
|
| #line 141 "./xs/metadata.xs" |
| 1260 |
|
| RETVAL = newRV_noinc((SV *)psaml_flow_parse(aTHX_ cookie, secret, |
| 1261 |
|
| now, ttl)); |
| 1262 |
|
| #line 1263 "PSAML.c" |
| 1263 |
0 |
| RETVAL = sv_2mortal(RETVAL); |
| 1264 |
0 |
| ST(0) = RETVAL; |
| 1265 |
|
| } |
| 1266 |
0 |
| XSRETURN(1); |
| 1267 |
|
| } |
| 1268 |
|
| |
| 1269 |
|
| |
| 1270 |
|
| XS_EUPXS(XS_Punk__SAML__flow_cookie); /* prototype to pass -Wmissing-prototypes */ |
| 1271 |
0 |
| XS_EUPXS(XS_Punk__SAML__flow_cookie) |
| 1272 |
|
| { |
| 1273 |
0 |
| dVAR; dXSARGS; |
| 1274 |
0 |
▶ | if (items != 3) |
Branch: 1 branch
| Branch | True | False | Total |
| if (items != 3) |
0 |
0 |
0 |
|
| 1275 |
0 |
| croak_xs_usage(cv, "value, mount, ttl"); |
| 1276 |
|
| { |
| 1277 |
0 |
| SV * value = ST(0) |
| 1278 |
|
| ; |
| 1279 |
0 |
| SV * mount = ST(1) |
| 1280 |
|
| ; |
| 1281 |
0 |
| IV ttl = (IV)SvIV(ST(2)) |
| 1282 |
|
| ; |
| 1283 |
|
| SV * RETVAL; |
| 1284 |
|
| #line 152 "./xs/metadata.xs" |
| 1285 |
|
| RETVAL = psaml_flow_cookie(aTHX_ value, mount, ttl); |
| 1286 |
|
| #line 1287 "PSAML.c" |
| 1287 |
0 |
| RETVAL = sv_2mortal(RETVAL); |
| 1288 |
0 |
| ST(0) = RETVAL; |
| 1289 |
|
| } |
| 1290 |
0 |
| XSRETURN(1); |
| 1291 |
|
| } |
| 1292 |
|
| |
| 1293 |
|
| |
| 1294 |
|
| /* INCLUDE: Returning to 'PSAML.xs' from 'xs/metadata.xs' */ |
| 1295 |
|
| |
| 1296 |
|
| #ifdef __cplusplus |
| 1297 |
|
| extern "C" { |
| 1298 |
|
| #endif |
| 1299 |
|
| XS_EXTERNAL(boot_Punk__SAML); /* prototype to pass -Wmissing-prototypes */ |
| 1300 |
16 |
| XS_EXTERNAL(boot_Punk__SAML) |
| 1301 |
|
| { |
| 1302 |
|
| #if PERL_VERSION_LE(5, 21, 5) |
| 1303 |
|
| dVAR; dXSARGS; |
| 1304 |
|
| #else |
| 1305 |
16 |
| dVAR; dXSBOOTARGSXSAPIVERCHK; |
| 1306 |
|
| #endif |
| 1307 |
|
| #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */ |
| 1308 |
|
| char* file = __FILE__; |
| 1309 |
|
| #else |
| 1310 |
16 |
| const char* file = __FILE__; |
| 1311 |
|
| #endif |
| 1312 |
|
| |
| 1313 |
|
| PERL_UNUSED_VAR(file); |
| 1314 |
|
| |
| 1315 |
|
| PERL_UNUSED_VAR(cv); /* -W */ |
| 1316 |
|
| PERL_UNUSED_VAR(items); /* -W */ |
| 1317 |
|
| #if PERL_VERSION_LE(5, 21, 5) |
| 1318 |
|
| XS_VERSION_BOOTCHECK; |
| 1319 |
|
| # ifdef XS_APIVERSION_BOOTCHECK |
| 1320 |
|
| XS_APIVERSION_BOOTCHECK; |
| 1321 |
|
| # endif |
| 1322 |
|
| #endif |
| 1323 |
|
| |
| 1324 |
|
| { |
| 1325 |
|
| CV * cv; |
| 1326 |
|
| |
| 1327 |
16 |
| newXS_deffile("Punk::SAML::_b64_encode", XS_Punk__SAML__b64_encode); |
| 1328 |
16 |
| newXS_deffile("Punk::SAML::_b64_decode", XS_Punk__SAML__b64_decode); |
| 1329 |
16 |
| newXS_deffile("Punk::SAML::_deflate", XS_Punk__SAML__deflate); |
| 1330 |
16 |
| newXS_deffile("Punk::SAML::_xml_escape", XS_Punk__SAML__xml_escape); |
| 1331 |
16 |
| newXS_deffile("Punk::SAML::_time_parse", XS_Punk__SAML__time_parse); |
| 1332 |
16 |
| newXS_deffile("Punk::SAML::_time_format", XS_Punk__SAML__time_format); |
| 1333 |
16 |
| newXS_deffile("Punk::SAML::_throw", XS_Punk__SAML__throw); |
| 1334 |
16 |
| newXS_deffile("Punk::SAML::_croak_sv_selftest", XS_Punk__SAML__croak_sv_selftest); |
| 1335 |
16 |
| newXS_deffile("Punk::SAML::_abi_versions", XS_Punk__SAML__abi_versions); |
| 1336 |
16 |
| newXS_deffile("Punk::SAML::_abi_needs", XS_Punk__SAML__abi_needs); |
| 1337 |
16 |
| newXS_deffile("Punk::Plugin::SAML::import", XS_Punk__Plugin__SAML_import); |
| 1338 |
16 |
| newXS_deffile("Punk::Plugin::SAML::new", XS_Punk__Plugin__SAML_new); |
| 1339 |
16 |
| newXS_deffile("Punk::Plugin::SAML::register", XS_Punk__Plugin__SAML_register); |
| 1340 |
16 |
| newXS_deffile("Punk::Plugin::SAML::_refetch_idp", XS_Punk__Plugin__SAML__refetch_idp); |
| 1341 |
16 |
| newXS_deffile("Punk::Plugin::SAML::_state", XS_Punk__Plugin__SAML__state); |
| 1342 |
16 |
| newXS_deffile("Punk::SAML::Request::new_id", XS_Punk__SAML__Request_new_id); |
| 1343 |
16 |
| newXS_deffile("Punk::SAML::Request::build", XS_Punk__SAML__Request_build); |
| 1344 |
16 |
| newXS_deffile("Punk::SAML::Request::redirect_url", XS_Punk__SAML__Request_redirect_url); |
| 1345 |
16 |
| newXS_deffile("Punk::SAML::_urlenc", XS_Punk__SAML__urlenc); |
| 1346 |
16 |
| newXS_deffile("Punk::SAML::_deflate_b64", XS_Punk__SAML__deflate_b64); |
| 1347 |
16 |
| newXS_deffile("Punk::SAML::_signed_string", XS_Punk__SAML__signed_string); |
| 1348 |
16 |
| newXS_deffile("Punk::SAML::_decode_field", XS_Punk__SAML__decode_field); |
| 1349 |
16 |
| newXS_deffile("Punk::SAML::_verify_bytes", XS_Punk__SAML__verify_bytes); |
| 1350 |
16 |
| cv = newXS_deffile("Punk::SAML::Response::_verify_field", XS_Punk__SAML__Response_verify); |
| 1351 |
16 |
| XSANY.any_i32 = 1; |
| 1352 |
16 |
| cv = newXS_deffile("Punk::SAML::Response::verify", XS_Punk__SAML__Response_verify); |
| 1353 |
16 |
| XSANY.any_i32 = 0; |
| 1354 |
16 |
| newXS_deffile("Punk::SAML::Response::_replayed", XS_Punk__SAML__Response__replayed); |
| 1355 |
16 |
| newXS_deffile("Punk::SAML::_sign_bytes", XS_Punk__SAML__sign_bytes); |
| 1356 |
16 |
| newXS_deffile("Punk::SAML::IdP::read", XS_Punk__SAML__IdP_read); |
| 1357 |
16 |
| newXS_deffile("Punk::SAML::Metadata::build", XS_Punk__SAML__Metadata_build); |
| 1358 |
16 |
| newXS_deffile("Punk::SAML::Metadata::sign", XS_Punk__SAML__Metadata_sign); |
| 1359 |
16 |
| newXS_deffile("Punk::SAML::Metadata::content_type", XS_Punk__SAML__Metadata_content_type); |
| 1360 |
16 |
| newXS_deffile("Punk::SAML::_verify_document", XS_Punk__SAML__verify_document); |
| 1361 |
16 |
| newXS_deffile("Punk::SAML::_flow_serialise", XS_Punk__SAML__flow_serialise); |
| 1362 |
16 |
| newXS_deffile("Punk::SAML::_flow_parse", XS_Punk__SAML__flow_parse); |
| 1363 |
16 |
| newXS_deffile("Punk::SAML::_flow_cookie", XS_Punk__SAML__flow_cookie); |
| 1364 |
|
| } |
| 1365 |
|
| #if PERL_VERSION_LE(5, 21, 5) |
| 1366 |
|
| # if PERL_VERSION_GE(5, 9, 0) |
| 1367 |
|
| if (PL_unitcheckav) |
| 1368 |
|
| call_list(PL_scopestack_ix, PL_unitcheckav); |
| 1369 |
|
| # endif |
| 1370 |
|
| XSRETURN_YES; |
| 1371 |
|
| #else |
| 1372 |
16 |
| Perl_xs_boot_epilog(aTHX_ ax); |
| 1373 |
|
| #endif |
| 1374 |
16 |
| } |
| 1375 |
|
| |
| 1376 |
|
| #ifdef __cplusplus |
| 1377 |
|
| } |
| 1378 |
|
| #endif |