/* Generated from "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod" by precompile.pike running Pike v8.0 release 1109
 *
 * Do NOT edit this file.
 */

#undef PRECOMPILE_API_VERSION
#define PRECOMPILE_API_VERSION 6

#undef PRECOMPILE_SUB_PIKEVARS
#define PRECOMPILE_SUB_PIKEVARS 1

#undef PRECOMPILE_DYNAMIC_TYPES
#define PRECOMPILE_DYNAMIC_TYPES 1



#undef cmod___CMOD__
#define cmod___CMOD__ 1
#line 1 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#line 1 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#line 1 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#line 3003 "/Users/hww3/devel/pike/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"







#line 3010 "/Users/hww3/devel/pike/lib/modules/Tools.pmod/Standalone.pmod/precompile.pike"
#line 1 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#line 1 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
/* -*- c -*-
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
*/

#include "global.h"
#include "builtin_functions.h"
#include "operators.h"
#include "interpret.h"
#include "module.h"

#include "nettle_config.h"

#ifdef HAVE_LIBHOGWEED



#ifndef PIKE_UNUSED_ATTRIBUTE
#define PIKE_UNUSED_ATTRIBUTE
#endif
#define CMOD_MAP_PROGRAM_IDS_DEFINED 1
static int ___cmod_map_program_ids(int id) PIKE_UNUSED_ATTRIBUTE;
#ifndef TYPEOF
/* Compat with older Pikes. */
#define TYPEOF(SVAL)	((SVAL).type)
#define SUBTYPEOF(SVAL)	((SVAL).subtype)
#define SET_SVAL_TYPE(SVAL, TYPE)	(TYPEOF(SVAL) = TYPE)
#define SET_SVAL_SUBTYPE(SVAL, TYPE)	(SUBTYPEOF(SVAL) = TYPE)
#define SET_SVAL(SVAL, TYPE, SUBTYPE, FIELD, EXPR) do {	\
    /* Set the type afterwards to avoid a clobbered	\
     * svalue in case EXPR throws. */			\
    (SVAL).u.FIELD = (EXPR);				\
    SET_SVAL_TYPE((SVAL), (TYPE));			\
    SET_SVAL_SUBTYPE((SVAL), (SUBTYPE));		\
  } while(0)
#endif /* !TYPEOF */
#ifndef PIKE_UNUSED
/* Compat with Pike 7.8 and earlier. */
/* NB: Not strictly correct; PIKE_UNUSED was added the
 *     day after set_program_id_to_id(), but good enough.
 */
#ifndef UNUSED
#define UNUSED(X)	X
#endif
#ifndef set_program_id_to_id
/* NB: Recent Pike 7.8 has a #define that conflicts with
 *     the following declaration.
 */
static void set_program_id_to_id(void*UNUSED(id)){}
#endif
#else /* */
PMOD_EXPORT void set_program_id_to_id( int (*to)(int) );
#endif /* !PIKE_UNUSED */


#ifndef DEFAULT_CMOD_STORAGE
#define CMOD_COND_USED
#define DEFAULT_CMOD_STORAGE static
#endif
#define module_strings_declared
static struct pike_string *module_strings[13] = {
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
  NULL,
};
static struct { INT32 from;INT32 to; } ___cmod_ext_used[1];
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_name_fun_num_used 1
#else
#define f_Nettle_ECC_Curve_name_fun_num_used 1
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_size_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_size_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define Nettle_ECC_Curve_Point_program_fun_num_used 1
#else
#define Nettle_ECC_Curve_Point_program_fun_num_used 1
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_Point_get_x_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_Point_get_x_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_DH_Params_generate_fun_num_used 1
#else
#undef f_Nettle_DH_Params_generate_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_Point_get_y_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_Point_get_y_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_set_public_key_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_set_public_key_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_get_private_key_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_get_private_key_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_DH_Params_cq__backtickg_eq_fun_num_used 1
#else
#undef f_Nettle_DH_Params_cq__backtickg_eq_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_DH_Params_cq__backtickq_eq_fun_num_used 1
#else
#undef f_Nettle_DH_Params_cq__backtickq_eq_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_DH_Params_cq__backtickg_fun_num_used 1
#else
#undef f_Nettle_DH_Params_cq__backtickg_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_DH_Params_cq__backtickq_fun_num_used 1
#else
#undef f_Nettle_DH_Params_cq__backtickq_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_get_x_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_get_x_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_DH_Params_cq__backtickp_fun_num_used 1
#else
#undef f_Nettle_DH_Params_cq__backtickp_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_Point_cq__backtick_2A_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_Point_cq__backtick_2A_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_DH_Params_cq__backtickp_eq_fun_num_used 1
#else
#undef f_Nettle_DH_Params_cq__backtickp_eq_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_DH_Params_generate_keypair_fun_num_used 1
#else
#undef f_Nettle_DH_Params_generate_keypair_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_Point_set_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_Point_set_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_Point_name_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_Point_name_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_Point_get_curve_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_Point_get_curve_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define Nettle_DH_Params_program_fun_num_used 1
#else
#undef Nettle_DH_Params_program_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_get_curve_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_get_curve_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_set_private_key_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_set_private_key_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_get_y_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_get_y_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_name_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_name_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define Nettle_ECC_Curve_ECDSA_program_fun_num_used 1
#else
#undef Nettle_ECC_Curve_ECDSA_program_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_generate_key_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_generate_key_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_raw_sign_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_raw_sign_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_set_random_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_set_random_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_ECDSA_raw_verify_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_ECDSA_raw_verify_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_create_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_create_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_cq__backtick_2A_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_cq__backtick_2A_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_new_scalar_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_new_scalar_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_dsa_generate_keypair_fun_num_used 1
#else
#undef f_Nettle_dsa_generate_keypair_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_ECC_Curve_point_mul_fun_num_used 1
#else
#undef f_Nettle_ECC_Curve_point_mul_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define Nettle_ECC_Curve_program_fun_num_used 1
#else
#undef Nettle_ECC_Curve_program_fun_num_used
#endif
#ifndef CMOD_COND_USED
# define f_Nettle_rsa_generate_keypair_fun_num_used 1
#else
#undef f_Nettle_rsa_generate_keypair_fun_num_used
#endif
#line 19 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#include "nettle.h"
#include <nettle/dsa.h>
#include <nettle/rsa.h>
#include <gmp.h>

#include "bignum.h"

/*! @module Nettle
 */

static void random_func_wrapper(void *f, pike_nettle_size_t num, uint8_t *out)
{
push_int(num);
apply_svalue((struct svalue *)f, 1);
if(TYPEOF(Pike_sp[-1])!=T_STRING)
Pike_error("Random function did not return string value.\n");
if((unsigned)Pike_sp[-1].u.string->len != (unsigned)num)
Pike_error("Random function did not return correct number of bytes.\n");
memcpy(out, Pike_sp[-1].u.string->str, num);
pop_stack();
}

/*! @decl array(object(Gmp.mpz)) @
 *!         dsa_generate_keypair(int p_bits, int q_bits, @
 *!                              function(int(0..):string(0..255)) rnd)
 *!
 *! Generates a DSA key pair with @[p_bits] number of bits (sometimes
 *! referred to as L) for p, and @[q_bits] number of bits (sometimes
 *! referred to as N) for q, using the random function @[rnd].
 *!
 *! Valid combinations as per FIPS 186-3 are
 *! @pre{
 *!   p_bits  q_bits
 *!   1024    160
 *!   2048    224 (rejected by some versions of Hogweed)
 *!   2048    256
 *!   3072    256
 *! @}
 *!
 *! @returns
 *!   @array
 *!     @elem Gmp.mpz 0
 *!       The value p, the modulo.
 *!     @elem Gmp.mpz 1
 *!       The value q, the group order.
 *!     @elem Gmp.mpz 2
 *!       The value g, the generator.
 *!     @elem Gmp.mpz 3
 *!       The value y, the public value.
 *!     @elem Gmp.mpz 4
 *!       The value x, the private value.
 *!   @endarray
 */
#define f_Nettle_dsa_generate_keypair_defined

#ifdef f_Nettle_dsa_generate_keypair_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_dsa_generate_keypair_fun_num = 0;

#endif /* f_Nettle_dsa_generate_keypair_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_dsa_generate_keypair(INT32 args) {
#line 73 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE p_bits;
#line 73 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE q_bits;
#line 73 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * rnd;
#line 72 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 3) wrong_number_of_args_error("dsa_generate_keypair",args,3);
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("dsa_generate_keypair",1,"int");
#line 73 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
p_bits=Pike_sp[0-3].u.integer;
#line 73 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("dsa_generate_keypair",2,"int");
#line 73 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
q_bits=Pike_sp[1-3].u.integer;
#line 73 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[2-3]) != PIKE_T_FUNCTION) SIMPLE_ARG_TYPE_ERROR("dsa_generate_keypair",3,"function(int(0..):string(0..255))");
#line 73 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
rnd=Pike_sp+2-3; dmalloc_touch_svalue(Pike_sp+2-3);
{
#ifdef dsa_params_init
 /* Nettle 3.0 or later. */
struct dsa_params params;
mpz_t pub;
mpz_t key;

dsa_params_init(&params);

if (!dsa_generate_params(&params, rnd, random_func_wrapper,
NULL, NULL, p_bits, q_bits)) {
dsa_params_clear(&params);
Pike_error("Illegal parameter value.\n");
}

mpz_init(pub);
mpz_init(key);

dsa_generate_keypair(&params, pub, key, rnd, random_func_wrapper);

push_bignum((MP_INT *)&params.p);
push_bignum((MP_INT *)&params.q);
push_bignum((MP_INT *)&params.g);

dsa_params_clear(&params);

push_bignum((MP_INT *)pub);
push_bignum((MP_INT *)key);

mpz_clear(key);
mpz_clear(pub);

#else
 struct dsa_public_key pub;
struct dsa_private_key key;

dsa_public_key_init(&pub);
dsa_private_key_init(&key);

if( !nettle_dsa_generate_keypair(&pub, &key, rnd, random_func_wrapper,
NULL, NULL, p_bits
#ifdef HAVE_DSA_QBITS_KEYPAIR_ARG
 , q_bits
#endif
 ) )
{
dsa_private_key_clear(&key);
dsa_public_key_clear(&pub);

Pike_error("Illegal parameter value.\n");
}

push_bignum((MP_INT *)&pub.p);
push_bignum((MP_INT *)&pub.q);
push_bignum((MP_INT *)&pub.g);
push_bignum((MP_INT *)&pub.y);
push_bignum((MP_INT *)&key.x);

dsa_private_key_clear(&key);
dsa_public_key_clear(&pub);
#endif /* dsa_params_init */

f_aggregate(5);
stack_pop_n_elems_keep_top(args); /* Remove p_bits, q_bits and rnd. */
}

}
/*! @decl array(object(Gmp.mpz)) @
 *!         rsa_generate_keypair(int bits, int e, @
 *!                              function(int(0..):string(0..255)) rnd)
 *!
 *! Generates an RSA key pair with a @[bits] sized modulus (n), using
 *! the provided value for @[e] and random function @[rnd].
 *!
 *! @returns
 *!   @array
 *!     @elem Gmp.mpz 0
 *!       The value n, the modulo.
 *!     @elem Gmp.mpz 1
 *!       The value d, the private exponent.
 *!     @elem Gmp.mpz 2
 *!       The value p, a prime.
 *!     @elem Gmp.mpz 3
 *!       The value q, a prime.
 *!   @endarray
 */
#define f_Nettle_rsa_generate_keypair_defined

#ifdef f_Nettle_rsa_generate_keypair_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_rsa_generate_keypair_fun_num = 0;

