/*
 * This file was generated automatically by ExtUtils::ParseXS version 3.51 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 <openssl/bn.h>

#include "const-c.inc"


#if OPENSSL_VERSION_NUMBER >= 0x10100000L
#include <openssl/ec.h>
#else
/* ECDSA_SIG_get0() and ECDSA_SIG_set0() copied from OpenSSL 1.1.0b. */
static void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr,
    const BIGNUM **ps) {
    if (pr != NULL)
        *pr = sig->r;
    if (ps != NULL)
        *ps = sig->s;
}

static int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s)
{
    if (r == NULL || s == NULL)
        return 0;
    BN_clear_free(sig->r);
    BN_clear_free(sig->s);
    sig->r = r;
    sig->s = s;
    return 1;
}
#endif

#line 49 "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 193 "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 = 0; /* avoid uninit var warning */
	/* NV		nv;	Uncomment this if you need to return NVs */
	/* const char	*pv;	Uncomment this if you need to return PVs */
#line 218 "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, 2);
          PUSHs(&PL_sv_undef);
          PUSHi(iv);
          break;
	/* Uncomment this if you need to return NOs
        case PERL_constant_ISNO:
          EXTEND(SP, 2);
          PUSHs(&PL_sv_undef);
          PUSHs(&PL_sv_no);
          break; */
	/* Uncomment this if you need to return NVs
        case PERL_constant_ISNV:
          EXTEND(SP, 2);
          PUSHs(&PL_sv_undef);
          PUSHn(nv);
          break; */
	/* Uncomment this if you need to return PVs
        case PERL_constant_ISPV:
          EXTEND(SP, 2);
          PUSHs(&PL_sv_undef);
          PUSHp(pv, strlen(pv));
          break; */
	/* Uncomment this if you need to return PVNs
        case PERL_constant_ISPVN:
          EXTEND(SP, 2);
          PUSHs(&PL_sv_undef);
          PUSHp(pv, iv);
          break; */
	/* Uncomment this if you need to return SVs
        case PERL_constant_ISSV:
          EXTEND(SP, 2);
          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, 2);
          PUSHs(&PL_sv_undef);
          PUSHu((UV)iv);
          break; */
	/* Uncomment this if you need to return YESs
        case PERL_constant_ISYES:
          EXTEND(SP, 2);
          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 296 "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 65 "ECDSA.xs"
                STRLEN dgst_len;
#line 315 "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 67 "ECDSA.xs"
                dgst = (const unsigned char *)SvPV(ST(0), dgst_len);
                RETVAL = ECDSA_do_sign(dgst, dgst_len, eckey);
#line 327 "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 75 "ECDSA.xs"
                STRLEN dgst_len;
#line 348 "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 77 "ECDSA.xs"
                dgst = (const unsigned char *)SvPV(ST(0), dgst_len);
                RETVAL = ECDSA_do_sign_ex(dgst, dgst_len, kinv, rp, eckey);
#line 370 "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 85 "ECDSA.xs"
                STRLEN dgst_len;
#line 391 "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 87 "ECDSA.xs"
                dgst = (const unsigned char *)SvPV(ST(0), dgst_len);
                RETVAL = ECDSA_do_verify(dgst, dgst_len, sig, eckey);
#line 409 "ECDSA.c"
	XSprePUSH;
	PUSHi((IV)RETVAL);
    }
    XSRETURN(1);
}

#if OPENSSL_VERSION_NUMBER >= 0x10002000L
#define XSubPPtmpAAAA 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);
}

#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define XSubPPtmpAAAB 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_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
#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 143 "ECDSA.xs"
     RETVAL = ERR_error_string(error,buf);
#line 717 "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 154 "ECDSA.xs"
	CLASS = CLASS; /* prevent unused warnings */
        RETVAL = ECDSA_SIG_new();
#line 739 "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 163 "ECDSA.xs"
        ECDSA_SIG_free(ecdsa_sig);
#line 765 "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 169 "ECDSA.xs"
        const BIGNUM *r;
        unsigned char *to;
        STRLEN len;
        int bnlen;
#line 784 "ECDSA.c"
	SV *	RETVAL;

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 174 "ECDSA.xs"
        ECDSA_SIG_get0(ecdsa_sig, &r, NULL);
        bnlen = BN_num_bytes(r);
        to = malloc(sizeof(char) * bnlen);
        len = BN_bn2bin(r, to);
        RETVAL = newSVpvn((const char*)to, len);
        free(to);
#line 797 "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 187 "ECDSA.xs"
        const BIGNUM *s;
        unsigned char *to;
        STRLEN len;
        int bnlen;
#line 818 "ECDSA.c"
	SV *	RETVAL;

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 192 "ECDSA.xs"
        ECDSA_SIG_get0(ecdsa_sig, NULL, &s);
        bnlen = BN_num_bytes(s);
        to = malloc(sizeof(char) * bnlen);
        len = BN_bn2bin(s, to);
        RETVAL = newSVpvn((const char*)to, len);
        free(to);
#line 831 "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 206 "ECDSA.xs"
	    char *string;
        STRLEN len;
        BIGNUM *r;
        BIGNUM *s;
        const BIGNUM *old_s;
#line 855 "ECDSA.c"

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 212 "ECDSA.xs"
        string = SvPV(r_SV, len);
        r = BN_bin2bn((const unsigned char *)string, len, NULL);
        if (NULL == r)
            croak("Could not convert ECDSA parameter string to big number");
        ECDSA_SIG_get0(ecdsa_sig, NULL, &old_s);
        if (NULL == old_s) {
            s = BN_new();
        } else {
            s = BN_dup(old_s);
        }
        if (NULL == s) {
            BN_free(r);
            croak("Could not duplicate unchanged ECDSA parameter");
        }
        if (!ECDSA_SIG_set0(ecdsa_sig, r, s)) {
            BN_free(r);
            BN_free(s);
            croak("Could not store ECDSA parameters");
        }
#line 880 "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 237 "ECDSA.xs"
	    char *string;
        STRLEN len;
        BIGNUM *r;
        BIGNUM *s;
        const BIGNUM *old_r;
#line 902 "ECDSA.c"

    if( ! SvROK( ST(0) ) ) { croak( "argument is not an object" ); }
    ecdsa_sig = (ECDSA_SIG *) SvIV( SvRV( ST(0) ) )
;
#line 243 "ECDSA.xs"
        string = SvPV(s_SV, len);
        s = BN_bin2bn((const unsigned char *)string, len, NULL);
        if (NULL == s)
            croak("Could not convert ECDSA parameter string to big number");
        ECDSA_SIG_get0(ecdsa_sig, &old_r, NULL);
        if (NULL == old_r) {
            r = BN_new();
        } else {
            r = BN_dup(old_r);
        }
        if (NULL == r) {
            BN_free(s);
            croak("Could not duplicate unchanged ECDSA parameter");
        }
        if (!ECDSA_SIG_set0(ecdsa_sig, r, s)) {
            BN_free(r);
            BN_free(s);
            croak("Could not store ECDSA parameters");
        }
#line 927 "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_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
    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_size", XS_Crypt__OpenSSL__ECDSA_ECDSA_size, file, "$");
#if XSubPPtmpAAAB
        (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_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
#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 45 "ECDSA.xs"
    ERR_load_crypto_strings();
#if OPENSSL_VERSION_NUMBER >= 0x10002000L && OPENSSL_VERSION_NUMBER < 0x10100000L
    ERR_load_ECDSA_strings();
#endif

#if XSubPPtmpAAAA
#if XSubPPtmpAAAB
#endif
#endif
#line 999 "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
}

#ifdef __cplusplus
}
#endif
