1 /*
2  * Copyright (c) 2006 Kungliga Tekniska H�gskolan
3  * (Royal Institute of Technology, Stockholm, Sweden).
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the Institute nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 
34 /*
35  * $Id: bn.h,v 1.3 2006/01/13 08:27:50 lha Exp $
36  */
37 
38 #ifndef _HEIM_BN_H
39 #define _HEIM_BN_H 1
40 
41 /* symbol renaming */
42 #define BN_GENCB_call hc_BN_GENCB_call
43 #define BN_GENCB_set hc_BN_GENCB_set
44 #define BN_bin2bn hc_BN_bin2bn
45 #define BN_bn2bin hc_BN_bn2bin
46 #define BN_bn2hex hc_BN_bn2hex
47 #define BN_clear hc_BN_clear
48 #define BN_clear_bit hc_BN_clear_bit
49 #define BN_clear_free hc_BN_clear_free
50 #define BN_cmp hc_BN_cmp
51 #define BN_dup hc_BN_dup
52 #define BN_free hc_BN_free
53 #define BN_is_negative hc_BN_is_negative
54 #define BN_get_word hc_BN_get_word
55 #define BN_hex2bn hc_BN_hex2bn
56 #define BN_is_bit_set hc_BN_is_bit_set
57 #define BN_new hc_BN_new
58 #define BN_num_bits hc_BN_num_bits
59 #define BN_num_bytes hc_BN_num_bytes
60 #define BN_rand hc_BN_rand
61 #define BN_set_bit hc_BN_set_bit
62 #define BN_set_negative hc_BN_set_negative
63 #define BN_set_word hc_BN_set_word
64 #define BN_uadd hc_BN_uadd
65 
66 /*
67  *
68  */
69 
70 typedef void BIGNUM;
71 typedef struct BN_GENCB BN_GENCB;
72 typedef void BN_CTX;
73 typedef void BN_MONT_CTX;
74 typedef void BN_BLINDING;
75 
76 struct BN_GENCB {
77     unsigned int ver;
78     void *arg;
79     union {
80 	int (*cb_2)(int, int, BN_GENCB *);
81     } cb;
82 };
83 
84 /*
85  *
86  */
87 
88 BIGNUM *BN_new(void);
89 void	BN_free(BIGNUM *);
90 void	BN_clear_free(BIGNUM *);
91 void	BN_clear(BIGNUM *);
92 BIGNUM *BN_dup(const BIGNUM *);
93 
94 int	BN_num_bits(const BIGNUM *);
95 int	BN_num_bytes(const BIGNUM *);
96 
97 int	BN_cmp(const BIGNUM *, const BIGNUM *);
98 
99 void	BN_set_negative(BIGNUM *, int);
100 int	BN_is_negative(BIGNUM *);
101 
102 int	BN_is_bit_set(const BIGNUM *, int);
103 int	BN_set_bit(BIGNUM *, int);
104 int	BN_clear_bit(BIGNUM *, int);
105 
106 int	BN_set_word(BIGNUM *, unsigned long);
107 unsigned long BN_get_word(const BIGNUM *);
108 
109 BIGNUM *BN_bin2bn(const void *,int len,BIGNUM *);
110 int	BN_bn2bin(const BIGNUM *, void *);
111 int 	BN_hex2bn(BIGNUM **, const char *);
112 char *	BN_bn2hex(const BIGNUM *);
113 
114 int	BN_uadd(BIGNUM *, const BIGNUM *, const BIGNUM *);
115 
116 int	BN_rand(BIGNUM *, int, int, int);
117 
118 void	BN_GENCB_set(BN_GENCB *, int (*)(int, int, BN_GENCB *), void *);
119 int	BN_GENCB_call(BN_GENCB *, int, int);
120 
121 #endif
122