#endif /* f_Nettle_rsa_generate_keypair_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_rsa_generate_keypair(INT32 args) {
#line 160 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE bits;
#line 160 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE e;
#line 160 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * rnd;
#line 159 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 3) wrong_number_of_args_error("rsa_generate_keypair",args,3);
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("rsa_generate_keypair",1,"int");
#line 160 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
bits=Pike_sp[0-3].u.integer;
#line 160 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("rsa_generate_keypair",2,"int");
#line 160 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
e=Pike_sp[1-3].u.integer;
#line 160 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[2-3]) != PIKE_T_FUNCTION) SIMPLE_ARG_TYPE_ERROR("rsa_generate_keypair",3,"function(int(0..):string(0..255))");
#line 160 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
rnd=Pike_sp+2-3; dmalloc_touch_svalue(Pike_sp+2-3);
{
struct rsa_public_key pub;
struct rsa_private_key key;

rsa_public_key_init(&pub);
rsa_private_key_init(&key);

mpz_set_ui((MP_INT *)&pub.e, e);

if( !nettle_rsa_generate_keypair(&pub, &key, rnd, random_func_wrapper,
NULL, NULL, bits, 0) )
{
rsa_private_key_clear(&key);
rsa_public_key_clear(&pub);

Pike_error("Illegal parameter value.\n");
}

push_bignum((MP_INT *)&pub.n);
push_bignum((MP_INT *)&key.d);
push_bignum((MP_INT *)&key.p);
push_bignum((MP_INT *)&key.q);

rsa_private_key_clear(&key);
rsa_public_key_clear(&pub);

f_aggregate(4);
stack_pop_n_elems_keep_top(args); /* Remove bits, e and rnd. */
}

}
#line 191 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#ifdef dsa_params_init

/*! @class DH_Params
 *!
 *! Diffie-Hellman Parameters.
 */

#undef class_Nettle_DH_Params_defined
#define class_Nettle_DH_Params_defined
DEFAULT_CMOD_STORAGE struct program *Nettle_DH_Params_program=NULL;

#ifdef Nettle_DH_Params_program_fun_num_used
DEFAULT_CMOD_STORAGE int Nettle_DH_Params_program_fun_num=-1;
#endif /* Nettle_DH_Params_program_fun_num_used */

#undef var_params_Nettle_DH_Params_defined
#define var_params_Nettle_DH_Params_defined

#undef THIS
#define THIS ((struct Nettle_DH_Params_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_NETTLE_DH_PARAMS
#define THIS_NETTLE_DH_PARAMS ((struct Nettle_DH_Params_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_NETTLE_DH_PARAMS
#define OBJ2_NETTLE_DH_PARAMS(o) ((struct Nettle_DH_Params_struct *)(o->storage+Nettle_DH_Params_storage_offset))

#undef GET_NETTLE_DH_PARAMS_STORAGE
#define GET_NETTLE_DH_PARAMS_STORAGE(o) ((struct Nettle_DH_Params_struct *)(o->storage+Nettle_DH_Params_storage_offset)
static ptrdiff_t Nettle_DH_Params_storage_offset;
struct Nettle_DH_Params_struct {

#ifdef var_params_Nettle_DH_Params_defined
#line 200 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct dsa_params params;
#endif /* var_params_Nettle_DH_Params_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Nettle_DH_Params_struct *Nettle_DH_Params_gdb_dummy_ptr;
#endif

#undef internal_init_Nettle_DH_Params_defined
#define internal_init_Nettle_DH_Params_defined

#undef Nettle_DH_Params_event_handler_defined
#define Nettle_DH_Params_event_handler_defined
static void init_Nettle_DH_Params_struct(void)
#line 202 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
dsa_params_init(&THIS->params);
}


#undef Nettle_DH_Params_gc_live_obj
#define Nettle_DH_Params_gc_live_obj

#undef internal_exit_Nettle_DH_Params_defined
#define internal_exit_Nettle_DH_Params_defined

#undef Nettle_DH_Params_event_handler_defined
#define Nettle_DH_Params_event_handler_defined
static void exit_Nettle_DH_Params_struct(void)
#line 206 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
dsa_params_clear(&THIS->params);
}

/*! @decl Gmp.mpz p
   *!
   *! Prime.
   */

/*! @decl Gmp.mpz g
   *!
   *! Generator.
   */

/*! @decl Gmp.mpz q
   *!
   *! Order.
   */

#define f_Nettle_DH_Params_cq__backtickp_defined

#ifdef f_Nettle_DH_Params_cq__backtickp_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_DH_Params_cq__backtickp_fun_num = 0;

#endif /* f_Nettle_DH_Params_cq__backtickp_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_DH_Params_cq__backtickp(INT32 args) {
#line 225 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("`p",args,0);
{
push_bignum(THIS->params.p);
}

}
#define f_Nettle_DH_Params_cq__backtickp_eq_defined

#ifdef f_Nettle_DH_Params_cq__backtickp_eq_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_DH_Params_cq__backtickp_eq_fun_num = 0;

#endif /* f_Nettle_DH_Params_cq__backtickp_eq_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_DH_Params_cq__backtickp_eq(INT32 args) {
#line 230 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * p;
#line 230 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("`p=",args,1);
#line 230 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
p=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
convert_svalue_to_bignum(p);

mpz_from_svalue(THIS->params.p, p);
}

}
#define f_Nettle_DH_Params_cq__backtickg_defined

#ifdef f_Nettle_DH_Params_cq__backtickg_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_DH_Params_cq__backtickg_fun_num = 0;

#endif /* f_Nettle_DH_Params_cq__backtickg_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_DH_Params_cq__backtickg(INT32 args) {
#line 237 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("`g",args,0);
{
push_bignum(THIS->params.g);
}

}
#define f_Nettle_DH_Params_cq__backtickg_eq_defined

#ifdef f_Nettle_DH_Params_cq__backtickg_eq_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_DH_Params_cq__backtickg_eq_fun_num = 0;

#endif /* f_Nettle_DH_Params_cq__backtickg_eq_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_DH_Params_cq__backtickg_eq(INT32 args) {
#line 242 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * g;
#line 242 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("`g=",args,1);
#line 242 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
g=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
convert_svalue_to_bignum(g);

mpz_from_svalue(THIS->params.g, g);
}

}
#define f_Nettle_DH_Params_cq__backtickq_defined

#ifdef f_Nettle_DH_Params_cq__backtickq_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_DH_Params_cq__backtickq_fun_num = 0;

#endif /* f_Nettle_DH_Params_cq__backtickq_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_DH_Params_cq__backtickq(INT32 args) {
#line 249 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("`q",args,0);
{
push_bignum(THIS->params.q);
}

}
#define f_Nettle_DH_Params_cq__backtickq_eq_defined

#ifdef f_Nettle_DH_Params_cq__backtickq_eq_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_DH_Params_cq__backtickq_eq_fun_num = 0;

#endif /* f_Nettle_DH_Params_cq__backtickq_eq_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_DH_Params_cq__backtickq_eq(INT32 args) {
#line 254 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * q;
#line 254 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("`q=",args,1);
#line 254 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
q=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
convert_svalue_to_bignum(q);

mpz_from_svalue(THIS->params.q, q);
}

}
/*! @decl void generate(int p_bits, int q_bits, @
   *!                     function(int(0..):string(8bit)) rnd)
   *!
   *! Generate a new set of Diffie-Hellman parameters.
   *!
   *! @note
   *!   Throws errors for unsupported parameters.
   *!
   *! @note
   *!   This function is not available in all installations of Pike.
   */
#define f_Nettle_DH_Params_generate_defined

#ifdef f_Nettle_DH_Params_generate_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_DH_Params_generate_fun_num = 0;

#endif /* f_Nettle_DH_Params_generate_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_DH_Params_generate(INT32 args) {
#line 272 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE p_bits;
#line 272 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE q_bits;
struct svalue * rnd;
#line 272 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 3) wrong_number_of_args_error("generate",args,3);
#line 272 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("generate",1,"int");
#line 272 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
p_bits=Pike_sp[0-3].u.integer;
#line 272 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("generate",2,"int");
#line 272 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
q_bits=Pike_sp[1-3].u.integer;
if(TYPEOF(Pike_sp[2-3]) != PIKE_T_FUNCTION) SIMPLE_ARG_TYPE_ERROR("generate",3,"function(int(0..):string(0..255))");
#line 273 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
rnd=Pike_sp+2-3; dmalloc_touch_svalue(Pike_sp+2-3);
{
if (!dsa_generate_params(&THIS->params, rnd, random_func_wrapper,
NULL, NULL, p_bits, q_bits)) {
Pike_error("Illegal parameter value.\n");
}
pop_n_elems(args);
}

}
/*! @decl array(Gmp.mpz) generate_keypair(function(int(0..):string(8bit)) rnd)
   *!
   *! Generate a Diffie-Hellman key pair.
   *!
   *! @returns
   *!   Returns the following array:
   *!   @array
   *!     @elem Gmp.mpz 0
   *!       The generated public key.
   *!     @elem Gmp.mpz 1
   *!       The corresponding private key.
   *!   @endarray
   */
#define f_Nettle_DH_Params_generate_keypair_defined

#ifdef f_Nettle_DH_Params_generate_keypair_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_DH_Params_generate_keypair_fun_num = 0;

#endif /* f_Nettle_DH_Params_generate_keypair_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_DH_Params_generate_keypair(INT32 args) {
#line 295 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * rnd;
#line 295 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("generate_keypair",args,1);
#line 295 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_FUNCTION) SIMPLE_ARG_TYPE_ERROR("generate_keypair",1,"function(int(0..):string(0..255))");
#line 295 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
rnd=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
int psgn = mpz_sgn(THIS->params.p);
mpz_t pub;
mpz_t key;

if (!psgn) {
SIMPLE_DIVISION_BY_ZERO_ERROR("generate_keypair");
}
if (psgn < 0) {
Pike_error("The prime must be positive.\n");
}

mpz_init(pub);
mpz_init(key);

dsa_generate_keypair(&THIS->params, pub, key, rnd, random_func_wrapper);

push_bignum((MP_INT *)pub);
push_bignum((MP_INT *)key);

mpz_clear(key);
mpz_clear(pub);

f_aggregate(2);
}
}

#ifdef Nettle_DH_Params_event_handler_defined
static void Nettle_DH_Params_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Nettle_DH_Params_defined
  case PROG_EVENT_INIT: init_Nettle_DH_Params_struct(); break;

#endif /* internal_init_Nettle_DH_Params_defined */

#ifdef internal_exit_Nettle_DH_Params_defined
  case PROG_EVENT_EXIT: exit_Nettle_DH_Params_struct(); break;

#endif /* internal_exit_Nettle_DH_Params_defined */
  default: break; 
  }
}

#endif /* Nettle_DH_Params_event_handler_defined */
/*! @endclass
 */

#line 326 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#endif /* dsa_params_init */

#if defined(HAVE_NETTLE_ECDSA_H) && (defined(HAVE_CURVE_NETTLE_SECP_192R1) || defined(HAVE_CURVE_NETTLE_SECP_224R1) || defined(HAVE_CURVE_NETTLE_SECP_256R1) || defined(HAVE_CURVE_NETTLE_SECP_384R1) || defined(HAVE_CURVE_NETTLE_SECP_521R1))
#include <nettle/ecc-curve.h>

#include <nettle/ecc.h>

#include <nettle/ecdsa.h>

