]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/CyaSSL/cyassl/openssl/bn.h
0796bab272f6dbc5f63f47b7176ddae389908039
[freertos] / FreeRTOS-Plus / CyaSSL / cyassl / openssl / bn.h
1 /* bn.h for openssl */
2
3
4 #ifndef CYASSL_BN_H_
5 #define CYASSL_BN_H_
6
7 #include <cyassl/ctaocrypt/settings.h>
8
9 #ifdef __cplusplus
10     extern "C" {
11 #endif
12
13 typedef struct CYASSL_BIGNUM {
14     int   neg;              /* openssh deference */
15     void* internal;         /* our big num */
16 } CYASSL_BIGNUM;        
17
18
19 typedef struct CYASSL_BN_CTX CYASSL_BN_CTX;
20
21
22 CYASSL_API CYASSL_BN_CTX* CyaSSL_BN_CTX_new(void);
23 CYASSL_API void           CyaSSL_BN_CTX_init(CYASSL_BN_CTX*);
24 CYASSL_API void           CyaSSL_BN_CTX_free(CYASSL_BN_CTX*);
25
26 CYASSL_API CYASSL_BIGNUM* CyaSSL_BN_new(void);
27 CYASSL_API void           CyaSSL_BN_free(CYASSL_BIGNUM*);
28 CYASSL_API void           CyaSSL_BN_clear_free(CYASSL_BIGNUM*);
29
30
31 CYASSL_API int CyaSSL_BN_sub(CYASSL_BIGNUM*, const CYASSL_BIGNUM*,
32                                  const CYASSL_BIGNUM*);
33 CYASSL_API int CyaSSL_BN_mod(CYASSL_BIGNUM*, const CYASSL_BIGNUM*,
34                                  const CYASSL_BIGNUM*, const CYASSL_BN_CTX*);
35
36 CYASSL_API const CYASSL_BIGNUM* CyaSSL_BN_value_one(void);
37
38
39 CYASSL_API int CyaSSL_BN_num_bytes(const CYASSL_BIGNUM*);
40 CYASSL_API int CyaSSL_BN_num_bits(const CYASSL_BIGNUM*);
41
42 CYASSL_API int CyaSSL_BN_is_zero(const CYASSL_BIGNUM*);
43 CYASSL_API int CyaSSL_BN_is_one(const CYASSL_BIGNUM*);
44 CYASSL_API int CyaSSL_BN_is_odd(const CYASSL_BIGNUM*);
45
46 CYASSL_API int CyaSSL_BN_cmp(const CYASSL_BIGNUM*, const CYASSL_BIGNUM*);
47
48 CYASSL_API int CyaSSL_BN_bn2bin(const CYASSL_BIGNUM*, unsigned char*);
49 CYASSL_API CYASSL_BIGNUM* CyaSSL_BN_bin2bn(const unsigned char*, int len,
50                                     CYASSL_BIGNUM* ret);
51
52 CYASSL_API int CyaSSL_mask_bits(CYASSL_BIGNUM*, int n);
53
54 CYASSL_API int CyaSSL_BN_rand(CYASSL_BIGNUM*, int bits, int top, int bottom);
55 CYASSL_API int CyaSSL_BN_is_bit_set(const CYASSL_BIGNUM*, int n);
56 CYASSL_API int CyaSSL_BN_hex2bn(CYASSL_BIGNUM**, const char* str);
57
58 CYASSL_API CYASSL_BIGNUM* CyaSSL_BN_dup(const CYASSL_BIGNUM*);
59 CYASSL_API CYASSL_BIGNUM* CyaSSL_BN_copy(CYASSL_BIGNUM*, const CYASSL_BIGNUM*);
60
61 CYASSL_API int CyaSSL_BN_set_word(CYASSL_BIGNUM*, unsigned long w);
62
63 CYASSL_API int   CyaSSL_BN_dec2bn(CYASSL_BIGNUM**, const char* str);
64 CYASSL_API char* CyaSSL_BN_bn2dec(const CYASSL_BIGNUM*);
65
66
67 typedef CYASSL_BIGNUM BIGNUM;
68 typedef CYASSL_BN_CTX BN_CTX;
69
70 #define BN_CTX_new        CyaSSL_BN_CTX_new
71 #define BN_CTX_init       CyaSSL_BN_CTX_init
72 #define BN_CTX_free       CyaSSL_BN_CTX_free
73
74 #define BN_new        CyaSSL_BN_new
75 #define BN_free       CyaSSL_BN_free
76 #define BN_clear_free CyaSSL_BN_clear_free
77
78 #define BN_num_bytes CyaSSL_BN_num_bytes
79 #define BN_num_bits  CyaSSL_BN_num_bits
80
81 #define BN_is_zero  CyaSSL_BN_is_zero
82 #define BN_is_one   CyaSSL_BN_is_one
83 #define BN_is_odd   CyaSSL_BN_is_odd
84
85 #define BN_cmp    CyaSSL_BN_cmp
86
87 #define BN_bn2bin  CyaSSL_BN_bn2bin
88 #define BN_bin2bn  CyaSSL_BN_bin2bn
89
90 #define BN_mod       CyaSSL_BN_mod
91 #define BN_sub       CyaSSL_BN_sub
92 #define BN_value_one CyaSSL_BN_value_one
93
94 #define BN_mask_bits CyaSSL_mask_bits
95
96 #define BN_rand       CyaSSL_BN_rand
97 #define BN_is_bit_set CyaSSL_BN_is_bit_set
98 #define BN_hex2bn     CyaSSL_BN_hex2bn
99
100 #define BN_dup  CyaSSL_BN_dup
101 #define BN_copy CyaSSL_BN_copy
102
103 #define BN_set_word CyaSSL_BN_set_word
104
105 #define BN_dec2bn CyaSSL_BN_dec2bn
106 #define BN_bn2dec CyaSSL_BN_bn2dec
107
108
109 #ifdef __cplusplus
110     }  /* extern "C" */ 
111 #endif
112
113
114 #endif /* CYASSL__H_ */
115