#ifndef FAUXBN_H_
#define FAUXBN_H_ 20100108
#include <sys/types.h>
#include <inttypes.h>
#include <stdio.h>
#ifndef __BEGIN_DECLS
# if defined(__cplusplus)
# define __BEGIN_DECLS extern "C" {
# define __END_DECLS }
# else
# define __BEGIN_DECLS
# define __END_DECLS
# endif
#endif
__BEGIN_DECLS
typedef unsigned long mp_digit;
typedef uint64_t mp_word;
typedef struct mp_int {
mp_digit *dp;
int used;
int alloc;
int sign;
} mp_int;
#define BIGNUM mp_int
#define BN_ULONG mp_digit
typedef struct bn_ctx_t {
size_t count;
size_t arraysize;
BIGNUM **v;
} BN_CTX;
#define MP_LT -1
#define MP_EQ 0
#define MP_GT 1
#define MP_ZPOS 0
#define MP_NEG 1
#define MP_OKAY 0
#define MP_MEM -2
#define MP_VAL -3
#define MP_RANGE MP_VAL
#define BN_is_negative(x) ((x)->sign == MP_NEG)
#define BN_is_zero(a) (((a)->used == 0) ? 1 : 0)
#define BN_is_odd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? 1 : 0)
#define BN_is_even(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 0)) ? 1 : 0)
BIGNUM *BN_new(void);
BIGNUM *BN_dup(const BIGNUM *);
int BN_copy(BIGNUM *, const BIGNUM *);
void BN_init(BIGNUM *);
void BN_free(BIGNUM *);
void BN_clear(BIGNUM *);
void BN_clear_free(BIGNUM *);
int BN_cmp(BIGNUM *, BIGNUM *);
BIGNUM *BN_bin2bn(const uint8_t *, int , BIGNUM *);
int BN_bn2bin(const BIGNUM *, unsigned char *);
char *BN_bn2hex(const BIGNUM *);
char *BN_bn2dec(const BIGNUM *);
char *BN_bn2radix(const BIGNUM *, unsigned );
int BN_hex2bn(BIGNUM **, const char *);
int BN_dec2bn(BIGNUM **, const char *);
int BN_radix2bn(BIGNUM **, const char *, unsigned );
int BN_print_fp(FILE *, const BIGNUM *);
int BN_add(BIGNUM *, const BIGNUM *, const BIGNUM *);
int BN_sub(BIGNUM *, const BIGNUM *, const BIGNUM *);
int BN_mul(BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
int BN_div(BIGNUM *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *);
void BN_swap(BIGNUM *, BIGNUM *);
int BN_bitop(BIGNUM *, const BIGNUM *, char , const BIGNUM *);
int BN_lshift(BIGNUM *, const BIGNUM *, int );
int BN_lshift1(BIGNUM *, BIGNUM *);
int BN_rshift(BIGNUM *, const BIGNUM *, int );
int BN_rshift1(BIGNUM *, BIGNUM *);
int BN_set_word(BIGNUM *, BN_ULONG );
void BN_set_negative(BIGNUM *, int );
int BN_num_bytes(const BIGNUM *);
int BN_num_bits(const BIGNUM *);
int BN_mod_exp(BIGNUM *, BIGNUM *, BIGNUM *, BIGNUM *, BN_CTX *);
BIGNUM *BN_mod_inverse(BIGNUM *, BIGNUM *, const BIGNUM *, BN_CTX *);
int BN_mod_mul(BIGNUM *, BIGNUM *, BIGNUM *, const BIGNUM *, BN_CTX *);
int BN_mod_sub(BIGNUM *, BIGNUM *, BIGNUM *, const BIGNUM *, BN_CTX *);
int BN_raise(BIGNUM *, BIGNUM *, BIGNUM *);
int BN_factorial(BIGNUM *, BIGNUM *);
BN_CTX *BN_CTX_new(void);
BIGNUM *BN_CTX_get(BN_CTX *);
void BN_CTX_start(BN_CTX *);
void BN_CTX_end(BN_CTX *);
void BN_CTX_init(BN_CTX *);
void BN_CTX_free(BN_CTX *);
int BN_rand(BIGNUM *, int , int , int );
int BN_rand_range(BIGNUM *, BIGNUM *);
int BN_is_prime(const BIGNUM *, int , void (*callback)(int, int, void *), BN_CTX *, void *);
const BIGNUM *BN_value_one(void);
int BN_is_bit_set(const BIGNUM *, int );
int BN_gcd(BIGNUM *, BIGNUM *, BIGNUM *, BN_CTX *);
int humanize_bignum(char *, size_t, const BIGNUM *, const char *, int, int);
__END_DECLS
#endif