#ifdef NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_192R1
static const struct ecc_curve *nettle_get_secp_192r1(void) {
return &nettle_secp_192r1;
}
#endif /* NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_192R1 */
#ifdef NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_224R1
static const struct ecc_curve *nettle_get_secp_224r1(void) {
return &nettle_secp_224r1;
}
#endif /* NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_224R1 */
#ifdef NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_256R1
static const struct ecc_curve *nettle_get_secp_256r1(void) {
return &nettle_secp_256r1;
}
#endif /* NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_256R1 */
#ifdef NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_384R1
static const struct ecc_curve *nettle_get_secp_384r1(void) {
return &nettle_secp_384r1;
}
#endif /* NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_384R1 */
#ifdef NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_521R1
static const struct ecc_curve *nettle_get_secp_521r1(void) {
return &nettle_secp_521r1;
}
#endif /* NEED_WRAPPER_FOR_CURVE_NETTLE_SECP_521R1 */

/*! @class ECC_Curve
 *!
 *! Elliptic Curve Definition
 */

#undef class_Nettle_ECC_Curve_defined
#define class_Nettle_ECC_Curve_defined
DEFAULT_CMOD_STORAGE struct program *Nettle_ECC_Curve_program=NULL;

#ifdef Nettle_ECC_Curve_program_fun_num_used
DEFAULT_CMOD_STORAGE int Nettle_ECC_Curve_program_fun_num=-1;
#endif /* Nettle_ECC_Curve_program_fun_num_used */
/*! @decl inherit __builtin.Nettle.ECC_Curve
   */

#undef inherit_cq__22__builtin_2ENettle_2EECC_Curve_22_Nettle_ECC_Curve_defined
#define inherit_cq__22__builtin_2ENettle_2EECC_Curve_22_Nettle_ECC_Curve_defined
#line 369 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
static int Nettle_ECC_Curve_cq__22__builtin_2ENettle_2EECC_Curve_22_inh_num = -1;
#line 369 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
static int Nettle_ECC_Curve_cq__22__builtin_2ENettle_2EECC_Curve_22_inh_offset = -1;

#undef var_curve_Nettle_ECC_Curve_defined
#define var_curve_Nettle_ECC_Curve_defined

#undef var_field_size_Nettle_ECC_Curve_defined
#define var_field_size_Nettle_ECC_Curve_defined

#undef THIS
#define THIS ((struct Nettle_ECC_Curve_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_NETTLE_ECC_CURVE
#define THIS_NETTLE_ECC_CURVE ((struct Nettle_ECC_Curve_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_NETTLE_ECC_CURVE
#define OBJ2_NETTLE_ECC_CURVE(o) ((struct Nettle_ECC_Curve_struct *)(o->storage+Nettle_ECC_Curve_storage_offset))

#undef GET_NETTLE_ECC_CURVE_STORAGE
#define GET_NETTLE_ECC_CURVE_STORAGE(o) ((struct Nettle_ECC_Curve_struct *)(o->storage+Nettle_ECC_Curve_storage_offset)
static ptrdiff_t Nettle_ECC_Curve_storage_offset;
struct Nettle_ECC_Curve_struct {

#ifdef var_curve_Nettle_ECC_Curve_defined
#line 371 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
const struct ecc_curve *curve;
#endif /* var_curve_Nettle_ECC_Curve_defined */

#ifdef var_field_size_Nettle_ECC_Curve_defined
#line 372 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
int field_size;
#endif /* var_field_size_Nettle_ECC_Curve_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Nettle_ECC_Curve_struct *Nettle_ECC_Curve_gdb_dummy_ptr;
#endif
#line 374 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
;

/*! @decl void create(int(0..) family, int(0..) field_size, int(0..) revision)
   *!
   *! Initialize the curve.
   */
#define f_Nettle_ECC_Curve_create_defined

#ifdef f_Nettle_ECC_Curve_create_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_create_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_create_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_create(INT32 args) {
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE family;
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE field_size;
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
INT_TYPE revision;
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 3) wrong_number_of_args_error("create",args,3);
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("create",1,"int(0..)");
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
family=Pike_sp[0-3].u.integer;
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[1-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("create",2,"int(0..)");
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
field_size=Pike_sp[1-3].u.integer;
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[2-3]) != PIKE_T_INT) SIMPLE_ARG_TYPE_ERROR("create",3,"int(0..)");
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
revision=Pike_sp[2-3].u.integer;
#line 382 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
if (THIS->curve) {
Pike_error("The curve has already been initialized!\n");
}

switch(family) {
case 1:
if (revision != 1)
Pike_error("Unsupported revision.\n");
switch(field_size)
{
case 192:
#ifdef HAVE_CURVE_NETTLE_SECP_192R1
 THIS->curve = nettle_get_secp_192r1();
break;
#endif /* HAVE_CURVE_NETTLE_SECP_192R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_224R1
 case 224:
THIS->curve = nettle_get_secp_224r1();
break;
#endif /* HAVE_CURVE_NETTLE_SECP_224R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_256R1
 case 256:
THIS->curve = nettle_get_secp_256r1();
break;
#endif /* HAVE_CURVE_NETTLE_SECP_256R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_384R1
 case 384:
THIS->curve = nettle_get_secp_384r1();
break;
#endif /* HAVE_CURVE_NETTLE_SECP_384R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_521R1
 case 521:
THIS->curve = nettle_get_secp_521r1();
break;
#endif /* HAVE_CURVE_NETTLE_SECP_521R1 */
 default:
Pike_error("Invalid curve\n");
break;
}
break;
default:
Pike_error("Unknown curve family.\n");
break;
}
THIS->field_size = field_size;
}

}
/*! @decl string(7bit) name()
   *!
   *! Returns the name of the curve.
   */
#define f_Nettle_ECC_Curve_name_defined

#ifdef f_Nettle_ECC_Curve_name_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_name_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_name_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_name(INT32 args) {
#line 434 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("name",args,0);
{
#ifdef HAVE_CURVE_NETTLE_SECP_192R1
 if (THIS->curve == nettle_get_secp_192r1()) {
ref_push_string(module_strings[0] /* "SECP_192R1" */);
return;
}
#endif /* HAVE_CURVE_NETTLE_SECP_192R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_224R1
 if (THIS->curve == nettle_get_secp_224r1()) {
ref_push_string(module_strings[1] /* "SECP_224R1" */);
return;
}
#endif /* HAVE_CURVE_NETTLE_SECP_224R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_256R1
 if (THIS->curve == nettle_get_secp_256r1()) {
ref_push_string(module_strings[2] /* "SECP_256R1" */);
return;
}
#endif /* HAVE_CURVE_NETTLE_SECP_256R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_384R1
 if (THIS->curve == nettle_get_secp_384r1()) {
ref_push_string(module_strings[3] /* "SECP_384R1" */);
return;
}
#endif /* HAVE_CURVE_NETTLE_SECP_384R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_521R1
 if (THIS->curve == nettle_get_secp_521r1()) {
ref_push_string(module_strings[4] /* "SECP_521R1" */);
return;
}
#endif /* HAVE_CURVE_NETTLE_SECP_521R1 */
 ref_push_string(module_strings[5] /* "UNKNOWN" */);
}

}
/*! @decl int size()
   *!
   *! @returns
   *!   Returns the size in bits for a single coordinate on the curve.
   */
#define f_Nettle_ECC_Curve_size_defined

#ifdef f_Nettle_ECC_Curve_size_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_size_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_size_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_size(INT32 args) {
#line 474 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("size",args,0);
{
push_int(THIS->field_size);
}

}
/*! @decl Gmp.mpz new_scalar(function(int(0..):string(8bit)) rnd)
   *!
   *! @param rnd
   *!   Randomness function to use as source.
   *!
   *! @returns
   *!   Returns a random scalar suitable to use as an @[ECDSA] private key
   *!   or as an ECDH exponent.
   */
#define f_Nettle_ECC_Curve_new_scalar_defined

#ifdef f_Nettle_ECC_Curve_new_scalar_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_new_scalar_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_new_scalar_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_new_scalar(INT32 args) {
#line 488 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * rnd;
#line 488 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("new_scalar",args,1);
#line 488 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_FUNCTION) SIMPLE_ARG_TYPE_ERROR("new_scalar",1,"function(int(0..):string(0..255))");
#line 488 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
rnd=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
struct ecc_scalar s;
struct object *ret;

if (!THIS->curve) Pike_error("No curve defined.\n");

ecc_scalar_init(&s, THIS->curve);

ecc_scalar_random(&s, rnd, random_func_wrapper);

push_object(ret = fast_clone_object(get_auto_bignum_program()));
ecc_scalar_get(&s, (mpz_ptr)ret->storage);

ecc_scalar_clear(&s);
}

}
#line 505 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
static int Nettle_ECC_Curve_Point_program_fun_num;

/*! @decl Point `*(Gmp.mpz|int scalar)
   *!
   *! Multiply the curve by a scalar.
   *!
   *! This can be used to get the public key from a private key.
   *!
   *! @returns
   *!   Returns a new @[Point] on the curve.
   */
#define f_Nettle_ECC_Curve_cq__backtick_2A_defined

#ifdef f_Nettle_ECC_Curve_cq__backtick_2A_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_cq__backtick_2A_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_cq__backtick_2A_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_cq__backtick_2A(INT32 args) {
#line 516 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * scalar;
#line 516 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("`*",args,1);
#line 516 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
scalar=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
struct ecc_scalar s;
struct ecc_point r;
struct object *x;
struct object *y;

if (!THIS->curve) Pike_error("No curve defined.\n");

convert_svalue_to_bignum(scalar);

ecc_scalar_init(&s, THIS->curve);
ecc_point_init(&r, THIS->curve);

if (!ecc_scalar_set(&s, (mpz_srcptr)scalar->u.object->storage)) {
ecc_scalar_clear(&s);
ecc_point_clear(&r);
SIMPLE_ARG_ERROR("`*", 1, "Invalid scalar for curve.");
}

ecc_point_mul_g(&r, &s);
push_object(x = fast_clone_object(get_auto_bignum_program()));
push_object(y = fast_clone_object(get_auto_bignum_program()));
ecc_point_get(&r, (mpz_ptr)x->storage, (mpz_ptr)y->storage);

ecc_scalar_clear(&s);
ecc_point_clear(&r);

apply_current(Nettle_ECC_Curve_Point_program_fun_num, 2);
}

}
/*! @decl Point point_mul(Gmp.mpz|int x, Gmp.mpz|int y, @
   *!                       Gmp.mpz|int scalar)
   *!
   *! Multiply a point on the curve by a scalar.
   *!
   *! A typical use is for Elliptic Curve Diffie Hellman (ECDH) key exchange.
   *!
   *! This is equivalent to @expr{(Point(x, y) * scalar)@}.
   *!
   *! @returns
   *!   Returns the new @[Point] on the curve.
   *!
   *! @throws
   *!   Throws an error if the point (@[x], @[y]) isn't on the curve.
   */
#define f_Nettle_ECC_Curve_point_mul_defined

