/* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 3.0.12
 *
 * This file is not intended to be easily readable and contains a number of
 * coding conventions designed to improve portability and efficiency. Do not make
 * changes to this file unless you know what you are doing--modify the SWIG
 * interface file instead.
 * ----------------------------------------------------------------------------- */


#ifndef SWIGJAVA
#define SWIGJAVA
#endif


/* -----------------------------------------------------------------------------
 *  This section contains generic SWIG labels for method/variable
 *  declarations/attributes, and other compiler dependent labels.
 * ----------------------------------------------------------------------------- */

/* template workaround for compilers that cannot correctly implement the C++ standard */
#ifndef SWIGTEMPLATEDISAMBIGUATOR
# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
#  define SWIGTEMPLATEDISAMBIGUATOR template
# elif defined(__HP_aCC)
/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
#  define SWIGTEMPLATEDISAMBIGUATOR template
# else
#  define SWIGTEMPLATEDISAMBIGUATOR
# endif
#endif

/* inline attribute */
#ifndef SWIGINLINE
# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__))
#   define SWIGINLINE inline
# else
#   define SWIGINLINE
# endif
#endif

/* attribute recognised by some compilers to avoid 'unused' warnings */
#ifndef SWIGUNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define SWIGUNUSED __attribute__ ((__unused__))
#   else
#     define SWIGUNUSED
#   endif
# elif defined(__ICC)
#   define SWIGUNUSED __attribute__ ((__unused__))
# else
#   define SWIGUNUSED
# endif
#endif

#ifndef SWIG_MSC_UNSUPPRESS_4505
# if defined(_MSC_VER)
#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
# endif
#endif

#ifndef SWIGUNUSEDPARM
# ifdef __cplusplus
#   define SWIGUNUSEDPARM(p)
# else
#   define SWIGUNUSEDPARM(p) p SWIGUNUSED
# endif
#endif

/* internal SWIG method */
#ifndef SWIGINTERN
# define SWIGINTERN static SWIGUNUSED
#endif

/* internal inline SWIG method */
#ifndef SWIGINTERNINLINE
# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE
#endif

/* exporting methods */
#if defined(__GNUC__)
#  if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#    ifndef GCC_HASCLASSVISIBILITY
#      define GCC_HASCLASSVISIBILITY
#    endif
#  endif
#endif

#ifndef SWIGEXPORT
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#   if defined(STATIC_LINKED)
#     define SWIGEXPORT
#   else
#     define SWIGEXPORT __declspec(dllexport)
#   endif
# else
#   if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY)
#     define SWIGEXPORT __attribute__ ((visibility("default")))
#   else
#     define SWIGEXPORT
#   endif
# endif
#endif

/* calling conventions for Windows */
#ifndef SWIGSTDCALL
# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
#   define SWIGSTDCALL __stdcall
# else
#   define SWIGSTDCALL
# endif
#endif

/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
# define _CRT_SECURE_NO_DEPRECATE
#endif

/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
# define _SCL_SECURE_NO_DEPRECATE
#endif

/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
#endif

/* Intel's compiler complains if a variable which was never initialised is
 * cast to void, which is a common idiom which we use to indicate that we
 * are aware a variable isn't used.  So we just silence that warning.
 * See: https://github.com/swig/swig/issues/192 for more discussion.
 */
#ifdef __INTEL_COMPILER
# pragma warning disable 592
#endif


/* Fix for jlong on some versions of gcc on Windows */
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
  typedef long long __int64;
#endif

/* Fix for jlong on 64-bit x86 Solaris */
#if defined(__x86_64)
# ifdef _LP64
#   undef _LP64
# endif
#endif

#include <jni.h>
#include <stdlib.h>
#include <string.h>


/* Support for throwing Java exceptions */
typedef enum {
  SWIG_JavaOutOfMemoryError = 1, 
  SWIG_JavaIOException, 
  SWIG_JavaRuntimeException, 
  SWIG_JavaIndexOutOfBoundsException,
  SWIG_JavaArithmeticException,
  SWIG_JavaIllegalArgumentException,
  SWIG_JavaNullPointerException,
  SWIG_JavaDirectorPureVirtual,
  SWIG_JavaUnknownError
} SWIG_JavaExceptionCodes;

typedef struct {
  SWIG_JavaExceptionCodes code;
  const char *java_exception;
} SWIG_JavaExceptions_t;


