1 use super::super::*; 2 use libc::*; 3 4 #[repr(C)] 5 #[derive(Copy, Clone)] 6 pub enum point_conversion_form_t { 7 POINT_CONVERSION_COMPRESSED = 2, 8 POINT_CONVERSION_UNCOMPRESSED = 4, 9 POINT_CONVERSION_HYBRID = 6, 10 } 11 12 pub enum EC_METHOD {} 13 pub enum EC_GROUP {} 14 pub enum EC_POINT {} 15 16 extern "C" { 17 #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] EC_GF2m_simple_method() -> *const EC_METHOD18 pub fn EC_GF2m_simple_method() -> *const EC_METHOD; 19 EC_GROUP_new(meth: *const EC_METHOD) -> *mut EC_GROUP20 pub fn EC_GROUP_new(meth: *const EC_METHOD) -> *mut EC_GROUP; 21 EC_GROUP_free(group: *mut EC_GROUP)22 pub fn EC_GROUP_free(group: *mut EC_GROUP); 23 EC_GROUP_get_order( group: *const EC_GROUP, order: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int24 pub fn EC_GROUP_get_order( 25 group: *const EC_GROUP, 26 order: *mut BIGNUM, 27 ctx: *mut BN_CTX, 28 ) -> c_int; 29 EC_GROUP_get_cofactor( group: *const EC_GROUP, cofactor: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int30 pub fn EC_GROUP_get_cofactor( 31 group: *const EC_GROUP, 32 cofactor: *mut BIGNUM, 33 ctx: *mut BN_CTX, 34 ) -> c_int; 35 EC_GROUP_get0_generator(group: *const EC_GROUP) -> *const EC_POINT36 pub fn EC_GROUP_get0_generator(group: *const EC_GROUP) -> *const EC_POINT; 37 EC_GROUP_set_generator( group: *mut EC_GROUP, generator: *const EC_POINT, order: *const BIGNUM, cofactor: *const BIGNUM, ) -> c_int38 pub fn EC_GROUP_set_generator( 39 group: *mut EC_GROUP, 40 generator: *const EC_POINT, 41 order: *const BIGNUM, 42 cofactor: *const BIGNUM, 43 ) -> c_int; 44 EC_GROUP_get_curve_name(group: *const EC_GROUP) -> c_int45 pub fn EC_GROUP_get_curve_name(group: *const EC_GROUP) -> c_int; 46 EC_GROUP_set_asn1_flag(key: *mut EC_GROUP, flag: c_int)47 pub fn EC_GROUP_set_asn1_flag(key: *mut EC_GROUP, flag: c_int); 48 EC_GROUP_get_asn1_flag(group: *const EC_GROUP) -> c_int49 pub fn EC_GROUP_get_asn1_flag(group: *const EC_GROUP) -> c_int; 50 EC_GROUP_get_curve_GFp( group: *const EC_GROUP, p: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int51 pub fn EC_GROUP_get_curve_GFp( 52 group: *const EC_GROUP, 53 p: *mut BIGNUM, 54 a: *mut BIGNUM, 55 b: *mut BIGNUM, 56 ctx: *mut BN_CTX, 57 ) -> c_int; 58 59 #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] EC_GROUP_get_curve_GF2m( group: *const EC_GROUP, p: *mut BIGNUM, a: *mut BIGNUM, b: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int60 pub fn EC_GROUP_get_curve_GF2m( 61 group: *const EC_GROUP, 62 p: *mut BIGNUM, 63 a: *mut BIGNUM, 64 b: *mut BIGNUM, 65 ctx: *mut BN_CTX, 66 ) -> c_int; 67 EC_GROUP_get_degree(group: *const EC_GROUP) -> c_int68 pub fn EC_GROUP_get_degree(group: *const EC_GROUP) -> c_int; 69 70 #[cfg(ossl110)] EC_GROUP_order_bits(group: *const EC_GROUP) -> c_int71 pub fn EC_GROUP_order_bits(group: *const EC_GROUP) -> c_int; 72 EC_GROUP_new_curve_GFp( p: *const BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX, ) -> *mut EC_GROUP73 pub fn EC_GROUP_new_curve_GFp( 74 p: *const BIGNUM, 75 a: *const BIGNUM, 76 b: *const BIGNUM, 77 ctx: *mut BN_CTX, 78 ) -> *mut EC_GROUP; 79 80 #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] EC_GROUP_new_curve_GF2m( p: *const BIGNUM, a: *const BIGNUM, b: *const BIGNUM, ctx: *mut BN_CTX, ) -> *mut EC_GROUP81 pub fn EC_GROUP_new_curve_GF2m( 82 p: *const BIGNUM, 83 a: *const BIGNUM, 84 b: *const BIGNUM, 85 ctx: *mut BN_CTX, 86 ) -> *mut EC_GROUP; 87 EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP88 pub fn EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP; 89 EC_POINT_is_at_infinity(group: *const EC_GROUP, point: *const EC_POINT) -> c_int90 pub fn EC_POINT_is_at_infinity(group: *const EC_GROUP, point: *const EC_POINT) -> c_int; 91 EC_POINT_is_on_curve( group: *const EC_GROUP, point: *const EC_POINT, ctx: *mut BN_CTX, ) -> c_int92 pub fn EC_POINT_is_on_curve( 93 group: *const EC_GROUP, 94 point: *const EC_POINT, 95 ctx: *mut BN_CTX, 96 ) -> c_int; 97 EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT98 pub fn EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT; 99 EC_POINT_free(point: *mut EC_POINT)100 pub fn EC_POINT_free(point: *mut EC_POINT); 101 EC_POINT_dup(p: *const EC_POINT, group: *const EC_GROUP) -> *mut EC_POINT102 pub fn EC_POINT_dup(p: *const EC_POINT, group: *const EC_GROUP) -> *mut EC_POINT; 103 104 #[cfg(any(ossl111, boringssl, libressl350))] EC_POINT_get_affine_coordinates( group: *const EC_GROUP, p: *const EC_POINT, x: *mut BIGNUM, y: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int105 pub fn EC_POINT_get_affine_coordinates( 106 group: *const EC_GROUP, 107 p: *const EC_POINT, 108 x: *mut BIGNUM, 109 y: *mut BIGNUM, 110 ctx: *mut BN_CTX, 111 ) -> c_int; 112 EC_POINT_get_affine_coordinates_GFp( group: *const EC_GROUP, p: *const EC_POINT, x: *mut BIGNUM, y: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int113 pub fn EC_POINT_get_affine_coordinates_GFp( 114 group: *const EC_GROUP, 115 p: *const EC_POINT, 116 x: *mut BIGNUM, 117 y: *mut BIGNUM, 118 ctx: *mut BN_CTX, 119 ) -> c_int; 120 EC_POINT_set_affine_coordinates_GFp( group: *const EC_GROUP, p: *mut EC_POINT, x: *const BIGNUM, y: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int121 pub fn EC_POINT_set_affine_coordinates_GFp( 122 group: *const EC_GROUP, 123 p: *mut EC_POINT, 124 x: *const BIGNUM, 125 y: *const BIGNUM, 126 ctx: *mut BN_CTX, 127 ) -> c_int; 128 129 #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))] EC_POINT_get_affine_coordinates_GF2m( group: *const EC_GROUP, p: *const EC_POINT, x: *mut BIGNUM, y: *mut BIGNUM, ctx: *mut BN_CTX, ) -> c_int130 pub fn EC_POINT_get_affine_coordinates_GF2m( 131 group: *const EC_GROUP, 132 p: *const EC_POINT, 133 x: *mut BIGNUM, 134 y: *mut BIGNUM, 135 ctx: *mut BN_CTX, 136 ) -> c_int; 137 EC_POINT_point2oct( group: *const EC_GROUP, p: *const EC_POINT, form: point_conversion_form_t, buf: *mut c_uchar, len: size_t, ctx: *mut BN_CTX, ) -> size_t138 pub fn EC_POINT_point2oct( 139 group: *const EC_GROUP, 140 p: *const EC_POINT, 141 form: point_conversion_form_t, 142 buf: *mut c_uchar, 143 len: size_t, 144 ctx: *mut BN_CTX, 145 ) -> size_t; 146 EC_POINT_oct2point( group: *const EC_GROUP, p: *mut EC_POINT, buf: *const c_uchar, len: size_t, ctx: *mut BN_CTX, ) -> c_int147 pub fn EC_POINT_oct2point( 148 group: *const EC_GROUP, 149 p: *mut EC_POINT, 150 buf: *const c_uchar, 151 len: size_t, 152 ctx: *mut BN_CTX, 153 ) -> c_int; 154 EC_POINT_point2hex( group: *const EC_GROUP, p: *const EC_POINT, form: point_conversion_form_t, ctx: *mut BN_CTX, ) -> *mut c_char155 pub fn EC_POINT_point2hex( 156 group: *const EC_GROUP, 157 p: *const EC_POINT, 158 form: point_conversion_form_t, 159 ctx: *mut BN_CTX, 160 ) -> *mut c_char; 161 EC_POINT_hex2point( group: *const EC_GROUP, s: *const c_char, p: *mut EC_POINT, ctx: *mut BN_CTX, ) -> *mut EC_POINT162 pub fn EC_POINT_hex2point( 163 group: *const EC_GROUP, 164 s: *const c_char, 165 p: *mut EC_POINT, 166 ctx: *mut BN_CTX, 167 ) -> *mut EC_POINT; 168 EC_POINT_add( group: *const EC_GROUP, r: *mut EC_POINT, a: *const EC_POINT, b: *const EC_POINT, ctx: *mut BN_CTX, ) -> c_int169 pub fn EC_POINT_add( 170 group: *const EC_GROUP, 171 r: *mut EC_POINT, 172 a: *const EC_POINT, 173 b: *const EC_POINT, 174 ctx: *mut BN_CTX, 175 ) -> c_int; 176 EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int177 pub fn EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int; 178 EC_POINT_cmp( group: *const EC_GROUP, a: *const EC_POINT, b: *const EC_POINT, ctx: *mut BN_CTX, ) -> c_int179 pub fn EC_POINT_cmp( 180 group: *const EC_GROUP, 181 a: *const EC_POINT, 182 b: *const EC_POINT, 183 ctx: *mut BN_CTX, 184 ) -> c_int; 185 EC_POINT_mul( group: *const EC_GROUP, r: *mut EC_POINT, n: *const BIGNUM, q: *const EC_POINT, m: *const BIGNUM, ctx: *mut BN_CTX, ) -> c_int186 pub fn EC_POINT_mul( 187 group: *const EC_GROUP, 188 r: *mut EC_POINT, 189 n: *const BIGNUM, 190 q: *const EC_POINT, 191 m: *const BIGNUM, 192 ctx: *mut BN_CTX, 193 ) -> c_int; 194 EC_KEY_new() -> *mut EC_KEY195 pub fn EC_KEY_new() -> *mut EC_KEY; 196 EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY197 pub fn EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY; 198 EC_KEY_free(key: *mut EC_KEY)199 pub fn EC_KEY_free(key: *mut EC_KEY); 200 EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY201 pub fn EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY; 202 EC_KEY_up_ref(key: *mut EC_KEY) -> c_int203 pub fn EC_KEY_up_ref(key: *mut EC_KEY) -> c_int; 204 EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP205 pub fn EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP; 206 EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int207 pub fn EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int; 208 EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM209 pub fn EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM; 210 EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int211 pub fn EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int; 212 EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT213 pub fn EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT; 214 EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int215 pub fn EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int; 216 EC_KEY_generate_key(key: *mut EC_KEY) -> c_int217 pub fn EC_KEY_generate_key(key: *mut EC_KEY) -> c_int; 218 EC_KEY_check_key(key: *const EC_KEY) -> c_int219 pub fn EC_KEY_check_key(key: *const EC_KEY) -> c_int; 220 EC_KEY_set_public_key_affine_coordinates( key: *mut EC_KEY, x: *mut BIGNUM, y: *mut BIGNUM, ) -> c_int221 pub fn EC_KEY_set_public_key_affine_coordinates( 222 key: *mut EC_KEY, 223 x: *mut BIGNUM, 224 y: *mut BIGNUM, 225 ) -> c_int; 226 } 227 228 cfg_if! { 229 if #[cfg(any(ossl110, libressl280))] { 230 pub enum ECDSA_SIG {} 231 } else { 232 #[repr(C)] 233 pub struct ECDSA_SIG { 234 pub r: *mut BIGNUM, 235 pub s: *mut BIGNUM, 236 } 237 } 238 } 239 240 extern "C" { ECDSA_SIG_new() -> *mut ECDSA_SIG241 pub fn ECDSA_SIG_new() -> *mut ECDSA_SIG; 242 ECDSA_SIG_free(sig: *mut ECDSA_SIG)243 pub fn ECDSA_SIG_free(sig: *mut ECDSA_SIG); 244 245 #[cfg(any(ossl110, libressl273))] ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM)246 pub fn ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM); 247 248 #[cfg(any(ossl110, libressl273))] ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int249 pub fn ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int; 250 ECDSA_do_sign( dgst: *const c_uchar, dgst_len: c_int, eckey: *mut EC_KEY, ) -> *mut ECDSA_SIG251 pub fn ECDSA_do_sign( 252 dgst: *const c_uchar, 253 dgst_len: c_int, 254 eckey: *mut EC_KEY, 255 ) -> *mut ECDSA_SIG; 256 ECDSA_do_verify( dgst: *const c_uchar, dgst_len: c_int, sig: *const ECDSA_SIG, eckey: *mut EC_KEY, ) -> c_int257 pub fn ECDSA_do_verify( 258 dgst: *const c_uchar, 259 dgst_len: c_int, 260 sig: *const ECDSA_SIG, 261 eckey: *mut EC_KEY, 262 ) -> c_int; 263 d2i_ECDSA_SIG( sig: *mut *mut ECDSA_SIG, inp: *mut *const c_uchar, length: c_long, ) -> *mut ECDSA_SIG264 pub fn d2i_ECDSA_SIG( 265 sig: *mut *mut ECDSA_SIG, 266 inp: *mut *const c_uchar, 267 length: c_long, 268 ) -> *mut ECDSA_SIG; 269 i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int270 pub fn i2d_ECDSA_SIG(sig: *const ECDSA_SIG, out: *mut *mut c_uchar) -> c_int; 271 } 272