#ifdef f_Nettle_ECC_Curve_point_mul_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_point_mul_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_point_mul_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_point_mul(INT32 args) {
#line 562 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * x;
struct svalue * y;
struct svalue * scalar;
#line 562 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 3) wrong_number_of_args_error("point_mul",args,3);
#line 562 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
x=Pike_sp+0-3; dmalloc_touch_svalue(Pike_sp+0-3);
y=Pike_sp+1-3; dmalloc_touch_svalue(Pike_sp+1-3);
scalar=Pike_sp+2-3; dmalloc_touch_svalue(Pike_sp+2-3);
{
struct ecc_point p;
struct ecc_scalar s;
struct ecc_point r;
struct object *rx;
struct object *ry;

if (!THIS->curve) Pike_error("No curve defined.\n");

convert_svalue_to_bignum(x);
convert_svalue_to_bignum(y);
convert_svalue_to_bignum(scalar);

ecc_point_init(&p, THIS->curve);
ecc_scalar_init(&s, THIS->curve);

if (!ecc_point_set(&p,
(mpz_srcptr)x->u.object->storage,
(mpz_srcptr)y->u.object->storage)) {
ecc_scalar_clear(&s);
ecc_point_clear(&p);
SIMPLE_ARG_ERROR("point_mul", 1, "Invalid point on curve.");
}

if (!ecc_scalar_set(&s, (mpz_srcptr)scalar->u.object->storage)) {
ecc_scalar_clear(&s);
ecc_point_clear(&p);
SIMPLE_ARG_ERROR("point_mul", 3, "Invalid scalar for curve.");
}

ecc_point_init(&r, THIS->curve);

ecc_point_mul(&r, &s, &p);

push_object(rx = fast_clone_object(get_auto_bignum_program()));
push_object(ry = fast_clone_object(get_auto_bignum_program()));
ecc_point_get(&r, (mpz_ptr)rx->storage, (mpz_ptr)ry->storage);

ecc_point_clear(&r);
ecc_scalar_clear(&s);
ecc_point_clear(&p);

apply_current(Nettle_ECC_Curve_Point_program_fun_num, 2);
stack_pop_n_elems_keep_top(args);
}

}
/*! @class Point
   *!
   *! A point on an elliptic curve.
   */

#undef class_Nettle_ECC_Curve_Point_defined
#define class_Nettle_ECC_Curve_Point_defined
DEFAULT_CMOD_STORAGE struct program *Nettle_ECC_Curve_Point_program=NULL;

#ifdef Nettle_ECC_Curve_Point_program_fun_num_used
DEFAULT_CMOD_STORAGE int Nettle_ECC_Curve_Point_program_fun_num=-1;
#endif /* Nettle_ECC_Curve_Point_program_fun_num_used */

#undef var_point_Nettle_ECC_Curve_Point_defined
#define var_point_Nettle_ECC_Curve_Point_defined

#undef THIS
#define THIS ((struct Nettle_ECC_Curve_Point_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_NETTLE_ECC_CURVE_POINT
#define THIS_NETTLE_ECC_CURVE_POINT ((struct Nettle_ECC_Curve_Point_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_NETTLE_ECC_CURVE_POINT
#define OBJ2_NETTLE_ECC_CURVE_POINT(o) ((struct Nettle_ECC_Curve_Point_struct *)(o->storage+Nettle_ECC_Curve_Point_storage_offset))

#undef GET_NETTLE_ECC_CURVE_POINT_STORAGE
#define GET_NETTLE_ECC_CURVE_POINT_STORAGE(o) ((struct Nettle_ECC_Curve_Point_struct *)(o->storage+Nettle_ECC_Curve_Point_storage_offset)
static ptrdiff_t Nettle_ECC_Curve_Point_storage_offset;
struct Nettle_ECC_Curve_Point_struct {

#ifdef var_point_Nettle_ECC_Curve_Point_defined
#line 618 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct ecc_point point;
#endif /* var_point_Nettle_ECC_Curve_Point_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Nettle_ECC_Curve_Point_struct *Nettle_ECC_Curve_Point_gdb_dummy_ptr;
#endif
/*! @decl inherit ECC_Curve::Point
     */

#undef extra_Nettle_ECC_Curve_Point_defined
#define extra_Nettle_ECC_Curve_Point_defined

#undef internal_init_Nettle_ECC_Curve_Point_defined
#define internal_init_Nettle_ECC_Curve_Point_defined

#undef Nettle_ECC_Curve_Point_event_handler_defined
#define Nettle_ECC_Curve_Point_event_handler_defined
static void init_Nettle_ECC_Curve_Point_struct(void)
#line 648 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
const struct ecc_curve *curve =
(((const struct Nettle_ECC_Curve_struct *)parent_storage(1, Nettle_ECC_Curve_program))->curve);
if (!curve) Pike_error("No curve selected.\n");
ecc_point_init(&THIS->point, curve);
}


#undef Nettle_ECC_Curve_Point_gc_live_obj
#define Nettle_ECC_Curve_Point_gc_live_obj

#undef internal_exit_Nettle_ECC_Curve_Point_defined
#define internal_exit_Nettle_ECC_Curve_Point_defined

#undef Nettle_ECC_Curve_Point_event_handler_defined
#define Nettle_ECC_Curve_Point_event_handler_defined
static void exit_Nettle_ECC_Curve_Point_struct(void)
#line 656 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
const struct ecc_curve *curve =
(((const struct Nettle_ECC_Curve_struct *)parent_storage(1, Nettle_ECC_Curve_program))->curve);
if (!curve) return;
ecc_point_clear(&THIS->point);
}

/*! @decl string(7bit) name()
     *!
     *! Returns the string @expr{"Point"@} followed by
     *! the parenthesized name of the curve.
     */
#define f_Nettle_ECC_Curve_Point_name_defined

#ifdef f_Nettle_ECC_Curve_Point_name_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_Point_name_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_Point_name_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_Point_name(INT32 args) {
#line 668 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("name",args,0);
{
ref_push_string(module_strings[7] /* "Point(" */);
apply_external(1, f_Nettle_ECC_Curve_name_fun_num, 0);
ref_push_string(module_strings[8] /* ")" */);
f_add(3);
}

}
/*! @decl ECC_Curve get_curve()
     *!
     *! Get the elliptic curve that is in use.
     */
#define f_Nettle_ECC_Curve_Point_get_curve_defined

#ifdef f_Nettle_ECC_Curve_Point_get_curve_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_Point_get_curve_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_Point_get_curve_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_Point_get_curve(INT32 args) {
#line 680 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("get_curve",args,0);
{
struct external_variable_context loc;
loc.o = Pike_fp->current_object;
loc.inherit = Pike_fp->context;
find_external_context(&loc, 1);
ref_push_object_inherit(loc.o, loc.inherit - loc.o->prog->inherits);
}

}
/*! @decl object(Gmp.mpz) get_x()
     *!
     *! Get the x coordinate of the point.
     *!
     *! @seealso
     *!   @[get_y()]
     */
#define f_Nettle_ECC_Curve_Point_get_x_defined

#ifdef f_Nettle_ECC_Curve_Point_get_x_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_Point_get_x_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_Point_get_x_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_Point_get_x(INT32 args) {
#line 696 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("get_x",args,0);
{
struct object *ret;
push_object(ret = fast_clone_object(get_auto_bignum_program()));
ecc_point_get(&THIS->point, (mpz_ptr)ret->storage, NULL);
}

}
/*! @decl object(Gmp.mpz) get_y()
     *!
     *! Get the y coordinate of the point.
     *!
     *! @seealso
     *!   @[get_x()]
     */
#define f_Nettle_ECC_Curve_Point_get_y_defined

#ifdef f_Nettle_ECC_Curve_Point_get_y_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_Point_get_y_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_Point_get_y_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_Point_get_y(INT32 args) {
#line 710 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("get_y",args,0);
{
struct object *ret;
push_object(ret = fast_clone_object(get_auto_bignum_program()));
ecc_point_get(&THIS->point, NULL, (mpz_ptr)ret->storage);
}

}
/*! @decl void set(object(Gmp.mpz)|int x, object(Gmp.mpz)|int y)
     *!
     *! Change to the selected point on the curve.
     *!
     *! @note
     *!   Throws errors if the point isn't on the curve.
     */
#define f_Nettle_ECC_Curve_Point_set_defined

#ifdef f_Nettle_ECC_Curve_Point_set_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_Point_set_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_Point_set_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_Point_set(INT32 args) {
#line 724 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * x;
#line 724 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * y;
#line 724 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 2) wrong_number_of_args_error("set",args,2);
#line 724 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
x=Pike_sp+0-2; dmalloc_touch_svalue(Pike_sp+0-2);
#line 724 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
y=Pike_sp+1-2; dmalloc_touch_svalue(Pike_sp+1-2);
{
convert_svalue_to_bignum(x);
convert_svalue_to_bignum(y);
if (!ecc_point_set(&THIS->point,
(mpz_srcptr)x->u.object->storage,
(mpz_srcptr)y->u.object->storage)) {
SIMPLE_ARG_ERROR("set", 1, "Invalid point on curve.");
}
}

}
/*! @decl Point `*(Gmp.mpz|int scalar)
     *!
     *! Multiply the point on the curve by a scalar.
     *!
     *! A typical use is for Elliptic Curve Diffie Hellman (ECDH) key exchange.
     *!
     *! @returns
     *!   Returns the new point on the curve.
     */
#define f_Nettle_ECC_Curve_Point_cq__backtick_2A_defined

#ifdef f_Nettle_ECC_Curve_Point_cq__backtick_2A_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_Point_cq__backtick_2A_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_Point_cq__backtick_2A_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_Point_cq__backtick_2A(INT32 args) {
#line 744 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * scalar;
#line 744 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("`*",args,1);
#line 744 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
scalar=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
#line 746 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
struct ecc_scalar s;
struct ecc_point r;
struct object *rx;
struct object *ry;
const struct ecc_curve *curve =
(((const struct Nettle_ECC_Curve_struct *)parent_storage(1, Nettle_ECC_Curve_program))->curve);

if (!curve) Pike_error("No curve defined.\n");

convert_svalue_to_bignum(scalar);

ecc_scalar_init(&s, curve);

if (!ecc_scalar_set(&s, (mpz_srcptr)scalar->u.object->storage)) {
ecc_scalar_clear(&s);
SIMPLE_ARG_ERROR("`*", 1, "Invalid scalar for curve.");
}

ecc_point_init(&r, curve);

ecc_point_mul(&r, &s, &THIS->point);

push_object(rx = fast_clone_object(get_auto_bignum_program()));
push_object(ry = fast_clone_object(get_auto_bignum_program()));
ecc_point_get(&r, (mpz_ptr)rx->storage, (mpz_ptr)ry->storage);

ecc_point_clear(&r);
ecc_scalar_clear(&s);

apply_external(1, Nettle_ECC_Curve_Point_program_fun_num, 2);
}
}

#ifdef Nettle_ECC_Curve_Point_event_handler_defined
static void Nettle_ECC_Curve_Point_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Nettle_ECC_Curve_Point_defined
  case PROG_EVENT_INIT: init_Nettle_ECC_Curve_Point_struct(); break;

#endif /* internal_init_Nettle_ECC_Curve_Point_defined */

#ifdef internal_exit_Nettle_ECC_Curve_Point_defined
  case PROG_EVENT_EXIT: exit_Nettle_ECC_Curve_Point_struct(); break;

#endif /* internal_exit_Nettle_ECC_Curve_Point_defined */
  default: break; 
  }
}

#endif /* Nettle_ECC_Curve_Point_event_handler_defined */
/*! @endclass Point
   */

/*! @class ECDSA
   *!
   *! Elliptic Curve Digital Signing Algorithm
   */

#undef class_Nettle_ECC_Curve_ECDSA_defined
#define class_Nettle_ECC_Curve_ECDSA_defined
DEFAULT_CMOD_STORAGE struct program *Nettle_ECC_Curve_ECDSA_program=NULL;

#ifdef Nettle_ECC_Curve_ECDSA_program_fun_num_used
DEFAULT_CMOD_STORAGE int Nettle_ECC_Curve_ECDSA_program_fun_num=-1;
#endif /* Nettle_ECC_Curve_ECDSA_program_fun_num_used */
/*! @decl inherit __builtin.Nettle.Sign
     */

#undef inherit_cq__22__builtin_2ENettle_2ESign_22_Nettle_ECC_Curve_ECDSA_defined
#define inherit_cq__22__builtin_2ENettle_2ESign_22_Nettle_ECC_Curve_ECDSA_defined
#line 791 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
static int Nettle_ECC_Curve_ECDSA_cq__22__builtin_2ENettle_2ESign_22_inh_num = -1;
#line 791 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
static int Nettle_ECC_Curve_ECDSA_cq__22__builtin_2ENettle_2ESign_22_inh_offset = -1;

