/*
 * This file was generated automatically by ExtUtils::ParseXS version 3.30 from the
 * contents of ECDSA.xs. Do not edit this file, edit ECDSA.xs instead.
 *
 *    ANY CHANGES MADE HERE WILL BE LOST!
 *
 */

#line 1 "ECDSA.xs"
#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"

#include "ppport.h"

#include <openssl/ecdsa.h>
#include <openssl/err.h>

#include "const-c.inc"

#line 23 "ECDSA.c"
#ifndef PERL_UNUSED_VAR
#  define PERL_UNUSED_VAR(var) if (0) var = var
#endif

#ifndef dVAR
#  define dVAR		dNOOP
#endif


/* This stuff is not part of the API! You have been warned. */
#ifndef PERL_VERSION_DECIMAL
#  define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
#endif
#ifndef PERL_DECIMAL_VERSION
#  define PERL_DECIMAL_VERSION \
	  PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
#endif
#ifndef PERL_VERSION_GE
#  define PERL_VERSION_GE(r,v,s) \
	  (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
#endif
#ifndef PERL_VERSION_LE
#  define PERL_VERSION_LE(r,v,s) \
	  (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
#endif

/* XS_INTERNAL is the explicit static-linkage variant of the default
 * XS macro.
 *
 * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
 * "STATIC", ie. it exports XSUB symbols. You probably don't want that
 * for anything but the BOOT XSUB.
 *
 * See XSUB.h in core!
 */


/* TODO: This might be compatible further back than 5.10.0. */
#if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
#  undef XS_EXTERNAL
#  undef XS_INTERNAL
#  if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
#    define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
#    define XS_INTERNAL(name) STATIC XSPROTO(name)
#  endif
#  if defined(__SYMBIAN32__)
#    define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
#    define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
#  endif
#  ifndef XS_EXTERNAL
#    if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
#      define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
#      define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
#    else
#      ifdef __cplusplus
#        define XS_EXTERNAL(name) extern "C" XSPROTO(name)
#        define XS_INTERNAL(name) static XSPROTO(name)
#      else
#        define XS_EXTERNAL(name) XSPROTO(name)
#        define XS_INTERNAL(name) STATIC XSPROTO(name)
#      endif
#    endif
#  endif
#endif

/* perl >= 5.10.0 && perl <= 5.15.1 */


/* The XS_EXTERNAL macro is used for functions that must not be static
 * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
 * macro defined, the best we can do is assume XS is the same.
 * Dito for XS_INTERNAL.
 */
#ifndef XS_EXTERNAL
#  define XS_EXTERNAL(name) XS(name)
#endif
#ifndef XS_INTERNAL
#  define XS_INTERNAL(name) XS(name)
#endif

/* Now, finally, after all this mess, we want an ExtUtils::ParseXS
 * internal macro that we're free to redefine for varying linkage due
 * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
 * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
 */

#undef XS_EUPXS
#if defined(PERL_EUPXS_ALWAYS_EXPORT)
#  define XS_EUPXS(name) XS_EXTERNAL(name)
#else
   /* default to internal */
#  define XS_EUPXS(name) XS_INTERNAL(name)
#endif

#ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
#define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)

/* prototype to pass -Wmissing-prototypes */
STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params);

STATIC void
S_croak_xs_usage(const CV *const cv, const char *const params)
{
    const GV *const gv = CvGV(cv);

    PERL_ARGS_ASSERT_CROAK_XS_USAGE;

    if (gv) {
        const char *const gvname = GvNAME(gv);
        const HV *const stash = GvSTASH(gv);
        const char *const hvname = stash ? HvNAME(stash) : NULL;

        if (hvname)
	    Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
        else
	    Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
    } else {
        /* Pants. I don't think that it should be possible to get here. */
	Perl_croak_nocontext("Usage: CODE(0x%"UVxf")(%s)", PTR2UV(cv), params);
    }
}
#undef  PERL_ARGS_ASSERT_CROAK_XS_USAGE

#define croak_xs_usage        S_croak_xs_usage

#endif

/* NOTE: the prototype of newXSproto() is different in versions of perls,
 * so we define a portable version of newXSproto()
 */
#ifdef newXS_flags
#define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
#else
#define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
#endif /* !defined(newXS_flags) */

#if PERL_VERSION_LE(5, 21, 5)
#  define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
#else
#  define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
#endif

#line 167 "ECDSA.c"

/* INCLUDE:  Including 'const-xs.inc' from 'ECDSA.xs' */


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_constant); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_constant)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "sv");
    PERL_UNUSED_VAR(ax); /* -Wall */
    SP -= items;
    {
#line 4 "./const-xs.inc"
#ifdef dXSTARG
	dXSTARG; /* Faster if we have it.  */
#else
	dTARGET;
#endif
	STRLEN		len;
        int		type;
	IV		iv;
	/* NV		nv;	Uncomment this if you need to return NVs */
	/* const char	*pv;	Uncomment this if you need to return PVs */
#line 192 "ECDSA.c"
	SV *	sv = ST(0)
;
	const char *	s = SvPV(sv, len);
#line 18 "./const-xs.inc"
        /* Change this to constant(aTHX_ s, len, &iv, &nv);
           if you need to return both NVs and IVs */
	type = constant(aTHX_ s, len, &iv);
      /* Return 1 or 2 items. First is error message, or undef if no error.
           Second, if present, is found value */
        switch (type) {
        case PERL_constant_NOTFOUND:
          sv =
	    sv_2mortal(newSVpvf("%s is not a valid Crypt::OpenSSL::ECDSA macro", s));
          PUSHs(sv);
          break;
        case PERL_constant_NOTDEF:
          sv = sv_2mortal(newSVpvf(
	    "Your vendor has not defined Crypt::OpenSSL::ECDSA macro %s, used",
				   s));
          PUSHs(sv);
          break;
        case PERL_constant_ISIV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHi(iv);
          break;
	/* Uncomment this if you need to return NOs
        case PERL_constant_ISNO:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHs(&PL_sv_no);
          break; */
	/* Uncomment this if you need to return NVs
        case PERL_constant_ISNV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHn(nv);
          break; */
	/* Uncomment this if you need to return PVs
        case PERL_constant_ISPV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHp(pv, strlen(pv));
          break; */
	/* Uncomment this if you need to return PVNs
        case PERL_constant_ISPVN:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHp(pv, iv);
          break; */
	/* Uncomment this if you need to return SVs
        case PERL_constant_ISSV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHs(sv);
          break; */
	/* Uncomment this if you need to return UNDEFs
        case PERL_constant_ISUNDEF:
          break; */
	/* Uncomment this if you need to return UVs
        case PERL_constant_ISUV:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHu((UV)iv);
          break; */
	/* Uncomment this if you need to return YESs
        case PERL_constant_ISYES:
          EXTEND(SP, 1);
          PUSHs(&PL_sv_undef);
          PUSHs(&PL_sv_yes);
          break; */
        default:
          sv = sv_2mortal(newSVpvf(
	    "Unexpected return type %d while processing Crypt::OpenSSL::ECDSA macro %s, used",
               type, s));
          PUSHs(sv);
        }
#line 270 "ECDSA.c"
	PUTBACK;
	return;
    }
}