static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) {
  jclass excep;
  static const SWIG_JavaExceptions_t java_exceptions[] = {
    { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" },
    { SWIG_JavaIOException, "java/io/IOException" },
    { SWIG_JavaRuntimeException, "java/lang/RuntimeException" },
    { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" },
    { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" },
    { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" },
    { SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
    { SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
    { SWIG_JavaUnknownError,  "java/lang/UnknownError" },
    { (SWIG_JavaExceptionCodes)0,  "java/lang/UnknownError" }
  };
  const SWIG_JavaExceptions_t *except_ptr = java_exceptions;

  while (except_ptr->code != code && except_ptr->code)
    except_ptr++;

  (*jenv)->ExceptionClear(jenv);
  excep = (*jenv)->FindClass(jenv, except_ptr->java_exception);
  if (excep)
    (*jenv)->ThrowNew(jenv, excep, msg);
}


/* Contract support */

#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, msg); return nullreturn; } else


#include <eac/eac.h>
#include <openssl/bio.h>
#include <stdlib.h>
#include <string.h>

/* included in OpenPACE, but not propagated */
extern void BUF_MEM_clear_free(BUF_MEM *b);


#include <eac/eac.h>
#include <openssl/err.h>
#include <openssl/objects.h>
#include <stdlib.h>
#include <string.h>

/* included in OpenPACE, but not propagated */
extern BUF_MEM *BUF_MEM_create_init(const void *buf, size_t len);


    /*Dumps a BUF_MEM structure to stdout for debugging purposes */
    static void hexdump(const char *title, const BUF_MEM *s) {
        unsigned int n=0;

        if (!s) return;

        fprintf(stdout,"%s",title);
        for(; n < s->length; ++n) {
            if((n%16) == 0)
            fprintf(stdout,"\n    ");
            fprintf(stdout,"%02x:",(unsigned char) s->data[n]);
        }
        fprintf(stdout,"\n");
    }


    static void set_tr_version(EAC_CTX *ctx, int version) {
        switch (version) {
            case 1:
                ctx->tr_version = EAC_TR_VERSION_2_01;
                break;
            case 2:
                ctx->tr_version = EAC_TR_VERSION_2_02;
                break;
            default:
                ctx->tr_version = EAC_TR_VERSION;
                break;
        }
        return;
    }


    /* Converts a binary string and a length into a BUF_MEM structure */
    static BUF_MEM * get_buf(char *in, size_t in_len) {
        BUF_MEM *buf = NULL;
        if (in_len > 0)
            buf = BUF_MEM_create_init(in, in_len);
        return buf;
    }


    /* Print the OpenSSL error stack to stdout */
    static void print_ossl_err(void) {
        /* Might be better to load the strings once on program startup */
        ERR_load_crypto_strings();
        ERR_print_errors_fp(stdout);
        ERR_free_strings();
        return;
    }


#include <eac/ca.h>
#include <eac/cv_cert.h>
#include <eac/objects.h>
#include <stdlib.h>
#include <string.h>

/* included in OpenPACE, but not propagated */
extern void BUF_MEM_clear_free(BUF_MEM *b);


    int
    ca_set_key(const EAC_CTX *ctx,
            char *privkey, size_t privkey_len,
            char *pubkey, size_t pubkey_len)
    {
        return CA_set_key(ctx,
            (unsigned char *) privkey, privkey_len,
            (unsigned char *) pubkey, pubkey_len);
    }


#include <eac/cv_cert.h>
#include <openssl/bio.h>
#include <stdlib.h>
#include <string.h>


    static void CVC_CHAT_PRINT(CVC_CHAT *chat, int indent) {
        BIO *bio_stdout = BIO_new_fp(stdout, BIO_NOCLOSE);
        if (!bio_stdout)
            return;
        cvc_chat_print(bio_stdout, chat, indent);
        BIO_free_all(bio_stdout);
    }

 /* typemap applied */
    static CVC_CERT *cvc_d2i_cvc_cert(char *in, size_t in_len) {
        CVC_CERT *cvc = NULL;
        const unsigned char **p = (const unsigned char **) &in;
        cvc = CVC_d2i_CVC_CERT(NULL, p, in_len);
        return cvc;
    }

 /* typemap applied */
    static CVC_CERTIFICATE_DESCRIPTION *d2i_cvc_certificate_description(char *in, size_t in_len) {
        CVC_CERTIFICATE_DESCRIPTION *description = NULL;
        const unsigned char **p = (const unsigned char **) &in;
        description = d2i_CVC_CERTIFICATE_DESCRIPTION(NULL, p, in_len);
        return description;
    }

 /* typemap applied */
    static CVC_CHAT *d2i_cvc_chat(char *in, size_t in_len) {
        CVC_CHAT *chat = NULL;
        const unsigned char **p = (const unsigned char **) &in;
        chat = d2i_CVC_CHAT(NULL, p, (long) in_len);
        return chat;
    }


    static void print_binary_chat(char *in, size_t in_len) {
        CVC_CHAT *chat = NULL;
        const unsigned char **p;

        if (!in || (in_len <= 0))
            return;

        p = (const unsigned char**)&in;

        /* Convert string to CHAT structure */
        chat = d2i_CVC_CHAT(NULL, p, in_len);
        if (!chat)
            return;

        /* Print CHAT structure */
        CVC_CHAT_PRINT(chat, 0);

        /* Free memory */
        free(chat);
        return;
    }

 /* typemap applied */
    void i2d_cvc_chat(CVC_CHAT *chat, char **out, size_t *out_len) {
        unsigned char *tmp;
        int new_len;

        if (!chat)
            return;

        new_len = i2d_CVC_CHAT(chat, NULL);
        if (new_len < 0) {
            *out_len = 0;
            return;
        }
        *out = (char *) malloc(new_len);
        if (!*out)
            return;

        tmp = (unsigned char *) *out;
        *out_len = i2d_CVC_CHAT(chat, &tmp);
        return;
    }


    static void get_binary_chat(CVC_CHAT *chat, char **out, size_t *out_len) {

        if (!chat || !chat->relative_authorization) {
            /* Return a NULL pointer on error */
            *out = NULL;
            *out_len = 0;
            return;
        }

        *out_len = chat->relative_authorization->length;
        *out = (char *) malloc(*out_len);
        memcpy(*out, chat->relative_authorization->data, *out_len);
        return;

    }


    static void get_chat_role(CVC_CHAT *chat, char **out, size_t *out_len) {
        int role = 0;

        if (!chat || !out || !out_len)
            goto err;

        role = CVC_get_role(chat);
        switch(role) {
            case CVC_Terminal:
                *out_len = 21;
                *out = (char *) malloc(*out_len);
                if (!*out)
                    goto err;
                strncpy(*out, "Terminal certificate", *out_len);
                break;
            case CVC_DV:
                *out_len = 15;
                *out = (char *) malloc(*out_len);
                if (!*out)
                    goto err;
                strncpy(*out, "DV certificate", *out_len);
                break;
            case CVC_DocVer:
                *out_len = 15;
                *out = (char *) malloc(*out_len);
                if (!*out)
                    goto err;
                strncpy(*out, "DV certificate", *out_len);
                break;
            case CVC_CVCA:
                *out_len = 17;
                *out = (char *) malloc(*out_len);
                if (!*out)
                    goto err;
                strncpy(*out, "CVCA certificate", *out_len);
                break;
            default:
                goto err;
        }

        return;

    err:
        if (out) {
            free(*out);
            *out = NULL;
        }
        if (out_len)
            *out_len = 0;
        return;
    }


    static void get_chat_terminal_type(CVC_CHAT *chat, char **out, size_t *out_len) {
        const char *terminal_type = NULL;

        if (!chat || !out || !out_len)
            goto err;

        terminal_type = OBJ_nid2sn(OBJ_obj2nid(chat->terminal_type));
        if (!terminal_type)
            goto err;

        *out_len = strlen(terminal_type) + 1;
        *out = (char *) malloc(*out_len);
        if (!*out)
            goto err;

        strcpy(*out, terminal_type);
        return;

    err:
        if (out) {
            free(*out);
            *out = NULL;
        }
        if (out_len)
            *out_len = 0;
        return;
    }


    /**
     * @brief Get a string representation of a CHAT.
     */
    static void get_chat_rel_auth(CVC_CHAT *chat, char **out, size_t *out_len) {
        BIO *bio = NULL;
        long tmp;

        if (!out || !out_len)
            goto err;

        bio = BIO_new(BIO_s_mem());
        if (!bio)
            goto err;

        cvc_chat_print_authorizations(bio, chat, 0);

        tmp = BIO_ctrl_pending(bio);
        if (tmp < 0)
            goto err;
        *out = (char *) malloc(tmp);
        if (!*out)
            goto err;
        *out_len = tmp;

        if (BIO_read(bio, (void *) *out, *out_len) != tmp)
            goto err;

        BIO_free_all(bio);
        return;

    err:
        if (bio)
            BIO_free_all(bio);
        if (out) {
            free(*out);
            *out = NULL;
        }
        if (out_len)
            *out_len = 0;
        return;
    }


    /**
     * @brief Get a string representation of a CHAT.
     */
    static void get_chat_repr(CVC_CHAT *chat, char **out, size_t *out_len) {
        BIO *bio =  NULL;
        long tmp;

        if (!out || !out_len)
            goto err;

        bio = BIO_new(BIO_s_mem());
        if (!bio)
            return;

        cvc_chat_print(bio, chat, 0);

        tmp = BIO_ctrl_pending(bio);
        if (tmp < 0)
            goto err;
        *out = (char *) malloc(tmp);
        if (!*out)
            goto err;
        *out_len = tmp;

        if (BIO_read(bio, (void *) *out, *out_len) != tmp)
            goto err;

        BIO_free_all(bio);
        return;

    err:
        if (bio)
            BIO_free_all(bio);
        if (out) {
            free(*out);
            *out = NULL;
        }
        if (out_len)
            *out_len = 0;
        return;
    }


    /**
     * @brief Get a string representation of a CHAT.
     */
    static void get_cvc_repr(CVC_CERT *chat, char **out, size_t *out_len) {
        BIO *bio =  NULL;
        long tmp;

        if (!out || !out_len)
            goto err;

        bio = BIO_new(BIO_s_mem());
        if (!bio)
            return;

        CVC_print(bio, chat, 0);

        tmp = BIO_ctrl_pending(bio);
        if (tmp < 0)
            goto err;
        *out = (char *) malloc(tmp);
        if (!*out)
            goto err;
        *out_len = tmp;

        if (BIO_read(bio, (void *) *out, *out_len) != tmp)
            goto err;

        BIO_free_all(bio);
        return;

    err:
        if (bio)
            BIO_free_all(bio);
        if (out) {
            free(*out);
            *out = NULL;
        }
        if (out_len)
            *out_len = 0;
        return;
    }


#include <eac/objects.h>

#ifdef HAVE_PATCHED_OPENSSL

/* OpenSSL has NIDs as defines. So lets get their value into ints */

int id_PACE_DH_GM_3DES_CBC_CBC = NID_id_PACE_DH_GM_3DES_CBC_CBC;
int id_PACE_DH_GM_AES_CBC_CMAC_128 = NID_id_PACE_DH_GM_AES_CBC_CMAC_128;
int id_PACE_DH_GM_AES_CBC_CMAC_192 = NID_id_PACE_DH_GM_AES_CBC_CMAC_192;
int id_PACE_DH_GM_AES_CBC_CMAC_256 = NID_id_PACE_DH_GM_AES_CBC_CMAC_256;
int id_PACE_ECDH_GM_3DES_CBC_CBC = NID_id_PACE_ECDH_GM_3DES_CBC_CBC;
int id_PACE_ECDH_GM_AES_CBC_CMAC_128 = NID_id_PACE_ECDH_GM_AES_CBC_CMAC_128;
int id_PACE_ECDH_GM_AES_CBC_CMAC_192 = NID_id_PACE_ECDH_GM_AES_CBC_CMAC_192;
int id_PACE_ECDH_GM_AES_CBC_CMAC_256 = NID_id_PACE_ECDH_GM_AES_CBC_CMAC_256;
int id_PACE_DH_IM_3DES_CBC_CBC = NID_id_PACE_DH_IM_3DES_CBC_CBC;
int id_PACE_DH_IM_AES_CBC_CMAC_128 = NID_id_PACE_DH_IM_AES_CBC_CMAC_128;
int id_PACE_DH_IM_AES_CBC_CMAC_192 = NID_id_PACE_DH_IM_AES_CBC_CMAC_192;
int id_PACE_DH_IM_AES_CBC_CMAC_256 = NID_id_PACE_DH_IM_AES_CBC_CMAC_256;
int id_PACE_ECDH_IM_3DES_CBC_CBC = NID_id_PACE_ECDH_IM_3DES_CBC_CBC;
int id_PACE_ECDH_IM_AES_CBC_CMAC_128 = NID_id_PACE_ECDH_IM_AES_CBC_CMAC_128;
int id_PACE_ECDH_IM_AES_CBC_CMAC_192 = NID_id_PACE_ECDH_IM_AES_CBC_CMAC_192;
int id_PACE_ECDH_IM_AES_CBC_CMAC_256 = NID_id_PACE_ECDH_IM_AES_CBC_CMAC_256;

int id_CA_DH_3DES_CBC_CBC       = NID_id_CA_DH_3DES_CBC_CBC;
int id_CA_DH_AES_CBC_CMAC_128   = NID_id_CA_DH_AES_CBC_CMAC_128;
int id_CA_DH_AES_CBC_CMAC_192   = NID_id_CA_DH_AES_CBC_CMAC_192;
int id_CA_DH_AES_CBC_CMAC_256   = NID_id_CA_DH_AES_CBC_CMAC_256;
int id_CA_ECDH_3DES_CBC_CBC     = NID_id_CA_ECDH_3DES_CBC_CBC;
int id_CA_ECDH_AES_CBC_CMAC_128 = NID_id_CA_ECDH_AES_CBC_CMAC_128;
int id_CA_ECDH_AES_CBC_CMAC_192 = NID_id_CA_ECDH_AES_CBC_CMAC_192;
int id_CA_ECDH_AES_CBC_CMAC_256 = NID_id_CA_ECDH_AES_CBC_CMAC_256;

int id_RI_DH_SHA_1 = NID_id_RI_DH_SHA_1;
int id_RI_DH_SHA_224 = NID_id_RI_DH_SHA_224;
int id_RI_DH_SHA_256 = NID_id_RI_DH_SHA_256;
int id_RI_DH_SHA_384 = NID_id_RI_DH_SHA_384;
int id_RI_DH_SHA_512 = NID_id_RI_DH_SHA_512;
int id_RI_ECDH_SHA_1 = NID_id_RI_ECDH_SHA_1;
int id_RI_ECDH_SHA_224 = NID_id_RI_ECDH_SHA_224;
int id_RI_ECDH_SHA_256 = NID_id_RI_ECDH_SHA_256;
int id_RI_ECDH_SHA_384 = NID_id_RI_ECDH_SHA_384;
int id_RI_ECDH_SHA_512 = NID_id_RI_ECDH_SHA_512;

#else

/* libeac has NIDs as ints. So lets define id_* to be NID_id_* */

#define id_PACE_DH_GM_3DES_CBC_CBC NID_id_PACE_DH_GM_3DES_CBC_CBC
#define id_PACE_DH_GM_AES_CBC_CMAC_128 NID_id_PACE_DH_GM_AES_CBC_CMAC_128
#define id_PACE_DH_GM_AES_CBC_CMAC_192 NID_id_PACE_DH_GM_AES_CBC_CMAC_192
#define id_PACE_DH_GM_AES_CBC_CMAC_256 NID_id_PACE_DH_GM_AES_CBC_CMAC_256
#define id_PACE_ECDH_GM_3DES_CBC_CBC NID_id_PACE_ECDH_GM_3DES_CBC_CBC
#define id_PACE_ECDH_GM_AES_CBC_CMAC_128 NID_id_PACE_ECDH_GM_AES_CBC_CMAC_128
#define id_PACE_ECDH_GM_AES_CBC_CMAC_192 NID_id_PACE_ECDH_GM_AES_CBC_CMAC_192
#define id_PACE_ECDH_GM_AES_CBC_CMAC_256 NID_id_PACE_ECDH_GM_AES_CBC_CMAC_256
#define id_PACE_DH_IM_3DES_CBC_CBC NID_id_PACE_DH_IM_3DES_CBC_CBC
#define id_PACE_DH_IM_AES_CBC_CMAC_128 NID_id_PACE_DH_IM_AES_CBC_CMAC_128
#define id_PACE_DH_IM_AES_CBC_CMAC_192 NID_id_PACE_DH_IM_AES_CBC_CMAC_192
#define id_PACE_DH_IM_AES_CBC_CMAC_256 NID_id_PACE_DH_IM_AES_CBC_CMAC_256
#define id_PACE_ECDH_IM_3DES_CBC_CBC NID_id_PACE_ECDH_IM_3DES_CBC_CBC
#define id_PACE_ECDH_IM_AES_CBC_CMAC_128 NID_id_PACE_ECDH_IM_AES_CBC_CMAC_128
#define id_PACE_ECDH_IM_AES_CBC_CMAC_192 NID_id_PACE_ECDH_IM_AES_CBC_CMAC_192
#define id_PACE_ECDH_IM_AES_CBC_CMAC_256 NID_id_PACE_ECDH_IM_AES_CBC_CMAC_256

#define id_CA_DH_3DES_CBC_CBC NID_id_CA_DH_3DES_CBC_CBC
#define id_CA_DH_AES_CBC_CMAC_128 NID_id_CA_DH_AES_CBC_CMAC_128
#define id_CA_DH_AES_CBC_CMAC_192 NID_id_CA_DH_AES_CBC_CMAC_192
#define id_CA_DH_AES_CBC_CMAC_256 NID_id_CA_DH_AES_CBC_CMAC_256
#define id_CA_ECDH_3DES_CBC_CBC NID_id_CA_ECDH_3DES_CBC_CBC
#define id_CA_ECDH_AES_CBC_CMAC_128 NID_id_CA_ECDH_AES_CBC_CMAC_128
#define id_CA_ECDH_AES_CBC_CMAC_192 NID_id_CA_ECDH_AES_CBC_CMAC_192
#define id_CA_ECDH_AES_CBC_CMAC_256 NID_id_CA_ECDH_AES_CBC_CMAC_256

#define id_RI_DH_SHA_1 NID_id_RI_DH_SHA_1
#define id_RI_DH_SHA_224 NID_id_RI_DH_SHA_224
#define id_RI_DH_SHA_256 NID_id_RI_DH_SHA_256
#define id_RI_DH_SHA_384 NID_id_RI_DH_SHA_384
#define id_RI_DH_SHA_512 NID_id_RI_DH_SHA_512
#define id_RI_ECDH_SHA_1 NID_id_RI_ECDH_SHA_1
#define id_RI_ECDH_SHA_224 NID_id_RI_ECDH_SHA_224
#define id_RI_ECDH_SHA_256 NID_id_RI_ECDH_SHA_256
#define id_RI_ECDH_SHA_384 NID_id_RI_ECDH_SHA_384
#define id_RI_ECDH_SHA_512 NID_id_RI_ECDH_SHA_512

#endif



#include <eac/pace.h>
#include <openssl/buffer.h>


#include <eac/ta.h>
#include <openssl/buffer.h>
#include <stdlib.h>
#include <string.h>


    static int eac_ctx_init_ef_cardaccess(char *in, size_t in_len, EAC_CTX *ctx) { /* typemap applied */
            return EAC_CTX_init_ef_cardaccess((unsigned char*) in,
                    in_len, ctx);
    }


    static int eac_ctx_init_ef_cardsecurity(char *in, size_t in_len, EAC_CTX *ctx) { /* typemap applied */
            return EAC_CTX_init_ef_cardsecurity((unsigned char*) in,
                    in_len, ctx);
    }


    static int eac_ctx_init_ta(const EAC_CTX *ctx,
            char *privkey, size_t privkey_len, char *cert, size_t cert_len) {
        return EAC_CTX_init_ta(ctx,
            (unsigned char*) privkey, privkey_len,
            (unsigned char*) cert, cert_len);

    }


#ifdef __cplusplus
extern "C" {
#endif

SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1TR_1VERSION_12_101_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(1);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1TR_1VERSION_12_102_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_BUF_1MEM_1clear_1free(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  BUF_MEM *arg1 = (BUF_MEM *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(BUF_MEM **)&jarg1; 
  BUF_MEM_clear_free(arg1);
}


SWIGEXPORT jint JNICALL Java_eacJNI_OBJ_1txt2nid(JNIEnv *jenv, jclass jcls, jstring jarg1) {
  jint jresult = 0 ;
  char *arg1 = (char *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = 0;
  if (jarg1) {
    arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
    if (!arg1) return 0;
  }
  result = (int)OBJ_txt2nid(arg1);
  jresult = (jint)result; 
  if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_EAC_1init(JNIEnv *jenv, jclass jcls) {
  (void)jenv;
  (void)jcls;
  EAC_init();
}


SWIGEXPORT void JNICALL Java_eacJNI_EAC_1cleanup(JNIEnv *jenv, jclass jcls) {
  (void)jenv;
  (void)jcls;
  EAC_cleanup();
}


SWIGEXPORT void JNICALL Java_eacJNI_hexdump(JNIEnv *jenv, jclass jcls, jstring jarg1, jlong jarg2) {
  char *arg1 = (char *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = 0;
  if (jarg1) {
    arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
    if (!arg1) return ;
  }
  arg2 = *(BUF_MEM **)&jarg2; 
  hexdump((char const *)arg1,(BUF_MEM const *)arg2);
  if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
}


SWIGEXPORT void JNICALL Java_eacJNI_set_1tr_1version(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  int arg2 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = (int)jarg2; 
  set_tr_version(arg1,arg2);
}


SWIGEXPORT jlong JNICALL Java_eacJNI_get_1buf(JNIEnv *jenv, jclass jcls, jbyteArray jarg1) {
  jlong jresult = 0 ;
  char *arg1 = (char *) 0 ;
  size_t arg2 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  {
    /* Functions from jni.h */
    arg1 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg1, 0);
    arg2 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg1);
  }
  result = (BUF_MEM *)get_buf(arg1,arg2);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_print_1ossl_1err(JNIEnv *jenv, jclass jcls) {
  (void)jenv;
  (void)jcls;
  print_ossl_err();
}


SWIGEXPORT void JNICALL Java_eacJNI_CA_1disable_1passive_1authentication(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  CA_disable_passive_authentication(arg1);
}


SWIGEXPORT jlong JNICALL Java_eacJNI_CA_1get_1pubkey(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  unsigned char *arg2 = (unsigned char *) 0 ;
  size_t arg3 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(unsigned char **)&jarg2; 
  arg3 = (size_t)jarg3; 
  result = (BUF_MEM *)CA_get_pubkey((EAC_CTX const *)arg1,(unsigned char const *)arg2,arg3);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_CA_1STEP1_1get_1pubkey(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (BUF_MEM *)CA_STEP1_get_pubkey((EAC_CTX const *)arg1);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_CA_1STEP2_1get_1eph_1pubkey(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (BUF_MEM *)CA_STEP2_get_eph_pubkey((EAC_CTX const *)arg1);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_CA_1STEP3_1check_1pcd_1pubkey(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM *arg3 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  arg3 = *(BUF_MEM **)&jarg3; 
  result = (int)CA_STEP3_check_pcd_pubkey((EAC_CTX const *)arg1,(BUF_MEM const *)arg2,(BUF_MEM const *)arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_CA_1STEP4_1compute_1shared_1secret(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (int)CA_STEP4_compute_shared_secret((EAC_CTX const *)arg1,(BUF_MEM const *)arg2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_CA_1STEP6_1derive_1keys(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM *arg3 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  arg3 = *(BUF_MEM **)&jarg3; 
  result = (int)CA_STEP6_derive_keys(arg1,(BUF_MEM const *)arg2,(BUF_MEM const *)arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_CA_1set_1key(JNIEnv *jenv, jclass jcls, jlong jarg1, jbyteArray jarg2, jbyteArray jarg4) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  char *arg2 = (char *) 0 ;
  size_t arg3 ;
  char *arg4 = (char *) 0 ;
  size_t arg5 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  {
    /* Functions from jni.h */
    arg2 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg2, 0);
    arg3 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg2);
  }
  {
    /* Functions from jni.h */
    arg4 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg4, 0);
    arg5 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg4);
  }
  result = (int)ca_set_key((EAC_CTX const *)arg1,arg2,arg3,arg4,arg5);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_CA_1STEP5_1derive_1keys(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jlong jarg4) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM **arg3 = (BUF_MEM **) 0 ;
  BUF_MEM **arg4 = (BUF_MEM **) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  arg3 = *(BUF_MEM ***)&jarg3; 
  arg4 = *(BUF_MEM ***)&jarg4; 
  result = (int)CA_STEP5_derive_keys((EAC_CTX const *)arg1,(BUF_MEM const *)arg2,arg3,arg4);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_CVC_1CERT_1new(JNIEnv *jenv, jclass jcls) {
  jlong jresult = 0 ;
  CVC_CERT *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  result = (CVC_CERT *)CVC_CERT_new();
  *(CVC_CERT **)&jresult = result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_CVC_1CERT_1free(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  CVC_CERT_free(arg1);
}


SWIGEXPORT jlong JNICALL Java_eacJNI_CVC_1CERT_1dup(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  CVC_CERT *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  result = (CVC_CERT *)CVC_CERT_dup(arg1);
  *(CVC_CERT **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jshort JNICALL Java_eacJNI_CVC_1get_1profile_1identifier(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jshort jresult = 0 ;
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  short result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  result = (short)CVC_get_profile_identifier((CVC_CERT const *)arg1);
  jresult = (jshort)result; 
  return jresult;
}


SWIGEXPORT jstring JNICALL Java_eacJNI_CVC_1get_1car(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jstring jresult = 0 ;
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  char *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  result = (char *)CVC_get_car((CVC_CERT const *)arg1);
  if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result);
  free(result);
  return jresult;
}


SWIGEXPORT jstring JNICALL Java_eacJNI_CVC_1get_1chr(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jstring jresult = 0 ;
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  char *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  result = (char *)CVC_get_chr((CVC_CERT const *)arg1);
  if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result);
  free(result);
  return jresult;
}


SWIGEXPORT jstring JNICALL Java_eacJNI_CVC_1get_1effective_1date(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jstring jresult = 0 ;
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  char *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  result = (char *)CVC_get_effective_date((CVC_CERT const *)arg1);
  if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result);
  free(result);
  return jresult;
}


SWIGEXPORT jstring JNICALL Java_eacJNI_CVC_1get_1expiration_1date(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jstring jresult = 0 ;
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  char *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  result = (char *)CVC_get_expiration_date((CVC_CERT const *)arg1);
  if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result);
  free(result);
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_CVC_1CERTIFICATE_1DESCRIPTION_1new(JNIEnv *jenv, jclass jcls) {
  jlong jresult = 0 ;
  CVC_CERTIFICATE_DESCRIPTION *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  result = (CVC_CERTIFICATE_DESCRIPTION *)CVC_CERTIFICATE_DESCRIPTION_new();
  *(CVC_CERTIFICATE_DESCRIPTION **)&jresult = result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_CVC_1CERTIFICATE_1DESCRIPTION_1free(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  CVC_CERTIFICATE_DESCRIPTION *arg1 = (CVC_CERTIFICATE_DESCRIPTION *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERTIFICATE_DESCRIPTION **)&jarg1; 
  CVC_CERTIFICATE_DESCRIPTION_free(arg1);
}


SWIGEXPORT void JNICALL Java_eacJNI_cvc_1chat_1print(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  int arg2 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  arg2 = (int)jarg2; 
  CVC_CHAT_PRINT(arg1,arg2);
}


SWIGEXPORT jlong JNICALL Java_eacJNI_CVC_1d2i_1CVC_1CERT(JNIEnv *jenv, jclass jcls, jbyteArray jarg1) {
  jlong jresult = 0 ;
  char *arg1 = (char *) 0 ;
  size_t arg2 ;
  CVC_CERT *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  {
    /* Functions from jni.h */
    arg1 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg1, 0);
    arg2 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg1);
  }
  result = (CVC_CERT *)cvc_d2i_cvc_cert(arg1,arg2);
  *(CVC_CERT **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_d2i_1CVC_1CERTIFICATE_1DESCRIPTION(JNIEnv *jenv, jclass jcls, jbyteArray jarg1) {
  jlong jresult = 0 ;
  char *arg1 = (char *) 0 ;
  size_t arg2 ;
  CVC_CERTIFICATE_DESCRIPTION *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  {
    /* Functions from jni.h */
    arg1 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg1, 0);
    arg2 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg1);
  }
  result = (CVC_CERTIFICATE_DESCRIPTION *)d2i_cvc_certificate_description(arg1,arg2);
  *(CVC_CERTIFICATE_DESCRIPTION **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_d2i_1CVC_1CHAT(JNIEnv *jenv, jclass jcls, jbyteArray jarg1) {
  jlong jresult = 0 ;
  char *arg1 = (char *) 0 ;
  size_t arg2 ;
  CVC_CHAT *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  {
    /* Functions from jni.h */
    arg1 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg1, 0);
    arg2 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg1);
  }
  result = (CVC_CHAT *)d2i_cvc_chat(arg1,arg2);
  *(CVC_CHAT **)&jresult = result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_print_1binary_1chat(JNIEnv *jenv, jclass jcls, jbyteArray jarg1) {
  char *arg1 = (char *) 0 ;
  size_t arg2 ;
  
  (void)jenv;
  (void)jcls;
  {
    /* Functions from jni.h */
    arg1 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg1, 0);
    arg2 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg1);
  }
  print_binary_chat(arg1,arg2);
}


SWIGEXPORT void JNICALL Java_eacJNI_i2d_1CVC_1CHAT(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  char **arg2 = (char **) 0 ;
  size_t *arg3 = (size_t *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  arg2 = *(char ***)&jarg2; 
  arg3 = *(size_t **)&jarg3; 
  i2d_cvc_chat(arg1,arg2,arg3);
}


SWIGEXPORT void JNICALL Java_eacJNI_get_1binary_1chat(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  char **arg2 = (char **) 0 ;
  size_t *arg3 = (size_t *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  arg2 = *(char ***)&jarg2; 
  arg3 = *(size_t **)&jarg3; 
  get_binary_chat(arg1,arg2,arg3);
}


SWIGEXPORT void JNICALL Java_eacJNI_get_1chat_1role(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  char **arg2 = (char **) 0 ;
  size_t *arg3 = (size_t *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  arg2 = *(char ***)&jarg2; 
  arg3 = *(size_t **)&jarg3; 
  get_chat_role(arg1,arg2,arg3);
}


SWIGEXPORT void JNICALL Java_eacJNI_get_1chat_1terminal_1type(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  char **arg2 = (char **) 0 ;
  size_t *arg3 = (size_t *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  arg2 = *(char ***)&jarg2; 
  arg3 = *(size_t **)&jarg3; 
  get_chat_terminal_type(arg1,arg2,arg3);
}


SWIGEXPORT void JNICALL Java_eacJNI_get_1chat_1rel_1auth(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  char **arg2 = (char **) 0 ;
  size_t *arg3 = (size_t *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  arg2 = *(char ***)&jarg2; 
  arg3 = *(size_t **)&jarg3; 
  get_chat_rel_auth(arg1,arg2,arg3);
}


SWIGEXPORT void JNICALL Java_eacJNI_get_1chat_1repr(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  char **arg2 = (char **) 0 ;
  size_t *arg3 = (size_t *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  arg2 = *(char ***)&jarg2; 
  arg3 = *(size_t **)&jarg3; 
  get_chat_repr(arg1,arg2,arg3);
}


SWIGEXPORT void JNICALL Java_eacJNI_get_1cvc_1repr(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  char **arg2 = (char **) 0 ;
  size_t *arg3 = (size_t *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  arg2 = *(char ***)&jarg2; 
  arg3 = *(size_t **)&jarg3; 
  get_cvc_repr(arg1,arg2,arg3);
}


SWIGEXPORT void JNICALL Java_eacJNI_CVC_1CHAT_1free(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  CVC_CHAT_free(arg1);
}


SWIGEXPORT jlong JNICALL Java_eacJNI_cvc_1get_1chat(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  CVC_CERT *arg1 = (CVC_CERT *) 0 ;
  CVC_CHAT *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CERT **)&jarg1; 
  result = (CVC_CHAT *)cvc_get_chat(arg1);
  *(CVC_CHAT **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_CVC_1CHAT_1dup(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  CVC_CHAT *arg1 = (CVC_CHAT *) 0 ;
  CVC_CHAT *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(CVC_CHAT **)&jarg1; 
  result = (CVC_CHAT *)CVC_CHAT_dup(arg1);
  *(CVC_CHAT **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1DH_1GM_13DES_1CBC_1CBC_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_DH_GM_3DES_CBC_CBC;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1DH_1GM_1AES_1CBC_1CMAC_1128_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_DH_GM_AES_CBC_CMAC_128;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1DH_1GM_1AES_1CBC_1CMAC_1192_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_DH_GM_AES_CBC_CMAC_192;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1DH_1GM_1AES_1CBC_1CMAC_1256_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_DH_GM_AES_CBC_CMAC_256;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1ECDH_1GM_13DES_1CBC_1CBC_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_ECDH_GM_3DES_CBC_CBC;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1ECDH_1GM_1AES_1CBC_1CMAC_1128_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_ECDH_GM_AES_CBC_CMAC_128;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1ECDH_1GM_1AES_1CBC_1CMAC_1192_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_ECDH_GM_AES_CBC_CMAC_192;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1ECDH_1GM_1AES_1CBC_1CMAC_1256_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_ECDH_GM_AES_CBC_CMAC_256;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1DH_1IM_13DES_1CBC_1CBC_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_DH_IM_3DES_CBC_CBC;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1DH_1IM_1AES_1CBC_1CMAC_1128_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_DH_IM_AES_CBC_CMAC_128;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1DH_1IM_1AES_1CBC_1CMAC_1192_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_DH_IM_AES_CBC_CMAC_192;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1DH_1IM_1AES_1CBC_1CMAC_1256_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_DH_IM_AES_CBC_CMAC_256;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1ECDH_1IM_13DES_1CBC_1CBC_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_ECDH_IM_3DES_CBC_CBC;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1ECDH_1IM_1AES_1CBC_1CMAC_1128_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_ECDH_IM_AES_CBC_CMAC_128;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1ECDH_1IM_1AES_1CBC_1CMAC_1192_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_ECDH_IM_AES_CBC_CMAC_192;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1PACE_1ECDH_1IM_1AES_1CBC_1CMAC_1256_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_PACE_ECDH_IM_AES_CBC_CMAC_256;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1CA_1DH_13DES_1CBC_1CBC_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_CA_DH_3DES_CBC_CBC;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1CA_1DH_1AES_1CBC_1CMAC_1128_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_CA_DH_AES_CBC_CMAC_128;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1CA_1DH_1AES_1CBC_1CMAC_1192_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_CA_DH_AES_CBC_CMAC_192;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1CA_1DH_1AES_1CBC_1CMAC_1256_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_CA_DH_AES_CBC_CMAC_256;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1CA_1ECDH_13DES_1CBC_1CBC_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_CA_ECDH_3DES_CBC_CBC;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1CA_1ECDH_1AES_1CBC_1CMAC_1128_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_CA_ECDH_AES_CBC_CMAC_128;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1CA_1ECDH_1AES_1CBC_1CMAC_1192_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_CA_ECDH_AES_CBC_CMAC_192;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1CA_1ECDH_1AES_1CBC_1CMAC_1256_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_CA_ECDH_AES_CBC_CMAC_256;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1DH_1SHA_11_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_DH_SHA_1;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1DH_1SHA_1224_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_DH_SHA_224;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1DH_1SHA_1256_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_DH_SHA_256;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1DH_1SHA_1384_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_DH_SHA_384;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1DH_1SHA_1512_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_DH_SHA_512;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1ECDH_1SHA_11_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_ECDH_SHA_1;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1ECDH_1SHA_1224_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_ECDH_SHA_224;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1ECDH_1SHA_1256_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_ECDH_SHA_256;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1ECDH_1SHA_1384_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_ECDH_SHA_384;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_id_1RI_1ECDH_1SHA_1512_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(int)id_RI_ECDH_SHA_512;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_PACE_1MRZ_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  enum s_type result;
  
  (void)jenv;
  (void)jcls;
  result = (enum s_type)PACE_MRZ;
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_PACE_1SEC_1new(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jint jarg3) {
  jlong jresult = 0 ;
  char *arg1 = (char *) 0 ;
  size_t arg2 ;
  enum s_type arg3 ;
  PACE_SEC *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  {
    /* Functions from jni.h */
    arg1 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg1, 0);
    arg2 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg1);
  }
  arg3 = (enum s_type)jarg3; 
  result = (PACE_SEC *)PACE_SEC_new(arg1,arg2,arg3);
  *(PACE_SEC **)&jresult = result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_PACE_1SEC_1clear_1free(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  PACE_SEC *arg1 = (PACE_SEC *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(PACE_SEC **)&jarg1; 
  PACE_SEC_clear_free(arg1);
}


SWIGEXPORT jlong JNICALL Java_eacJNI_PACE_1STEP1_1enc_1nonce(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  PACE_SEC *arg2 = (PACE_SEC *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(PACE_SEC **)&jarg2; 
  result = (BUF_MEM *)PACE_STEP1_enc_nonce((EAC_CTX const *)arg1,(PACE_SEC const *)arg2);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_PACE_1STEP2_1dec_1nonce(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  PACE_SEC *arg2 = (PACE_SEC *) 0 ;
  BUF_MEM *arg3 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(PACE_SEC **)&jarg2; 
  arg3 = *(BUF_MEM **)&jarg3; 
  result = (int)PACE_STEP2_dec_nonce((EAC_CTX const *)arg1,(PACE_SEC const *)arg2,(BUF_MEM const *)arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_PACE_1STEP3A_1generate_1mapping_1data(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (BUF_MEM *)PACE_STEP3A_generate_mapping_data((EAC_CTX const *)arg1);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_PACE_1STEP3A_1map_1generator(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (int)PACE_STEP3A_map_generator((EAC_CTX const *)arg1,(BUF_MEM const *)arg2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_PACE_1STEP3B_1generate_1ephemeral_1key(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (BUF_MEM *)PACE_STEP3B_generate_ephemeral_key(arg1);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_PACE_1STEP3B_1compute_1shared_1secret(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (int)PACE_STEP3B_compute_shared_secret((EAC_CTX const *)arg1,(BUF_MEM const *)arg2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_PACE_1STEP3D_1compute_1authentication_1token(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (BUF_MEM *)PACE_STEP3D_compute_authentication_token((EAC_CTX const *)arg1,arg2);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_PACE_1STEP3D_1verify_1authentication_1token(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (int)PACE_STEP3D_verify_authentication_token((EAC_CTX const *)arg1,(BUF_MEM const *)arg2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_PACE_1STEP3C_1derive_1keys(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (int)PACE_STEP3C_derive_keys((EAC_CTX const *)arg1);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_TA_1disable_1checks(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  TA_disable_checks(arg1);
}


SWIGEXPORT jint JNICALL Java_eacJNI_TA_1STEP2_1import_1certificate(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  unsigned char *arg2 = (unsigned char *) 0 ;
  size_t arg3 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(unsigned char **)&jarg2; 
  arg3 = (size_t)jarg3; 
  result = (int)TA_STEP2_import_certificate((EAC_CTX const *)arg1,(unsigned char const *)arg2,arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_TA_1STEP3_1generate_1ephemeral_1key(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (BUF_MEM *)TA_STEP3_generate_ephemeral_key((EAC_CTX const *)arg1);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_TA_1STEP4_1get_1nonce(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (BUF_MEM *)TA_STEP4_get_nonce((EAC_CTX const *)arg1);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_TA_1STEP4_1set_1nonce(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (int)TA_STEP4_set_nonce((EAC_CTX const *)arg1,(BUF_MEM const *)arg2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_TA_1STEP5_1sign(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jlong jarg4) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM *arg3 = (BUF_MEM *) 0 ;
  BUF_MEM *arg4 = (BUF_MEM *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  arg3 = *(BUF_MEM **)&jarg3; 
  arg4 = *(BUF_MEM **)&jarg4; 
  result = (BUF_MEM *)TA_STEP5_sign((EAC_CTX const *)arg1,(BUF_MEM const *)arg2,(BUF_MEM const *)arg3,(BUF_MEM const *)arg4);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_TA_1STEP6_1verify(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jlong jarg4, jlong jarg5) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM *arg3 = (BUF_MEM *) 0 ;
  BUF_MEM *arg4 = (BUF_MEM *) 0 ;
  BUF_MEM *arg5 = (BUF_MEM *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  arg3 = *(BUF_MEM **)&jarg3; 
  arg4 = *(BUF_MEM **)&jarg4; 
  arg5 = *(BUF_MEM **)&jarg5; 
  result = (int)TA_STEP6_verify((EAC_CTX const *)arg1,(BUF_MEM const *)arg2,(BUF_MEM const *)arg3,(BUF_MEM const *)arg4,(BUF_MEM const *)arg5);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1ID_1PACE_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(0);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1ID_1CA_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(1);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1ID_1TA_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1ID_1EAC_1get(JNIEnv *jenv, jclass jcls) {
  jint jresult = 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  result = (int)(3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_EAC_1CTX_1new(JNIEnv *jenv, jclass jcls) {
  jlong jresult = 0 ;
  EAC_CTX *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  result = (EAC_CTX *)EAC_CTX_new();
  *(EAC_CTX **)&jresult = result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_EAC_1CTX_1clear_1free(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  EAC_CTX_clear_free(arg1);
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1init_1pace(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  int arg2 ;
  int arg3 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = (int)jarg2; 
  arg3 = (int)jarg3; 
  result = (int)EAC_CTX_init_pace(arg1,arg2,arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_EAC_1encrypt(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (BUF_MEM *)EAC_encrypt((EAC_CTX const *)arg1,(BUF_MEM const *)arg2);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_EAC_1decrypt(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (BUF_MEM *)EAC_decrypt((EAC_CTX const *)arg1,(BUF_MEM const *)arg2);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_EAC_1authenticate(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  BUF_MEM *arg2 = (BUF_MEM *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(BUF_MEM **)&jarg2; 
  result = (BUF_MEM *)EAC_authenticate((EAC_CTX const *)arg1,(BUF_MEM const *)arg2);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jlong JNICALL Java_eacJNI_EAC_1Comp(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jlong jarg3) {
  jlong jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  int arg2 ;
  BUF_MEM *arg3 = (BUF_MEM *) 0 ;
  BUF_MEM *result = 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = (int)jarg2; 
  arg3 = *(BUF_MEM **)&jarg3; 
  result = (BUF_MEM *)EAC_Comp((EAC_CTX const *)arg1,arg2,(BUF_MEM const *)arg3);
  *(BUF_MEM **)&jresult = result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1init_1ef_1cardaccess_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jint jresult = 0 ;
  unsigned char *arg1 = (unsigned char *) 0 ;
  size_t arg2 ;
  EAC_CTX *arg3 = (EAC_CTX *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(unsigned char **)&jarg1; 
  arg2 = (size_t)jarg2; 
  arg3 = *(EAC_CTX **)&jarg3; 
  result = (int)EAC_CTX_init_ef_cardaccess(arg1,arg2,arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1init_1ef_1cardsecurity_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3) {
  jint jresult = 0 ;
  unsigned char *arg1 = (unsigned char *) 0 ;
  size_t arg2 ;
  EAC_CTX *arg3 = (EAC_CTX *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(unsigned char **)&jarg1; 
  arg2 = (size_t)jarg2; 
  arg3 = *(EAC_CTX **)&jarg3; 
  result = (int)EAC_CTX_init_ef_cardsecurity(arg1,arg2,arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1init_1ta_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jlong jarg4, jlong jarg5) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  unsigned char *arg2 = (unsigned char *) 0 ;
  size_t arg3 ;
  unsigned char *arg4 = (unsigned char *) 0 ;
  size_t arg5 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = *(unsigned char **)&jarg2; 
  arg3 = (size_t)jarg3; 
  arg4 = *(unsigned char **)&jarg4; 
  arg5 = (size_t)jarg5; 
  result = (int)EAC_CTX_init_ta((EAC_CTX const *)arg1,(unsigned char const *)arg2,arg3,(unsigned char const *)arg4,arg5);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1init_1ef_1cardaccess_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jlong jarg3) {
  jint jresult = 0 ;
  char *arg1 = (char *) 0 ;
  size_t arg2 ;
  EAC_CTX *arg3 = (EAC_CTX *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  {
    /* Functions from jni.h */
    arg1 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg1, 0);
    arg2 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg1);
  }
  arg3 = *(EAC_CTX **)&jarg3; 
  result = (int)eac_ctx_init_ef_cardaccess(arg1,arg2,arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1init_1ef_1cardsecurity_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jbyteArray jarg1, jlong jarg3) {
  jint jresult = 0 ;
  char *arg1 = (char *) 0 ;
  size_t arg2 ;
  EAC_CTX *arg3 = (EAC_CTX *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  {
    /* Functions from jni.h */
    arg1 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg1, 0);
    arg2 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg1);
  }
  arg3 = *(EAC_CTX **)&jarg3; 
  result = (int)eac_ctx_init_ef_cardsecurity(arg1,arg2,arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1init_1ta_1_1SWIG_11(JNIEnv *jenv, jclass jcls, jlong jarg1, jbyteArray jarg2, jbyteArray jarg4) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  char *arg2 = (char *) 0 ;
  size_t arg3 ;
  char *arg4 = (char *) 0 ;
  size_t arg5 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  {
    /* Functions from jni.h */
    arg2 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg2, 0);
    arg3 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg2);
  }
  {
    /* Functions from jni.h */
    arg4 = (char *) (*jenv)->GetByteArrayElements(jenv, jarg4, 0);
    arg5 = (size_t)    (*jenv)->GetArrayLength(jenv, jarg4);
  }
  result = (int)eac_ctx_init_ta((EAC_CTX const *)arg1,arg2,arg3,arg4,arg5);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1init_1ca(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2, jint jarg3) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  int arg2 ;
  int arg3 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = (int)jarg2; 
  arg3 = (int)jarg3; 
  result = (int)EAC_CTX_init_ca(arg1,arg2,arg3);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1CTX_1set_1encryption_1ctx(JNIEnv *jenv, jclass jcls, jlong jarg1, jint jarg2) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  int arg2 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = (int)jarg2; 
  result = (int)EAC_CTX_set_encryption_ctx(arg1,arg2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1increment_1ssc(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (int)EAC_increment_ssc((EAC_CTX const *)arg1);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1reset_1ssc(JNIEnv *jenv, jclass jcls, jlong jarg1) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  result = (int)EAC_reset_ssc((EAC_CTX const *)arg1);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT jint JNICALL Java_eacJNI_EAC_1set_1ssc(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2) {
  jint jresult = 0 ;
  EAC_CTX *arg1 = (EAC_CTX *) 0 ;
  unsigned long arg2 ;
  int result;
  
  (void)jenv;
  (void)jcls;
  arg1 = *(EAC_CTX **)&jarg1; 
  arg2 = (unsigned long)jarg2; 
  result = (int)EAC_set_ssc((EAC_CTX const *)arg1,arg2);
  jresult = (jint)result; 
  return jresult;
}


SWIGEXPORT void JNICALL Java_eacJNI_EAC_1set_1cvc_1default_1dir(JNIEnv *jenv, jclass jcls, jstring jarg1) {
  char *arg1 = (char *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = 0;
  if (jarg1) {
    arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
    if (!arg1) return ;
  }
  EAC_set_cvc_default_dir((char const *)arg1);
  if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
}


SWIGEXPORT void JNICALL Java_eacJNI_EAC_1set_1x509_1default_1dir(JNIEnv *jenv, jclass jcls, jstring jarg1) {
  char *arg1 = (char *) 0 ;
  
  (void)jenv;
  (void)jcls;
  arg1 = 0;
  if (jarg1) {
    arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
    if (!arg1) return ;
  }
  EAC_set_x509_default_dir((char const *)arg1);
  if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
}


#ifdef __cplusplus
}
#endif