#undef var_key_Nettle_ECC_Curve_ECDSA_defined
#define var_key_Nettle_ECC_Curve_ECDSA_defined

#undef var_pub_Nettle_ECC_Curve_ECDSA_defined
#define var_pub_Nettle_ECC_Curve_ECDSA_defined

#undef var_random_Nettle_ECC_Curve_ECDSA_defined
#define var_random_Nettle_ECC_Curve_ECDSA_defined

#undef THIS
#define THIS ((struct Nettle_ECC_Curve_ECDSA_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef THIS_NETTLE_ECC_CURVE_ECDSA
#define THIS_NETTLE_ECC_CURVE_ECDSA ((struct Nettle_ECC_Curve_ECDSA_struct *)(Pike_interpreter.frame_pointer->current_storage))

#undef OBJ2_NETTLE_ECC_CURVE_ECDSA
#define OBJ2_NETTLE_ECC_CURVE_ECDSA(o) ((struct Nettle_ECC_Curve_ECDSA_struct *)(o->storage+Nettle_ECC_Curve_ECDSA_storage_offset))

#undef GET_NETTLE_ECC_CURVE_ECDSA_STORAGE
#define GET_NETTLE_ECC_CURVE_ECDSA_STORAGE(o) ((struct Nettle_ECC_Curve_ECDSA_struct *)(o->storage+Nettle_ECC_Curve_ECDSA_storage_offset)
static ptrdiff_t Nettle_ECC_Curve_ECDSA_storage_offset;
struct Nettle_ECC_Curve_ECDSA_struct {

#ifdef var_key_Nettle_ECC_Curve_ECDSA_defined
#line 793 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct ecc_scalar key;
#endif /* var_key_Nettle_ECC_Curve_ECDSA_defined */

#ifdef var_pub_Nettle_ECC_Curve_ECDSA_defined
#line 794 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct ecc_point pub;
#endif /* var_pub_Nettle_ECC_Curve_ECDSA_defined */

#ifdef var_random_Nettle_ECC_Curve_ECDSA_defined
  struct svalue random;

#endif /* var_random_Nettle_ECC_Curve_ECDSA_defined */
};
#ifdef PIKE_DEBUG
/* Ensure the struct is used in a variable declaration, or else gdb might not see it. */
static struct Nettle_ECC_Curve_ECDSA_struct *Nettle_ECC_Curve_ECDSA_gdb_dummy_ptr;
#endif

#undef internal_init_Nettle_ECC_Curve_ECDSA_defined
#define internal_init_Nettle_ECC_Curve_ECDSA_defined

#undef Nettle_ECC_Curve_ECDSA_event_handler_defined
#define Nettle_ECC_Curve_ECDSA_event_handler_defined
static void init_Nettle_ECC_Curve_ECDSA_struct(void)
#line 800 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
const struct ecc_curve *curve =
(((const struct Nettle_ECC_Curve_struct *)parent_storage(1, Nettle_ECC_Curve_program))->curve);
if (!curve) Pike_error("No curve selected.\n");
ecc_point_init(&THIS->pub, curve);
ecc_scalar_init(&THIS->key, curve);
push_constant_text("Crypto.Random.random_string");
APPLY_MASTER("resolv",1);
assign_svalue(&THIS->random, Pike_sp-1);
pop_stack();
}


#undef Nettle_ECC_Curve_ECDSA_gc_live_obj
#define Nettle_ECC_Curve_ECDSA_gc_live_obj

#undef internal_exit_Nettle_ECC_Curve_ECDSA_defined
#define internal_exit_Nettle_ECC_Curve_ECDSA_defined

#undef Nettle_ECC_Curve_ECDSA_event_handler_defined
#define Nettle_ECC_Curve_ECDSA_event_handler_defined
static void exit_Nettle_ECC_Curve_ECDSA_struct(void)
#line 813 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
const struct ecc_curve *curve =
(((const struct Nettle_ECC_Curve_struct *)parent_storage(1, Nettle_ECC_Curve_program))->curve);
if (!curve) return;
ecc_point_clear(&THIS->pub);
ecc_scalar_clear(&THIS->key);
}

/*! @decl string(7bit) name()
     *!
     *! Returns the string @expr{"ECDSA"@} followed by
     *! the parenthesized name of the curve.
     */
#define f_Nettle_ECC_Curve_ECDSA_name_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_name_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_name_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_name_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_name(INT32 args) {
#line 826 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("name",args,0);
{
ref_push_string(module_strings[9] /* "ECDSA(" */);
apply_external(1, f_Nettle_ECC_Curve_name_fun_num, 0);
ref_push_string(module_strings[8] /* ")" */);
f_add(3);
}

}
/*! @decl ECC_Curve get_curve()
     *!
     *! Get the elliptic curve that is in use.
     */
#define f_Nettle_ECC_Curve_ECDSA_get_curve_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_get_curve_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_get_curve_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_get_curve_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_get_curve(INT32 args) {
#line 838 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("get_curve",args,0);
{
struct external_variable_context loc;
loc.o = Pike_fp->current_object;
loc.inherit = Pike_fp->context;
find_external_context(&loc, 1);
ref_push_object_inherit(loc.o, loc.inherit - loc.o->prog->inherits);
}

}
/*! @decl Gmp.mpz get_private_key()
     *!
     *! Get the private key.
     */
#define f_Nettle_ECC_Curve_ECDSA_get_private_key_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_get_private_key_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_get_private_key_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_get_private_key_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_get_private_key(INT32 args) {
#line 851 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("get_private_key",args,0);
{
struct object *ret;
push_object(ret = fast_clone_object(get_auto_bignum_program()));
ecc_scalar_get(&THIS->key, (mpz_ptr)ret->storage);
}

}
/*! @decl void set_private_key(object(Gmp.mpz)|int k)
     *!
     *! Set the private key (and corresponding private key).
     *!
     *! @note
     *!   Throws errors if the key isn't valid for the curve.
     */
#define f_Nettle_ECC_Curve_ECDSA_set_private_key_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_set_private_key_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_set_private_key_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_set_private_key_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_set_private_key(INT32 args) {
#line 865 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * k;
#line 865 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("set_private_key",args,1);
#line 865 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
k=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
convert_svalue_to_bignum(k);
if (!ecc_scalar_set(&THIS->key, (mpz_srcptr)k->u.object->storage)) {
SIMPLE_ARG_ERROR("set_private_key", 1, "Invalid key for curve.");
}
/* Set the corresponding public key, */
ecc_point_mul_g(&THIS->pub, &THIS->key);
}

}
/*! @decl object(Gmp.mpz) get_x()
     *!
     *! Get the x coordinate of the public key.
     *!
     *! @seealso
     *!   @[get_y()]
     */
#define f_Nettle_ECC_Curve_ECDSA_get_x_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_get_x_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_get_x_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_get_x_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_get_x(INT32 args) {
#line 882 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("get_x",args,0);
{
struct object *ret;
push_object(ret = fast_clone_object(get_auto_bignum_program()));
ecc_point_get(&THIS->pub, (mpz_ptr)ret->storage, NULL);
}

}
/*! @decl object(Gmp.mpz) get_y()
     *!
     *! Get the y coordinate of the public key.
     *!
     *! @seealso
     *!   @[get_x()]
     */
#define f_Nettle_ECC_Curve_ECDSA_get_y_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_get_y_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_get_y_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_get_y_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_get_y(INT32 args) {
#line 896 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("get_y",args,0);
{
struct object *ret;
push_object(ret = fast_clone_object(get_auto_bignum_program()));
ecc_point_get(&THIS->pub, NULL, (mpz_ptr)ret->storage);
}

}
/*! @decl void set_public_key(object(Gmp.mpz)|int x, object(Gmp.mpz)|int y)
     *!
     *! Change to the selected point on the curve as public key.
     *!
     *! @note
     *!   Throws errors if the point isn't on the curve.
     */
#define f_Nettle_ECC_Curve_ECDSA_set_public_key_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_set_public_key_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_set_public_key_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_set_public_key_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_set_public_key(INT32 args) {
#line 910 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * x;
#line 910 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * y;
#line 910 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 2) wrong_number_of_args_error("set_public_key",args,2);
#line 910 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
x=Pike_sp+0-2; dmalloc_touch_svalue(Pike_sp+0-2);
#line 910 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
y=Pike_sp+1-2; dmalloc_touch_svalue(Pike_sp+1-2);
{
convert_svalue_to_bignum(x);
convert_svalue_to_bignum(y);
if (!ecc_point_set(&THIS->pub,
(mpz_srcptr)x->u.object->storage,
(mpz_srcptr)y->u.object->storage)) {
SIMPLE_ARG_ERROR("set_point", 1, "Invalid point on curve.");
}
}

}
/*! @decl void set_random(function(int(0..):string(8bit)) r)
     *!
     *! Set the random function, used to generate keys and parameters,
     *! to the function @[r].
     */
#define f_Nettle_ECC_Curve_ECDSA_set_random_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_set_random_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_set_random_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_set_random_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_set_random(INT32 args) {
#line 926 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct svalue * r;
#line 926 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("set_random",args,1);
#line 926 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_FUNCTION) SIMPLE_ARG_TYPE_ERROR("set_random",1,"function(int(0..):string(0..255))");
#line 926 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
r=Pike_sp+0-1; dmalloc_touch_svalue(Pike_sp+0-1);
{
assign_svalue(&THIS->random, r);
}

}
/*! @decl int(0..1) raw_verify(string(8bit) digest, @
     *!                            object(Gmp.mpz) r, @
     *!                            object(Gmp.mpz) s)
     *!
     *! Verify the signature @[r], @[s] against the message digest @[digest].
     */
#define f_Nettle_ECC_Curve_ECDSA_raw_verify_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_raw_verify_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_raw_verify_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_raw_verify_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_raw_verify(INT32 args) {
#line 937 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct pike_string * digest;
struct svalue * r;
struct svalue * s;
#line 937 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 3) wrong_number_of_args_error("raw_verify",args,3);
#line 937 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[0-3]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("raw_verify",1,"string(0..255)");
#line 937 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
debug_malloc_pass(digest=Pike_sp[0-3].u.string);
r=Pike_sp+1-3; dmalloc_touch_svalue(Pike_sp+1-3);
s=Pike_sp+2-3; dmalloc_touch_svalue(Pike_sp+2-3);
{
struct dsa_signature sig;
int ret;

NO_WIDE_STRING(digest);

dsa_signature_init(&sig);

if (!mpz_from_svalue((MP_INT *)&sig.r, r)) {
dsa_signature_clear(&sig);
SIMPLE_ARG_TYPE_ERROR("raw_verify", 1, "Gmp.mpz|int");
}
if (!mpz_from_svalue((MP_INT *)&sig.s, s)) {
dsa_signature_clear(&sig);
SIMPLE_ARG_TYPE_ERROR("raw_verify", 2, "Gmp.mpz|int");
}

ret = ecdsa_verify(&THIS->pub, digest->len, STR0(digest), &sig);
dsa_signature_clear(&sig);

do { INT_TYPE ret_=(ret); pop_n_elems(3); push_int(ret_); return; }while(0);
#line 961 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
}

}
/*! @decl array(Gmp.mpz) raw_sign(string(8bit) digest)
     *!
     *! Sign the message digest @[digest]. Returns the signature
     *! as two @[Gmp.mpz] objects.
     */