/* INCLUDE: Returning to 'ECDSA.xs' from 'const-xs.inc' */


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_do_sign); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_do_sign)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "dgst, eckey");
    {
#line 37 "ECDSA.xs"
                STRLEN dgst_len;
#line 289 "ECDSA.c"
	ECDSA_SIG *	RETVAL;
	const unsigned char *	dgst = (const unsigned char *)SvPV_nolen(ST(0))
;
	EC_KEY *	eckey;

    if( ! SvROK( ST(1) ) ) { croak( "argument is not an object" ); }
    eckey = (EC_KEY *) SvIV( SvRV( ST(1) ) )
;
#line 39 "ECDSA.xs"
                dgst = (const unsigned char *)SvPV(ST(0), dgst_len);
                RETVAL = ECDSA_do_sign(dgst, dgst_len, eckey);
#line 301 "ECDSA.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setsv(RETVALSV, sv_2mortal(sv_bless(newRV_noinc( newSViv( (IV)RETVAL ) ), gv_stashpv("Crypt::OpenSSL::ECDSA::ECDSA_SIG",1))));
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_do_sign_ex); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_do_sign_ex)
{
    dVAR; dXSARGS;
    if (items != 4)
       croak_xs_usage(cv,  "dgst, kinv, rp, eckey");
    {
#line 47 "ECDSA.xs"
                STRLEN dgst_len;
#line 322 "ECDSA.c"
	ECDSA_SIG *	RETVAL;
	const unsigned char *	dgst = (const unsigned char *)SvPV_nolen(ST(0))
;
	const BIGNUM *	kinv;
	const BIGNUM *	rp;
	EC_KEY *	eckey;

    if( ! SvROK( ST(1) ) ) { croak( "argument is not an object" ); }
    kinv = (const BIGNUM *) SvIV( SvRV( ST(1) ) )
;

    if( ! SvROK( ST(2) ) ) { croak( "argument is not an object" ); }
    rp = (const BIGNUM *) SvIV( SvRV( ST(2) ) )
;

    if( ! SvROK( ST(3) ) ) { croak( "argument is not an object" ); }
    eckey = (EC_KEY *) SvIV( SvRV( ST(3) ) )
;
#line 49 "ECDSA.xs"
                dgst = (const unsigned char *)SvPV(ST(0), dgst_len);
                RETVAL = ECDSA_do_sign_ex(dgst, dgst_len, kinv, rp, eckey);
#line 344 "ECDSA.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setsv(RETVALSV, sv_2mortal(sv_bless(newRV_noinc( newSViv( (IV)RETVAL ) ), gv_stashpv("Crypt::OpenSSL::ECDSA::ECDSA_SIG",1))));
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_do_verify); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_do_verify)
{
    dVAR; dXSARGS;
    if (items != 3)
       croak_xs_usage(cv,  "dgst, sig, eckey");
    {
#line 57 "ECDSA.xs"
                STRLEN dgst_len;
#line 365 "ECDSA.c"
	int	RETVAL;
	dXSTARG;
	const unsigned char *	dgst = (const unsigned char *)SvPV_nolen(ST(0))
;
	const ECDSA_SIG *	sig;
	EC_KEY*	eckey;

    if( ! SvROK( ST(1) ) ) { croak( "argument is not an object" ); }
    sig = (const ECDSA_SIG *) SvIV( SvRV( ST(1) ) )
;

    if( ! SvROK( ST(2) ) ) { croak( "argument is not an object" ); }
    eckey = (EC_KEY *) SvIV( SvRV( ST(2) ) )
;
#line 59 "ECDSA.xs"
                dgst = (const unsigned char *)SvPV(ST(0), dgst_len);
                RETVAL = ECDSA_do_verify(dgst, dgst_len, sig, eckey);
#line 383 "ECDSA.c"
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#if OPENSSL_VERSION_NUMBER >= 0x10002000L
#define XSubPPtmpAAAA 1


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_OpenSSL); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_OpenSSL)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	const ECDSA_METHOD *	RETVAL;

	RETVAL = ECDSA_OpenSSL();
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, Nullch, (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_set_default_method); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_set_default_method)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "meth");
    {
	const ECDSA_METHOD *	meth;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    meth = INT2PTR(const ECDSA_METHOD *,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"Crypt::OpenSSL::ECDSA::ECDSA_set_default_method",
			"meth")
;

	ECDSA_set_default_method(meth);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_get_default_method); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_get_default_method)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	const ECDSA_METHOD *	RETVAL;

	RETVAL = ECDSA_get_default_method();
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, Nullch, (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_set_method); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_set_method)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "eckey, meth");
    {
	int	RETVAL;
	dXSTARG;
	EC_KEY *	eckey;
	const ECDSA_METHOD *	meth;

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    eckey = (EC_KEY *) SvIV( SvRV( ST(0) ) )
;

	if (SvROK(ST(1))) {
	    IV tmp = SvIV((SV*)SvRV(ST(1)));
	    meth = INT2PTR(const ECDSA_METHOD *,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"Crypt::OpenSSL::ECDSA::ECDSA_set_method",
			"meth")
;

	RETVAL = ECDSA_set_method(eckey, meth);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_size); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_size)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "eckey");
    {
	int	RETVAL;
	dXSTARG;
	const EC_KEY *	eckey;

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    eckey = (const EC_KEY *) SvIV( SvRV( ST(0) ) )
;

	RETVAL = ECDSA_size(eckey);
	XSprePUSH; PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_new); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_new)
{
    dVAR; dXSARGS;
    if (items < 0 || items > 1)
       croak_xs_usage(cv,  "ecdsa_method=0");
    {
	ECDSA_METHOD *	RETVAL;
	ECDSA_METHOD *	ecdsa_method;

	if (items < 1)
	    ecdsa_method = 0;
	else {
	    if (SvROK(ST(0))) {
		IV tmp = SvIV((SV*)SvRV(ST(0)));
		ecdsa_method = INT2PTR(ECDSA_METHOD *,tmp);
	    }
	    else
		Perl_croak_nocontext("%s: %s is not a reference",
			    "Crypt::OpenSSL::ECDSA::ECDSA_METHOD_new",
			    "ecdsa_method")
;
	}

	RETVAL = ECDSA_METHOD_new(ecdsa_method);
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setref_pv(RETVALSV, Nullch, (void*)RETVAL);
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_free); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_free)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "ecdsa_method");
    {
	ECDSA_METHOD *	ecdsa_method;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    ecdsa_method = INT2PTR(ECDSA_METHOD *,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"Crypt::OpenSSL::ECDSA::ECDSA_METHOD_free",
			"ecdsa_method")
;

	ECDSA_METHOD_free(ecdsa_method);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_set_flags); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_set_flags)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ecdsa_method, flags");
    {
	ECDSA_METHOD *	ecdsa_method;
	int	flags = (int)SvIV(ST(1))
;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    ecdsa_method = INT2PTR(ECDSA_METHOD *,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"Crypt::OpenSSL::ECDSA::ECDSA_METHOD_set_flags",
			"ecdsa_method")
;

	ECDSA_METHOD_set_flags(ecdsa_method, flags);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_set_name); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_set_name)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ecdsa_method, name");
    {
	ECDSA_METHOD *	ecdsa_method;
	char *	name = (char *)SvPV_nolen(ST(1))
;

	if (SvROK(ST(0))) {
	    IV tmp = SvIV((SV*)SvRV(ST(0)));
	    ecdsa_method = INT2PTR(ECDSA_METHOD *,tmp);
	}
	else
	    Perl_croak_nocontext("%s: %s is not a reference",
			"Crypt::OpenSSL::ECDSA::ECDSA_METHOD_set_name",
			"ecdsa_method")
;

	ECDSA_METHOD_set_name(ecdsa_method, name);
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ERR_load_ECDSA_strings); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ERR_load_ECDSA_strings)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {

	ERR_load_ECDSA_strings();
    }
    XSRETURN_EMPTY;
}

