Skip to main content

botan_sys/
ec_group.rs

1use crate::ffi_types::{botan_view_bin_fn, botan_view_ctx, botan_view_str_fn, c_char, c_int};
2use crate::{botan_asn1_oid_t, botan_mp_t};
3
4use crate::rng::botan_rng_t;
5
6pub enum botan_ec_group_struct {}
7
8pub type botan_ec_group_t = *mut botan_ec_group_struct;
9
10pub enum botan_ec_scalar_struct {}
11pub type botan_ec_scalar_t = *mut botan_ec_scalar_struct;
12
13pub enum botan_ec_point_struct {}
14pub type botan_ec_point_t = *mut botan_ec_point_struct;
15
16botan_ffi_functions! {
17    #[cfg(botan_ffi_20250506)]
18    pub fn botan_ec_group_destroy(bc: botan_ec_group_t) -> c_int;
19
20    #[cfg(botan_ffi_20250506)]
21    pub fn botan_ec_group_supports_application_specific_group(res: *mut c_int) -> c_int;
22
23    #[cfg(botan_ffi_20250506)]
24    pub fn botan_ec_group_supports_named_group(name: *const c_char, res: *mut c_int) -> c_int;
25
26    #[cfg(botan_ffi_20250506)]
27    pub fn botan_ec_group_from_params(
28        group: *mut botan_ec_group_t,
29        oid: botan_asn1_oid_t,
30        p: botan_mp_t,
31        a: botan_mp_t,
32        b: botan_mp_t,
33        g_x: botan_mp_t,
34        g_y: botan_mp_t,
35        order: botan_mp_t,
36    ) -> c_int;
37
38    #[cfg(botan_ffi_20250506)]
39    pub fn botan_ec_group_from_ber(
40        group: *mut botan_ec_group_t,
41        ber: *const u8,
42        ber_len: usize,
43    ) -> c_int;
44    #[cfg(botan_ffi_20250506)]
45    pub fn botan_ec_group_from_pem(group: *mut botan_ec_group_t, pem: *const c_char) -> c_int;
46    #[cfg(botan_ffi_20250506)]
47    pub fn botan_ec_group_from_oid(group: *mut botan_ec_group_t, oid: botan_asn1_oid_t) -> c_int;
48    #[cfg(botan_ffi_20250506)]
49    pub fn botan_ec_group_from_name(group: *mut botan_ec_group_t, name: *const c_char) -> c_int;
50
51    #[cfg(botan_ffi_20250506)]
52    pub fn botan_ec_group_view_der(
53        group: botan_ec_group_t,
54        ctx: botan_view_ctx,
55        view: botan_view_bin_fn,
56    ) -> c_int;
57    #[cfg(botan_ffi_20250506)]
58    pub fn botan_ec_group_view_pem(
59        group: botan_ec_group_t,
60        ctx: botan_view_ctx,
61        view: botan_view_str_fn,
62    ) -> c_int;
63    #[cfg(botan_ffi_20250506)]
64    pub fn botan_ec_group_get_curve_oid(
65        oid: *mut botan_asn1_oid_t,
66        group: botan_ec_group_t,
67    ) -> c_int;
68    #[cfg(botan_ffi_20250506)]
69    pub fn botan_ec_group_get_p(p: *mut botan_mp_t, group: botan_ec_group_t) -> c_int;
70
71    #[cfg(botan_ffi_20250506)]
72    pub fn botan_ec_group_get_a(a: *mut botan_mp_t, group: botan_ec_group_t) -> c_int;
73
74    #[cfg(botan_ffi_20250506)]
75    pub fn botan_ec_group_get_b(b: *mut botan_mp_t, group: botan_ec_group_t) -> c_int;
76
77    #[cfg(botan_ffi_20250506)]
78    pub fn botan_ec_group_get_g_x(g_x: *mut botan_mp_t, group: botan_ec_group_t) -> c_int;
79
80    #[cfg(botan_ffi_20250506)]
81    pub fn botan_ec_group_get_g_y(g_y: *mut botan_mp_t, group: botan_ec_group_t) -> c_int;
82
83    #[cfg(botan_ffi_20250506)]
84    pub fn botan_ec_group_get_order(order: *mut botan_mp_t, group: botan_ec_group_t) -> c_int;
85
86    #[cfg(botan_ffi_20250506)]
87    pub fn botan_ec_group_equal(group1: botan_ec_group_t, group2: botan_ec_group_t) -> c_int;
88
89    #[cfg(botan_ffi_20260303)]
90    pub fn botan_ec_group_unregister(oid: botan_asn1_oid_t) -> c_int;
91}
92
93botan_ffi_functions! {
94    #[cfg(botan_ffi_20260506)]
95    pub fn botan_ec_scalar_destroy(ec_scalar: botan_ec_scalar_t) -> c_int;
96
97    #[cfg(botan_ffi_20260506)]
98    pub fn botan_ec_scalar_random(
99        ec_scalar: *mut botan_ec_scalar_t,
100        ec_group: botan_ec_group_t,
101        rng: botan_rng_t,
102    ) -> c_int;
103
104    #[cfg(botan_ffi_20260506)]
105    pub fn botan_ec_scalar_from_mp(
106        ec_scalar: *mut botan_ec_scalar_t,
107        ec_group: botan_ec_group_t,
108        mp: botan_mp_t,
109    ) -> c_int;
110
111    #[cfg(botan_ffi_20260506)]
112    pub fn botan_ec_scalar_to_mp(ec_scalar: botan_ec_scalar_t, mp: *mut botan_mp_t) -> c_int;
113
114    #[cfg(botan_ffi_20260506)]
115    pub fn botan_ec_point_destroy(ec_point: botan_ec_point_t) -> c_int;
116
117    #[cfg(botan_ffi_20260506)]
118    pub fn botan_ec_point_identity(
119        ec_point: *mut botan_ec_point_t,
120        ec_group: botan_ec_group_t,
121    ) -> c_int;
122
123    #[cfg(botan_ffi_20260506)]
124    pub fn botan_ec_point_generator(
125        ec_point: *mut botan_ec_point_t,
126        ec_group: botan_ec_group_t,
127    ) -> c_int;
128
129    #[cfg(botan_ffi_20260506)]
130    pub fn botan_ec_point_from_xy(
131        ec_point: *mut botan_ec_point_t,
132        ec_group: botan_ec_group_t,
133        x: botan_mp_t,
134        y: botan_mp_t,
135    ) -> c_int;
136
137    #[cfg(botan_ffi_20260506)]
138    pub fn botan_ec_point_from_bytes(
139        ec_point: *mut botan_ec_point_t,
140        ec_group: botan_ec_group_t,
141        bytes: *const u8,
142        bytes_len: usize,
143    ) -> c_int;
144
145    #[cfg(botan_ffi_20260506)]
146    pub fn botan_ec_point_view_x_bytes(
147        ec_point: botan_ec_point_t,
148        ctx: botan_view_ctx,
149        view: botan_view_bin_fn,
150    ) -> c_int;
151
152    #[cfg(botan_ffi_20260506)]
153    pub fn botan_ec_point_view_y_bytes(
154        ec_point: botan_ec_point_t,
155        ctx: botan_view_ctx,
156        view: botan_view_bin_fn,
157    ) -> c_int;
158
159    #[cfg(botan_ffi_20260506)]
160    pub fn botan_ec_point_view_xy_bytes(
161        ec_point: botan_ec_point_t,
162        ctx: botan_view_ctx,
163        view: botan_view_bin_fn,
164    ) -> c_int;
165
166    #[cfg(botan_ffi_20260506)]
167    pub fn botan_ec_point_view_uncompressed(
168        ec_point: botan_ec_point_t,
169        ctx: botan_view_ctx,
170        view: botan_view_bin_fn,
171    ) -> c_int;
172
173    #[cfg(botan_ffi_20260506)]
174    pub fn botan_ec_point_view_compressed(
175        ec_point: botan_ec_point_t,
176        ctx: botan_view_ctx,
177        view: botan_view_bin_fn,
178    ) -> c_int;
179
180    #[cfg(botan_ffi_20260506)]
181    pub fn botan_ec_point_is_identity(ec_point: botan_ec_point_t) -> c_int;
182
183    #[cfg(botan_ffi_20260506)]
184    pub fn botan_ec_point_equal(x: botan_ec_point_t, y: botan_ec_point_t) -> c_int;
185
186    #[cfg(botan_ffi_20260506)]
187    pub fn botan_ec_point_negate(
188        result: *mut botan_ec_point_t,
189        ec_point: botan_ec_point_t,
190    ) -> c_int;
191
192    #[cfg(botan_ffi_20260506)]
193    pub fn botan_ec_point_add(
194        result: *mut botan_ec_point_t,
195        x: botan_ec_point_t,
196        y: botan_ec_point_t,
197    ) -> c_int;
198
199    #[cfg(botan_ffi_20260506)]
200    pub fn botan_ec_point_mul(
201        result: *mut botan_ec_point_t,
202        ec_point: botan_ec_point_t,
203        ec_scalar: botan_ec_scalar_t,
204        rng: botan_rng_t,
205    ) -> c_int;
206}