#define f_Nettle_ECC_Curve_ECDSA_raw_sign_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_raw_sign_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_raw_sign_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_raw_sign_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_raw_sign(INT32 args) {
#line 968 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
struct pike_string * digest;
#line 968 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 1) wrong_number_of_args_error("raw_sign",args,1);
#line 968 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(TYPEOF(Pike_sp[0-1]) != PIKE_T_STRING) SIMPLE_ARG_TYPE_ERROR("raw_sign",1,"string(0..255)");
#line 968 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
debug_malloc_pass(digest=Pike_sp[0-1].u.string);
{
struct dsa_signature sig;
struct object *r, *s;

NO_WIDE_STRING(digest);

dsa_signature_init(&sig);

ecdsa_sign(&THIS->key, &THIS->random, random_func_wrapper,
digest->len, STR0(digest), &sig);

push_bignum((MP_INT *)&sig.r);
push_bignum((MP_INT *)&sig.s);

dsa_signature_clear(&sig);

f_aggregate(2);
stack_pop_n_elems_keep_top(args);
}

}
/*! @decl void generate_key()
     *!
     *! Generate a new set of private and public keys on the current curve.
     */
#define f_Nettle_ECC_Curve_ECDSA_generate_key_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_generate_key_fun_num_used
DEFAULT_CMOD_STORAGE ptrdiff_t f_Nettle_ECC_Curve_ECDSA_generate_key_fun_num = 0;

#endif /* f_Nettle_ECC_Curve_ECDSA_generate_key_fun_num_used */
DEFAULT_CMOD_STORAGE void f_Nettle_ECC_Curve_ECDSA_generate_key(INT32 args) {
#line 993 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
if(args != 0) wrong_number_of_args_error("generate_key",args,0);
{
ecdsa_generate_keypair(&THIS->pub, &THIS->key,
&THIS->random, random_func_wrapper);
}
}

#ifdef Nettle_ECC_Curve_ECDSA_event_handler_defined
static void Nettle_ECC_Curve_ECDSA_event_handler(int ev) {
  switch(ev) {

#ifdef internal_init_Nettle_ECC_Curve_ECDSA_defined
  case PROG_EVENT_INIT: init_Nettle_ECC_Curve_ECDSA_struct(); break;

#endif /* internal_init_Nettle_ECC_Curve_ECDSA_defined */

#ifdef internal_exit_Nettle_ECC_Curve_ECDSA_defined
  case PROG_EVENT_EXIT: exit_Nettle_ECC_Curve_ECDSA_struct(); break;

#endif /* internal_exit_Nettle_ECC_Curve_ECDSA_defined */
  default: break; 
  }
}

#endif /* Nettle_ECC_Curve_ECDSA_event_handler_defined */
/*! @endclass ECDSA
   */
/*! @endclass ECC_Curve
 */

#line 1006 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#endif /* HAVE_NETTLE_ECDSA_H */

/*! @endmodule Nettle
 */