#endif

XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ERR_get_error); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ERR_get_error)
{
    dVAR; dXSARGS;
    if (items != 0)
       croak_xs_usage(cv,  "");
    {
	unsigned long	RETVAL;
	dXSTARG;

	RETVAL = ERR_get_error();
	XSprePUSH; PUSHu((UV)RETVAL);
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ERR_error_string); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA_ERR_error_string)
{
    dVAR; dXSARGS;
    if (items < 1 || items > 2)
       croak_xs_usage(cv,  "error, buf=NULL");
    {
	unsigned long	error = (unsigned long)SvUV(ST(0))
;
	char *	buf;
	char *	RETVAL;
	dXSTARG;

	if (items < 2)
	    buf = NULL;
	else {
	    buf = (char *)SvPV_nolen(ST(1))
;
	}
#line 112 "ECDSA.xs"
     RETVAL = ERR_error_string(error,buf);
#line 683 "ECDSA.c"
	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_new); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_new)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "CLASS");
    {
	char *	CLASS = (char *)SvPV_nolen(ST(0))
;
	ECDSA_SIG *	RETVAL;
#line 123 "ECDSA.xs"
	CLASS = CLASS; /* prevent unused warnings */
        RETVAL = ECDSA_SIG_new();
#line 703 "ECDSA.c"
	{
	    SV * RETVALSV;
	    RETVALSV = sv_newmortal();
	    sv_setsv(RETVALSV, sv_2mortal(sv_bless(newRV_noinc( newSViv( (IV)RETVAL ) ), gv_stashpv("Crypt::OpenSSL::ECDSA::ECDSA_SIG",1))));
	    ST(0) = RETVALSV;
	}
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_DESTROY); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_DESTROY)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "ecdsa_sig");
    {
	ECDSA_SIG *	ecdsa_sig;

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 132 "ECDSA.xs"
        ECDSA_SIG_free(ecdsa_sig);
#line 729 "ECDSA.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_get_r); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_get_r)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "ecdsa_sig");
    {
	ECDSA_SIG *	ecdsa_sig;
#line 138 "ECDSA.xs"
        unsigned char *to;
        STRLEN len;
#line 746 "ECDSA.c"
	SV *	RETVAL;

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 141 "ECDSA.xs"
        to = malloc(sizeof(char) * 128);
        len = BN_bn2bin(ecdsa_sig->r, to);
        RETVAL = newSVpvn((const char*)to, len);
        free(to);
#line 757 "ECDSA.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_get_s); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_get_s)
{
    dVAR; dXSARGS;
    if (items != 1)
       croak_xs_usage(cv,  "ecdsa_sig");
    {
	ECDSA_SIG *	ecdsa_sig;
#line 152 "ECDSA.xs"
        unsigned char *to;
        STRLEN len;
#line 776 "ECDSA.c"
	SV *	RETVAL;

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 155 "ECDSA.xs"
        to = malloc(sizeof(char) * 128);
        len = BN_bn2bin(ecdsa_sig->s, to);
        RETVAL = newSVpvn((const char*)to, len);
        free(to);
#line 787 "ECDSA.c"
	RETVAL = sv_2mortal(RETVAL);
	ST(0) = RETVAL;
    }
    XSRETURN(1);
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_set_r); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_set_r)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ecdsa_sig, r_SV");
    {
	ECDSA_SIG *	ecdsa_sig;
	SV *	r_SV = ST(1)
;
#line 167 "ECDSA.xs"
	char *s;
        STRLEN len;
#line 808 "ECDSA.c"

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 170 "ECDSA.xs"
        s = SvPV(r_SV, len);
        if (ecdsa_sig->r)
            BN_free(ecdsa_sig->r);
        ecdsa_sig->r = BN_bin2bn((const unsigned char *)s, len, NULL);
#line 818 "ECDSA.c"
    }
    XSRETURN_EMPTY;
}


XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_set_s); /* prototype to pass -Wmissing-prototypes */
XS_EUPXS(XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_set_s)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "ecdsa_sig, s_SV");
    {
	ECDSA_SIG *	ecdsa_sig;
	SV *	s_SV = ST(1)
;
#line 180 "ECDSA.xs"
	char *s;
        STRLEN len;
#line 837 "ECDSA.c"

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 183 "ECDSA.xs"
        s = SvPV(s_SV, len);
        if (ecdsa_sig->s)
            BN_free(ecdsa_sig->s);
        ecdsa_sig->s = BN_bin2bn((const unsigned char *)s, len, NULL);
#line 847 "ECDSA.c"
    }
    XSRETURN_EMPTY;
}

#ifdef __cplusplus
extern "C"
#endif
XS_EXTERNAL(boot_Crypt__OpenSSL__ECDSA); /* prototype to pass -Wmissing-prototypes */
XS_EXTERNAL(boot_Crypt__OpenSSL__ECDSA)
{
#if PERL_VERSION_LE(5, 21, 5)
    dVAR; dXSARGS;
#else
    dVAR; dXSBOOTARGSXSAPIVERCHK;
#endif
#if (PERL_REVISION == 5 && PERL_VERSION < 9)
    char* file = __FILE__;
#else
    const char* file = __FILE__;
#endif

    PERL_UNUSED_VAR(file);

    PERL_UNUSED_VAR(cv); /* -W */
    PERL_UNUSED_VAR(items); /* -W */
#if PERL_VERSION_LE(5, 21, 5)
    XS_VERSION_BOOTCHECK;
#  ifdef XS_APIVERSION_BOOTCHECK
    XS_APIVERSION_BOOTCHECK;
#  endif
#endif

        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::constant", XS_Crypt__OpenSSL__ECDSA_constant, file, "$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_do_sign", XS_Crypt__OpenSSL__ECDSA_ECDSA_do_sign, file, "$$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_do_sign_ex", XS_Crypt__OpenSSL__ECDSA_ECDSA_do_sign_ex, file, "$$$$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_do_verify", XS_Crypt__OpenSSL__ECDSA_ECDSA_do_verify, file, "$$$");
#if XSubPPtmpAAAA
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_OpenSSL", XS_Crypt__OpenSSL__ECDSA_ECDSA_OpenSSL, file, "");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_set_default_method", XS_Crypt__OpenSSL__ECDSA_ECDSA_set_default_method, file, "$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_get_default_method", XS_Crypt__OpenSSL__ECDSA_ECDSA_get_default_method, file, "");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_set_method", XS_Crypt__OpenSSL__ECDSA_ECDSA_set_method, file, "$$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_size", XS_Crypt__OpenSSL__ECDSA_ECDSA_size, file, "$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_METHOD_new", XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_new, file, ";$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_METHOD_free", XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_free, file, "$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_METHOD_set_flags", XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_set_flags, file, "$$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_METHOD_set_name", XS_Crypt__OpenSSL__ECDSA_ECDSA_METHOD_set_name, file, "$$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ERR_load_ECDSA_strings", XS_Crypt__OpenSSL__ECDSA_ERR_load_ECDSA_strings, file, "");
#endif
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ERR_get_error", XS_Crypt__OpenSSL__ECDSA_ERR_get_error, file, "");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ERR_error_string", XS_Crypt__OpenSSL__ECDSA_ERR_error_string, file, "$;$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_SIG::new", XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_new, file, "$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_SIG::DESTROY", XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_DESTROY, file, "$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_SIG::get_r", XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_get_r, file, "$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_SIG::get_s", XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_get_s, file, "$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_SIG::set_r", XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_set_r, file, "$$");
        (void)newXSproto_portable("Crypt::OpenSSL::ECDSA::ECDSA_SIG::set_s", XS_Crypt__OpenSSL__ECDSA__ECDSA_SIG_set_s, file, "$$");

    /* Initialisation Section */

#line 19 "ECDSA.xs"
    ERR_load_crypto_strings();
    ERR_load_ECDSA_strings();

#if XSubPPtmpAAAA
#endif
#line 913 "ECDSA.c"

    /* End of Initialisation Section */

#if PERL_VERSION_LE(5, 21, 5)
#  if PERL_VERSION_GE(5, 9, 0)
    if (PL_unitcheckav)
        call_list(PL_scopestack_ix, PL_unitcheckav);
#  endif
    XSRETURN_YES;
#else
    Perl_xs_boot_epilog(aTHX_ ax);
#endif
}

