summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/hcrypto/bn.h
blob: 92cacec2a66cec0f27738a78967f50d997a09cb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
 * Copyright (c) 2006 Kungliga Tekniska Högskolan
 * (Royal Institute of Technology, Stockholm, Sweden). 
 * All rights reserved. 
 *
 * Redistribution and use in source and binary forms, with or without 
 * modification, are permitted provided that the following conditions 
 * are met: 
 *
 * 1. Redistributions of source code must retain the above copyright 
 *    notice, this list of conditions and the following disclaimer. 
 *
 * 2. Redistributions in binary form must reproduce the above copyright 
 *    notice, this list of conditions and the following disclaimer in the 
 *    documentation and/or other materials provided with the distribution. 
 *
 * 3. Neither the name of the Institute nor the names of its contributors 
 *    may be used to endorse or promote products derived from this software 
 *    without specific prior written permission. 
 *
 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
 * SUCH DAMAGE. 
 */

/*
 * $Id: bn.h 22260 2007-12-09 06:23:47Z lha $
 */

#ifndef _HEIM_BN_H
#define _HEIM_BN_H 1

/* symbol renaming */
#define BN_GENCB_call hc_BN_GENCB_call
#define BN_GENCB_set hc_BN_GENCB_set
#define BN_bin2bn hc_BN_bin2bn
#define BN_bn2bin hc_BN_bn2bin
#define BN_bn2hex hc_BN_bn2hex
#define BN_clear hc_BN_clear
#define BN_clear_bit hc_BN_clear_bit
#define BN_clear_free hc_BN_clear_free
#define BN_cmp hc_BN_cmp
#define BN_dup hc_BN_dup
#define BN_free hc_BN_free
#define BN_is_negative hc_BN_is_negative
#define BN_get_word hc_BN_get_word
#define BN_hex2bn hc_BN_hex2bn
#define BN_is_bit_set hc_BN_is_bit_set
#define BN_new hc_BN_new
#define BN_num_bits hc_BN_num_bits
#define BN_num_bytes hc_BN_num_bytes
#define BN_rand hc_BN_rand
#define BN_set_bit hc_BN_set_bit
#define BN_set_negative hc_BN_set_negative
#define BN_set_word hc_BN_set_word
#define BN_uadd hc_BN_uadd

/*
 *
 */

typedef void BIGNUM;
typedef struct BN_GENCB BN_GENCB;
typedef void BN_CTX;
typedef void BN_MONT_CTX;
typedef void BN_BLINDING;

struct BN_GENCB {
    unsigned int ver;
    void *arg;
    union {
	int (*cb_2)(int, int, BN_GENCB *);
    } cb;
};

/*
 *
 */

BIGNUM *BN_new(void);
void	BN_free(BIGNUM *);
void	BN_clear_free(BIGNUM *);
void	BN_clear(BIGNUM *);
BIGNUM *BN_dup(const BIGNUM *);

int	BN_num_bits(const BIGNUM *);
int	BN_num_bytes(const BIGNUM *);

int	BN_cmp(const BIGNUM *, const BIGNUM *);

void	BN_set_negative(BIGNUM *, int);
int	BN_is_negative(const BIGNUM *);

int	BN_is_bit_set(const BIGNUM *, int);
int	BN_set_bit(BIGNUM *, int);
int	BN_clear_bit(BIGNUM *, int);

int	BN_set_word(BIGNUM *, unsigned long);
unsigned long BN_get_word(const BIGNUM *);

BIGNUM *BN_bin2bn(const void *,int len,BIGNUM *);
int	BN_bn2bin(const BIGNUM *, void *);
int 	BN_hex2bn(BIGNUM **, const char *);
char *	BN_bn2hex(const BIGNUM *);

int	BN_uadd(BIGNUM *, const BIGNUM *, const BIGNUM *);

int	BN_rand(BIGNUM *, int, int, int);

void	BN_GENCB_set(BN_GENCB *, int (*)(int, int, BN_GENCB *), void *);
int	BN_GENCB_call(BN_GENCB *, int, int);

#endif