void
hogweed_init(void)
{

#ifdef module_strings_declared
module_strings[0] = 
  make_shared_binary_string("SECP_192R1",
                            CONSTANT_STRLEN("SECP_192R1"));
module_strings[1] = 
  make_shared_binary_string("SECP_224R1",
                            CONSTANT_STRLEN("SECP_224R1"));
module_strings[2] = 
  make_shared_binary_string("SECP_256R1",
                            CONSTANT_STRLEN("SECP_256R1"));
module_strings[3] = 
  make_shared_binary_string("SECP_384R1",
                            CONSTANT_STRLEN("SECP_384R1"));
module_strings[4] = 
  make_shared_binary_string("SECP_521R1",
                            CONSTANT_STRLEN("SECP_521R1"));
module_strings[5] = 
  make_shared_binary_string("UNKNOWN",
                            CONSTANT_STRLEN("UNKNOWN"));
module_strings[6] = 
  make_shared_binary_string("Point",
                            CONSTANT_STRLEN("Point"));
module_strings[7] = 
  make_shared_binary_string("Point(",
                            CONSTANT_STRLEN("Point("));
module_strings[8] = 
  make_shared_binary_string(")",
                            CONSTANT_STRLEN(")"));
module_strings[9] = 
  make_shared_binary_string("ECDSA(",
                            CONSTANT_STRLEN("ECDSA("));
module_strings[10] = 
  make_shared_binary_string("__builtin.Nettle.ECC_Curve",
                            CONSTANT_STRLEN("__builtin.Nettle.ECC_Curve"));
module_strings[11] = 
  make_shared_binary_string("__builtin.Nettle.Sign",
                            CONSTANT_STRLEN("__builtin.Nettle.Sign"));
module_strings[12] = 
  make_shared_binary_string("Gmp_mpz",
                            CONSTANT_STRLEN("Gmp_mpz"));
#endif

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
{ int i=0;
#ifndef tObjImpl_GMP_MPZ
# define tObjImpl_GMP_MPZ "\3\0\177\0\0\6"
{
   struct program *tmp = resolve_program(module_strings[12] /* "Gmp_mpz" */);
   if( tmp ) {
      ___cmod_ext_used[i].from = 6;
      ___cmod_ext_used[i].to = tmp->id;
      i++;
   }
}
#endif /* tObjImpl_GMP_MPZ */
}
set_program_id_to_id( ___cmod_map_program_ids );

#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */

#ifdef class_Nettle_DH_Params_defined

#ifdef PROG_NETTLE_DH_PARAMS_ID
#line 197 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  START_NEW_PROGRAM_ID(NETTLE_DH_PARAMS);
#else
#line 197 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  start_new_program();

#endif /* PROG_NETTLE_DH_PARAMS_ID */
#line 197 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_DH_Params_program = Pike_compiler->new_program;

#ifndef tObjImpl_NETTLE_DH_PARAMS

#undef tObjIs_NETTLE_DH_PARAMS
#define tObjIs_NETTLE_DH_PARAMS "\3\1\177\0\0\2"

#undef tObjImpl_NETTLE_DH_PARAMS
#define tObjImpl_NETTLE_DH_PARAMS "\3\0\177\0\0\2"

#endif /* tObjImpl_NETTLE_DH_PARAMS */

#ifdef THIS_NETTLE_DH_PARAMS
  Nettle_DH_Params_storage_offset = ADD_STORAGE(struct Nettle_DH_Params_struct);
#endif /* THIS_NETTLE_DH_PARAMS */

#ifdef Nettle_DH_Params_event_handler_defined
  pike_set_prog_event_callback(Nettle_DH_Params_event_handler);

#ifndef Nettle_DH_Params_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Nettle_DH_Params_gc_live_obj */

#endif /* Nettle_DH_Params_event_handler_defined */

#ifdef f_Nettle_DH_Params_cq__backtickp_defined

#ifdef f_Nettle_DH_Params_cq__backtickp_fun_num_used
  f_Nettle_DH_Params_cq__backtickp_fun_num =
#endif /* f_Nettle_DH_Params_cq__backtickp_fun_num_used */
#line 225 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("`p", f_Nettle_DH_Params_cq__backtickp, tFunc(tNone,tName("Gmp_mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_DH_Params_cq__backtickp_defined */

#ifdef f_Nettle_DH_Params_cq__backtickp_eq_defined

#ifdef f_Nettle_DH_Params_cq__backtickp_eq_fun_num_used
  f_Nettle_DH_Params_cq__backtickp_eq_fun_num =
#endif /* f_Nettle_DH_Params_cq__backtickp_eq_fun_num_used */
#line 230 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("`p=", f_Nettle_DH_Params_cq__backtickp_eq, tFunc(tOr(tName("Gmp_mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_DH_Params_cq__backtickp_eq_defined */

#ifdef f_Nettle_DH_Params_cq__backtickg_defined

#ifdef f_Nettle_DH_Params_cq__backtickg_fun_num_used
  f_Nettle_DH_Params_cq__backtickg_fun_num =
#endif /* f_Nettle_DH_Params_cq__backtickg_fun_num_used */
#line 237 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("`g", f_Nettle_DH_Params_cq__backtickg, tFunc(tNone,tName("Gmp_mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_DH_Params_cq__backtickg_defined */

#ifdef f_Nettle_DH_Params_cq__backtickg_eq_defined

#ifdef f_Nettle_DH_Params_cq__backtickg_eq_fun_num_used
  f_Nettle_DH_Params_cq__backtickg_eq_fun_num =
#endif /* f_Nettle_DH_Params_cq__backtickg_eq_fun_num_used */
#line 242 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("`g=", f_Nettle_DH_Params_cq__backtickg_eq, tFunc(tOr(tName("Gmp_mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_DH_Params_cq__backtickg_eq_defined */

#ifdef f_Nettle_DH_Params_cq__backtickq_defined

#ifdef f_Nettle_DH_Params_cq__backtickq_fun_num_used
  f_Nettle_DH_Params_cq__backtickq_fun_num =
#endif /* f_Nettle_DH_Params_cq__backtickq_fun_num_used */
#line 249 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("`q", f_Nettle_DH_Params_cq__backtickq, tFunc(tNone,tName("Gmp_mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_DH_Params_cq__backtickq_defined */

#ifdef f_Nettle_DH_Params_cq__backtickq_eq_defined

#ifdef f_Nettle_DH_Params_cq__backtickq_eq_fun_num_used
  f_Nettle_DH_Params_cq__backtickq_eq_fun_num =
#endif /* f_Nettle_DH_Params_cq__backtickq_eq_fun_num_used */
#line 254 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("`q=", f_Nettle_DH_Params_cq__backtickq_eq, tFunc(tOr(tName("Gmp_mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_DH_Params_cq__backtickq_eq_defined */

#ifdef f_Nettle_DH_Params_generate_defined

#ifdef f_Nettle_DH_Params_generate_fun_num_used
  f_Nettle_DH_Params_generate_fun_num =
#endif /* f_Nettle_DH_Params_generate_fun_num_used */
#line 272 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("generate", f_Nettle_DH_Params_generate, tFunc("\10\200\0\0\0\177\377\377\377" "\10\200\0\0\0\177\377\377\377" tFunc("\10\0\0\0\0\177\377\377\377",tStr8),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_DH_Params_generate_defined */

#ifdef f_Nettle_DH_Params_generate_keypair_defined

#ifdef f_Nettle_DH_Params_generate_keypair_fun_num_used
  f_Nettle_DH_Params_generate_keypair_fun_num =
#endif /* f_Nettle_DH_Params_generate_keypair_fun_num_used */
#line 295 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("generate_keypair", f_Nettle_DH_Params_generate_keypair, tFunc(tFunc("\10\0\0\0\0\177\377\377\377",tStr8),tArr(tName("Gmp_mpz", tObjImpl_GMP_MPZ))), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_DH_Params_generate_keypair_defined */
#line 198 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Pike_compiler->new_program->flags |= PROGRAM_CLEAR_STORAGE;
#line 197 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_DH_Params_program=end_program();
#line 197 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#ifdef Nettle_DH_Params_program_fun_num_used
Nettle_DH_Params_program_fun_num=
#endif
 add_program_constant("DH_Params",Nettle_DH_Params_program,0);

#endif /* class_Nettle_DH_Params_defined */

#ifdef class_Nettle_ECC_Curve_defined

#ifdef PROG_NETTLE_ECC_CURVE_ID
#line 365 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  START_NEW_PROGRAM_ID(NETTLE_ECC_CURVE);
#else
#line 365 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  start_new_program();

#endif /* PROG_NETTLE_ECC_CURVE_ID */
#line 365 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_ECC_Curve_program = Pike_compiler->new_program;

#ifndef tObjImpl_NETTLE_ECC_CURVE

#undef tObjIs_NETTLE_ECC_CURVE
#define tObjIs_NETTLE_ECC_CURVE "\3\1\177\0\0\3"

#undef tObjImpl_NETTLE_ECC_CURVE
#define tObjImpl_NETTLE_ECC_CURVE "\3\0\177\0\0\3"

#endif /* tObjImpl_NETTLE_ECC_CURVE */

#ifdef THIS_NETTLE_ECC_CURVE
  Nettle_ECC_Curve_storage_offset = ADD_STORAGE(struct Nettle_ECC_Curve_struct);
#endif /* THIS_NETTLE_ECC_CURVE */

#ifdef inherit_cq__22__builtin_2ENettle_2EECC_Curve_22_Nettle_ECC_Curve_defined
#line 369 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_ECC_Curve_cq__22__builtin_2ENettle_2EECC_Curve_22_inh_num = Pike_compiler->new_program->num_inherits;
  do {
#line 369 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    struct program *p = resolve_program(module_strings[10] /* "__builtin.Nettle.ECC_Curve" */);
    if (p) {
#line 369 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
      low_inherit(p, NULL, -1, 0, 0, NULL);
#line 369 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
      Nettle_ECC_Curve_cq__22__builtin_2ENettle_2EECC_Curve_22_inh_offset = Pike_compiler->new_program->inherits[Nettle_ECC_Curve_cq__22__builtin_2ENettle_2EECC_Curve_22_inh_num].identifier_level;
#line 369 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
      free_program(p);
    } else {
#line 369 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
      yyerror("Inherit failed.");
    }
  } while(0);
#endif /* inherit_cq__22__builtin_2ENettle_2EECC_Curve_22_Nettle_ECC_Curve_defined */

#ifdef class_Nettle_ECC_Curve_Point_defined

#ifdef PROG_NETTLE_ECC_CURVE_POINT_ID
#line 615 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  START_NEW_PROGRAM_ID(NETTLE_ECC_CURVE_POINT);
#else
#line 615 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  start_new_program();

#endif /* PROG_NETTLE_ECC_CURVE_POINT_ID */
#line 615 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_ECC_Curve_Point_program = Pike_compiler->new_program;

#ifndef tObjImpl_NETTLE_ECC_CURVE_POINT

#undef tObjIs_NETTLE_ECC_CURVE_POINT
#define tObjIs_NETTLE_ECC_CURVE_POINT "\3\1\177\0\0\4"

#undef tObjImpl_NETTLE_ECC_CURVE_POINT
#define tObjImpl_NETTLE_ECC_CURVE_POINT "\3\0\177\0\0\4"

#endif /* tObjImpl_NETTLE_ECC_CURVE_POINT */

#ifdef THIS_NETTLE_ECC_CURVE_POINT
  Nettle_ECC_Curve_Point_storage_offset = ADD_STORAGE(struct Nettle_ECC_Curve_Point_struct);
#endif /* THIS_NETTLE_ECC_CURVE_POINT */

#ifdef extra_Nettle_ECC_Curve_Point_defined
#line 623 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
{
/* Perform an inherit of the Point class that our parent
       * contains via its inherit of __builtin.Nettle.ECC_Curve.
       */
struct program *parent_prog = Pike_compiler->previous->new_program;
struct object *parent_obj = Pike_compiler->previous->fake_object;
int parent_Point_fun_num =
really_low_find_shared_string_identifier(module_strings[6] /* "Point" */,
parent_prog,
SEE_PROTECTED|SEE_PRIVATE);
if (parent_Point_fun_num >= 0) {
struct program *parent_Point_prog =
low_program_from_function(parent_obj, parent_Point_fun_num);
if (parent_Point_prog) {
parent_Point_fun_num =
really_low_reference_inherited_identifier(Pike_compiler->previous,
0, parent_Point_fun_num);
low_inherit(parent_Point_prog, 0,
parent_Point_fun_num,
1 + 42, 0, NULL);
}
}
}


#endif /* extra_Nettle_ECC_Curve_Point_defined */

#ifdef Nettle_ECC_Curve_Point_event_handler_defined
  pike_set_prog_event_callback(Nettle_ECC_Curve_Point_event_handler);

#ifndef Nettle_ECC_Curve_Point_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Nettle_ECC_Curve_Point_gc_live_obj */

#endif /* Nettle_ECC_Curve_Point_event_handler_defined */

#ifdef f_Nettle_ECC_Curve_Point_name_defined

#ifdef f_Nettle_ECC_Curve_Point_name_fun_num_used
  f_Nettle_ECC_Curve_Point_name_fun_num =
#endif /* f_Nettle_ECC_Curve_Point_name_fun_num_used */
#line 668 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("name", f_Nettle_ECC_Curve_Point_name, tFunc(tNone,tStr7), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_Point_name_defined */

#ifdef f_Nettle_ECC_Curve_Point_get_curve_defined

#ifdef f_Nettle_ECC_Curve_Point_get_curve_fun_num_used
  f_Nettle_ECC_Curve_Point_get_curve_fun_num =
#endif /* f_Nettle_ECC_Curve_Point_get_curve_fun_num_used */
#line 680 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("get_curve", f_Nettle_ECC_Curve_Point_get_curve, tFunc(tNone,tName("Nettle_ECC_Curve", tObjImpl_NETTLE_ECC_CURVE)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_Point_get_curve_defined */

#ifdef f_Nettle_ECC_Curve_Point_get_x_defined

#ifdef f_Nettle_ECC_Curve_Point_get_x_fun_num_used
  f_Nettle_ECC_Curve_Point_get_x_fun_num =
#endif /* f_Nettle_ECC_Curve_Point_get_x_fun_num_used */
#line 696 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("get_x", f_Nettle_ECC_Curve_Point_get_x, tFunc(tNone,tName("Gmp.mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_Point_get_x_defined */

#ifdef f_Nettle_ECC_Curve_Point_get_y_defined

#ifdef f_Nettle_ECC_Curve_Point_get_y_fun_num_used
  f_Nettle_ECC_Curve_Point_get_y_fun_num =
#endif /* f_Nettle_ECC_Curve_Point_get_y_fun_num_used */
#line 710 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("get_y", f_Nettle_ECC_Curve_Point_get_y, tFunc(tNone,tName("Gmp.mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_Point_get_y_defined */

#ifdef f_Nettle_ECC_Curve_Point_set_defined

#ifdef f_Nettle_ECC_Curve_Point_set_fun_num_used
  f_Nettle_ECC_Curve_Point_set_fun_num =
#endif /* f_Nettle_ECC_Curve_Point_set_fun_num_used */
#line 724 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("set", f_Nettle_ECC_Curve_Point_set, tFunc(tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377") tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_Point_set_defined */

#ifdef f_Nettle_ECC_Curve_Point_cq__backtick_2A_defined

#ifdef f_Nettle_ECC_Curve_Point_cq__backtick_2A_fun_num_used
  f_Nettle_ECC_Curve_Point_cq__backtick_2A_fun_num =
#endif /* f_Nettle_ECC_Curve_Point_cq__backtick_2A_fun_num_used */
#line 744 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("`*", f_Nettle_ECC_Curve_Point_cq__backtick_2A, tFunc(tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tName("Nettle_ECC_Curve_Point", tObjImpl_NETTLE_ECC_CURVE_POINT)), ID_PROTECTED, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_Point_cq__backtick_2A_defined */
#line 616 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Pike_compiler->new_program->flags |= PROGRAM_USES_PARENT|PROGRAM_NEEDS_PARENT|PROGRAM_CLEAR_STORAGE;
#line 615 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_ECC_Curve_Point_program=end_program();
#line 615 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#ifdef Nettle_ECC_Curve_Point_program_fun_num_used
Nettle_ECC_Curve_Point_program_fun_num=
#endif
 add_program_constant("Point",Nettle_ECC_Curve_Point_program,0);

#endif /* class_Nettle_ECC_Curve_Point_defined */

#ifdef class_Nettle_ECC_Curve_ECDSA_defined

#ifdef PROG_NETTLE_ECC_CURVE_ECDSA_ID
#line 786 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  START_NEW_PROGRAM_ID(NETTLE_ECC_CURVE_ECDSA);
#else
#line 786 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  start_new_program();

#endif /* PROG_NETTLE_ECC_CURVE_ECDSA_ID */
#line 786 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_ECC_Curve_ECDSA_program = Pike_compiler->new_program;

#ifndef tObjImpl_NETTLE_ECC_CURVE_ECDSA

#undef tObjIs_NETTLE_ECC_CURVE_ECDSA
#define tObjIs_NETTLE_ECC_CURVE_ECDSA "\3\1\177\0\0\5"

#undef tObjImpl_NETTLE_ECC_CURVE_ECDSA
#define tObjImpl_NETTLE_ECC_CURVE_ECDSA "\3\0\177\0\0\5"

#endif /* tObjImpl_NETTLE_ECC_CURVE_ECDSA */

#ifdef THIS_NETTLE_ECC_CURVE_ECDSA
  Nettle_ECC_Curve_ECDSA_storage_offset = ADD_STORAGE(struct Nettle_ECC_Curve_ECDSA_struct);
#endif /* THIS_NETTLE_ECC_CURVE_ECDSA */

#ifdef inherit_cq__22__builtin_2ENettle_2ESign_22_Nettle_ECC_Curve_ECDSA_defined
#line 791 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_ECC_Curve_ECDSA_cq__22__builtin_2ENettle_2ESign_22_inh_num = Pike_compiler->new_program->num_inherits;
  do {
#line 791 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    struct program *p = resolve_program(module_strings[11] /* "__builtin.Nettle.Sign" */);
    if (p) {
#line 791 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
      low_inherit(p, NULL, -1, 0, 0, NULL);
#line 791 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
      Nettle_ECC_Curve_ECDSA_cq__22__builtin_2ENettle_2ESign_22_inh_offset = Pike_compiler->new_program->inherits[Nettle_ECC_Curve_ECDSA_cq__22__builtin_2ENettle_2ESign_22_inh_num].identifier_level;
#line 791 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
      free_program(p);
    } else {
#line 791 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
      yyerror("Inherit failed.");
    }
  } while(0);
#endif /* inherit_cq__22__builtin_2ENettle_2ESign_22_Nettle_ECC_Curve_ECDSA_defined */

#ifdef var_random_Nettle_ECC_Curve_ECDSA_defined
  PIKE_MAP_VARIABLE("random", Nettle_ECC_Curve_ECDSA_storage_offset + OFFSETOF(Nettle_ECC_Curve_ECDSA_struct, random),
                    tFunc("\10\0\0\0\0\177\377\377\377",tStr8), PIKE_T_MIXED, ID_PROTECTED);
#endif /* var_random_Nettle_ECC_Curve_ECDSA_defined */

#ifdef Nettle_ECC_Curve_ECDSA_event_handler_defined
  pike_set_prog_event_callback(Nettle_ECC_Curve_ECDSA_event_handler);

#ifndef Nettle_ECC_Curve_ECDSA_gc_live_obj
  Pike_compiler->new_program->flags &= ~PROGRAM_LIVE_OBJ;

#endif /* Nettle_ECC_Curve_ECDSA_gc_live_obj */

#endif /* Nettle_ECC_Curve_ECDSA_event_handler_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_name_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_name_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_name_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_name_fun_num_used */
#line 826 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("name", f_Nettle_ECC_Curve_ECDSA_name, tFunc(tNone,tStr7), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_name_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_get_curve_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_get_curve_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_get_curve_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_get_curve_fun_num_used */
#line 838 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("get_curve", f_Nettle_ECC_Curve_ECDSA_get_curve, tFunc(tNone,tName("Nettle_ECC_Curve", tObjImpl_NETTLE_ECC_CURVE)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_get_curve_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_get_private_key_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_get_private_key_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_get_private_key_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_get_private_key_fun_num_used */
#line 851 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("get_private_key", f_Nettle_ECC_Curve_ECDSA_get_private_key, tFunc(tNone,tName("Gmp.mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_get_private_key_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_set_private_key_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_set_private_key_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_set_private_key_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_set_private_key_fun_num_used */
#line 865 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("set_private_key", f_Nettle_ECC_Curve_ECDSA_set_private_key, tFunc(tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_set_private_key_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_get_x_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_get_x_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_get_x_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_get_x_fun_num_used */
#line 882 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("get_x", f_Nettle_ECC_Curve_ECDSA_get_x, tFunc(tNone,tName("Gmp.mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_get_x_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_get_y_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_get_y_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_get_y_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_get_y_fun_num_used */
#line 896 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("get_y", f_Nettle_ECC_Curve_ECDSA_get_y, tFunc(tNone,tName("Gmp.mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_get_y_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_set_public_key_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_set_public_key_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_set_public_key_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_set_public_key_fun_num_used */
#line 910 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("set_public_key", f_Nettle_ECC_Curve_ECDSA_set_public_key, tFunc(tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377") tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_set_public_key_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_set_random_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_set_random_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_set_random_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_set_random_fun_num_used */
#line 926 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("set_random", f_Nettle_ECC_Curve_ECDSA_set_random, tFunc(tFunc("\10\0\0\0\0\177\377\377\377",tStr8),tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_set_random_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_raw_verify_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_raw_verify_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_raw_verify_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_raw_verify_fun_num_used */
#line 937 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("raw_verify", f_Nettle_ECC_Curve_ECDSA_raw_verify, tFunc(tStr8 tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377") tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),"\10\0\0\0\0\0\0\0\1"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_raw_verify_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_raw_sign_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_raw_sign_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_raw_sign_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_raw_sign_fun_num_used */
#line 968 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("raw_sign", f_Nettle_ECC_Curve_ECDSA_raw_sign, tFunc(tStr8,tArr(tName("Gmp.mpz", tObjImpl_GMP_MPZ))), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_raw_sign_defined */

#ifdef f_Nettle_ECC_Curve_ECDSA_generate_key_defined

#ifdef f_Nettle_ECC_Curve_ECDSA_generate_key_fun_num_used
  f_Nettle_ECC_Curve_ECDSA_generate_key_fun_num =
#endif /* f_Nettle_ECC_Curve_ECDSA_generate_key_fun_num_used */
#line 993 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("generate_key", f_Nettle_ECC_Curve_ECDSA_generate_key, tFunc(tNone,tVoid), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_ECDSA_generate_key_defined */
#line 787 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Pike_compiler->new_program->flags |= PROGRAM_USES_PARENT|PROGRAM_NEEDS_PARENT|PROGRAM_CLEAR_STORAGE;
#line 786 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_ECC_Curve_ECDSA_program=end_program();
#line 786 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#ifdef Nettle_ECC_Curve_ECDSA_program_fun_num_used
Nettle_ECC_Curve_ECDSA_program_fun_num=
#endif
 add_program_constant("ECDSA",Nettle_ECC_Curve_ECDSA_program,0);

#endif /* class_Nettle_ECC_Curve_ECDSA_defined */

#ifdef f_Nettle_ECC_Curve_create_defined

#ifdef f_Nettle_ECC_Curve_create_fun_num_used
  f_Nettle_ECC_Curve_create_fun_num =
#endif /* f_Nettle_ECC_Curve_create_fun_num_used */
#line 380 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("create", f_Nettle_ECC_Curve_create, tFunc("\10\0\0\0\0\177\377\377\377" "\10\0\0\0\0\177\377\377\377" "\10\0\0\0\0\177\377\377\377",tVoid), ID_STATIC
, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_create_defined */

#ifdef f_Nettle_ECC_Curve_name_defined

#ifdef f_Nettle_ECC_Curve_name_fun_num_used
  f_Nettle_ECC_Curve_name_fun_num =
#endif /* f_Nettle_ECC_Curve_name_fun_num_used */
#line 434 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("name", f_Nettle_ECC_Curve_name, tFunc(tNone,tStr7), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_name_defined */

#ifdef f_Nettle_ECC_Curve_size_defined

#ifdef f_Nettle_ECC_Curve_size_fun_num_used
  f_Nettle_ECC_Curve_size_fun_num =
#endif /* f_Nettle_ECC_Curve_size_fun_num_used */
#line 474 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("size", f_Nettle_ECC_Curve_size, tFunc(tNone,"\10\200\0\0\0\177\377\377\377"), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_size_defined */

#ifdef f_Nettle_ECC_Curve_new_scalar_defined

#ifdef f_Nettle_ECC_Curve_new_scalar_fun_num_used
  f_Nettle_ECC_Curve_new_scalar_fun_num =
#endif /* f_Nettle_ECC_Curve_new_scalar_fun_num_used */
#line 488 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("new_scalar", f_Nettle_ECC_Curve_new_scalar, tFunc(tFunc("\10\0\0\0\0\177\377\377\377",tStr8),tName("Gmp.mpz", tObjImpl_GMP_MPZ)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_new_scalar_defined */

#ifdef f_Nettle_ECC_Curve_cq__backtick_2A_defined

#ifdef f_Nettle_ECC_Curve_cq__backtick_2A_fun_num_used
  f_Nettle_ECC_Curve_cq__backtick_2A_fun_num =
#endif /* f_Nettle_ECC_Curve_cq__backtick_2A_fun_num_used */
#line 516 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("`*", f_Nettle_ECC_Curve_cq__backtick_2A, tFunc(tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tName("Nettle_ECC_Curve_Point", tObjImpl_NETTLE_ECC_CURVE_POINT)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_cq__backtick_2A_defined */

#ifdef f_Nettle_ECC_Curve_point_mul_defined

#ifdef f_Nettle_ECC_Curve_point_mul_fun_num_used
  f_Nettle_ECC_Curve_point_mul_fun_num =
#endif /* f_Nettle_ECC_Curve_point_mul_fun_num_used */
#line 562 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("point_mul", f_Nettle_ECC_Curve_point_mul, tFunc(tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377") tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377") tOr(tName("Gmp.mpz", tObjImpl_GMP_MPZ),"\10\200\0\0\0\177\377\377\377"),tName("Nettle_ECC_Curve_Point", tObjImpl_NETTLE_ECC_CURVE_POINT)), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_ECC_Curve_point_mul_defined */
#line 365 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
  Nettle_ECC_Curve_program=end_program();
#line 365 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
#ifdef Nettle_ECC_Curve_program_fun_num_used
Nettle_ECC_Curve_program_fun_num=
#endif
 add_program_constant("ECC_Curve",Nettle_ECC_Curve_program,0);

#endif /* class_Nettle_ECC_Curve_defined */

#ifdef f_Nettle_dsa_generate_keypair_defined

#ifdef f_Nettle_dsa_generate_keypair_fun_num_used
  f_Nettle_dsa_generate_keypair_fun_num =
#endif /* f_Nettle_dsa_generate_keypair_fun_num_used */
#line 72 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("dsa_generate_keypair", f_Nettle_dsa_generate_keypair, tFunc("\10\200\0\0\0\177\377\377\377" "\10\200\0\0\0\177\377\377\377" tFunc("\10\0\0\0\0\177\377\377\377",tStr8),tArr(tName("Gmp.mpz", tObjImpl_GMP_MPZ))), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_dsa_generate_keypair_defined */

#ifdef f_Nettle_rsa_generate_keypair_defined

#ifdef f_Nettle_rsa_generate_keypair_fun_num_used
  f_Nettle_rsa_generate_keypair_fun_num =
#endif /* f_Nettle_rsa_generate_keypair_fun_num_used */
#line 159 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    ADD_FUNCTION2("rsa_generate_keypair", f_Nettle_rsa_generate_keypair, tFunc("\10\200\0\0\0\177\377\377\377" "\10\200\0\0\0\177\377\377\377" tFunc("\10\0\0\0\0\177\377\377\377",tStr8),tArr(tName("Gmp.mpz", tObjImpl_GMP_MPZ))), 0, OPT_EXTERNAL_DEPEND|OPT_SIDE_EFFECT);

#endif /* f_Nettle_rsa_generate_keypair_defined */

#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
set_program_id_to_id( 0 );
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
#line 1014 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
;

#ifdef HAVE_NETTLE_ECDSA_H
#ifdef HAVE_CURVE_NETTLE_SECP_192R1
 ADD_INT_CONSTANT("SECP192R1", 192, 0);
#endif /* HAVE_CURVE_NETTLE_SECP_192R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_224R1
 ADD_INT_CONSTANT("SECP224R1", 224, 0);
#endif /* HAVE_CURVE_NETTLE_SECP_224R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_256R1
 ADD_INT_CONSTANT("SECP256R1", 256, 0);
#endif /* HAVE_CURVE_NETTLE_SECP_256R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_384R1
 ADD_INT_CONSTANT("SECP384R1", 384, 0);
#endif /* HAVE_CURVE_NETTLE_SECP_384R1 */
#ifdef HAVE_CURVE_NETTLE_SECP_521R1
 ADD_INT_CONSTANT("SECP521R1", 521, 0);
#endif /* HAVE_CURVE_NETTLE_SECP_521R1 */
#endif /* HAVE_NETTLE_ECDSA_H */
}

void
hogweed_exit(void)
{

#ifdef class_Nettle_DH_Params_defined
  if(Nettle_DH_Params_program) {
#line 197 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    free_program(Nettle_DH_Params_program);
    Nettle_DH_Params_program=0;
  }

#endif /* class_Nettle_DH_Params_defined */

#ifdef class_Nettle_ECC_Curve_defined

#ifdef class_Nettle_ECC_Curve_Point_defined
  if(Nettle_ECC_Curve_Point_program) {
#line 615 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    free_program(Nettle_ECC_Curve_Point_program);
    Nettle_ECC_Curve_Point_program=0;
  }

#endif /* class_Nettle_ECC_Curve_Point_defined */

#ifdef class_Nettle_ECC_Curve_ECDSA_defined
  if(Nettle_ECC_Curve_ECDSA_program) {
#line 786 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    free_program(Nettle_ECC_Curve_ECDSA_program);
    Nettle_ECC_Curve_ECDSA_program=0;
  }

#endif /* class_Nettle_ECC_Curve_ECDSA_defined */
  if(Nettle_ECC_Curve_program) {
#line 365 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
    free_program(Nettle_ECC_Curve_program);
    Nettle_ECC_Curve_program=0;
  }

#endif /* class_Nettle_ECC_Curve_defined */

#ifdef module_strings_declared
{
  int i;
  for(i=0; i < 13; i++) {
    if (module_strings[i]) free_string(module_strings[i]);
    module_strings[i] = NULL;
  }
}
#endif
#line 1038 "/Users/hww3/devel/pike/src/post_modules/Nettle/hogweed.cmod"
;
}

#endif


#ifdef CMOD_MAP_PROGRAM_IDS_DEFINED
static int ___cmod_map_program_ids(int id)
{
  int i = 0;
  if( (id&0x7f000000) != 0x7f000000 ) return id;
  id = id&0x00ffffff;
#ifdef class_Nettle_ECC_Curve_Point_defined
if(id==4) return Nettle_ECC_Curve_Point_program->id;
#endif
#ifdef class_Nettle_ECC_Curve_ECDSA_defined
if(id==5) return Nettle_ECC_Curve_ECDSA_program->id;
#endif
#ifdef class_Nettle_DH_Params_defined
if(id==2) return Nettle_DH_Params_program->id;
#endif
#ifdef class_Nettle_ECC_Curve_defined
if(id==3) return Nettle_ECC_Curve_program->id;
#endif
  while(___cmod_ext_used[i].from ) {
   if( ___cmod_ext_used[i].from == id ) return ___cmod_ext_used[i].to;
   i++;
  }
  return 0;
}
#endif /* CMOD_MAP_PROGRAM_IDS_DEFINED */
