aboutsummaryrefslogtreecommitdiff
path: root/openssl-sys/src/ec.rs
diff options
context:
space:
mode:
authorSteven Fackler <[email protected]>2018-09-12 20:02:40 -0700
committerGitHub <[email protected]>2018-09-12 20:02:40 -0700
commita29c789e5769169bc338d2ea4773603b674edc9d (patch)
tree2f3c49b218a501b7ec549a1f1fdfeaa37a0186df /openssl-sys/src/ec.rs
parentBump to 1.1.1 release (diff)
parentRefactor openssl-sys (diff)
downloadrust-openssl-a29c789e5769169bc338d2ea4773603b674edc9d.tar.xz
rust-openssl-a29c789e5769169bc338d2ea4773603b674edc9d.zip
Merge pull request #990 from sfackler/one-sys-mod
Refactor openssl-sys
Diffstat (limited to 'openssl-sys/src/ec.rs')
-rw-r--r--openssl-sys/src/ec.rs203
1 files changed, 203 insertions, 0 deletions
diff --git a/openssl-sys/src/ec.rs b/openssl-sys/src/ec.rs
new file mode 100644
index 00000000..3eea0d24
--- /dev/null
+++ b/openssl-sys/src/ec.rs
@@ -0,0 +1,203 @@
+use libc::*;
+
+use *;
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub enum point_conversion_form_t {
+ POINT_CONVERSION_COMPRESSED = 2,
+ POINT_CONVERSION_UNCOMPRESSED = 4,
+ POINT_CONVERSION_HYBRID = 6,
+}
+
+pub enum EC_METHOD {}
+pub enum EC_GROUP {}
+pub enum EC_POINT {}
+
+pub const OPENSSL_EC_NAMED_CURVE: c_int = 1;
+
+extern "C" {
+ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
+ pub fn EC_GF2m_simple_method() -> *const EC_METHOD;
+
+ pub fn EC_GROUP_new(meth: *const EC_METHOD) -> *mut EC_GROUP;
+
+ pub fn EC_GROUP_free(group: *mut EC_GROUP);
+
+ pub fn EC_GROUP_get_order(
+ group: *const EC_GROUP,
+ order: *mut BIGNUM,
+ ctx: *mut BN_CTX,
+ ) -> c_int;
+
+ pub fn EC_GROUP_set_asn1_flag(key: *mut EC_GROUP, flag: c_int);
+
+ pub fn EC_GROUP_get_curve_GFp(
+ group: *const EC_GROUP,
+ p: *mut BIGNUM,
+ a: *mut BIGNUM,
+ b: *mut BIGNUM,
+ ctx: *mut BN_CTX,
+ ) -> c_int;
+
+ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
+ pub fn EC_GROUP_get_curve_GF2m(
+ group: *const EC_GROUP,
+ p: *mut BIGNUM,
+ a: *mut BIGNUM,
+ b: *mut BIGNUM,
+ ctx: *mut BN_CTX,
+ ) -> c_int;
+
+ pub fn EC_GROUP_get_degree(group: *const EC_GROUP) -> c_int;
+
+ pub fn EC_GROUP_new_curve_GFp(
+ p: *const BIGNUM,
+ a: *const BIGNUM,
+ b: *const BIGNUM,
+ ctx: *mut BN_CTX,
+ ) -> *mut EC_GROUP;
+
+ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
+ pub fn EC_GROUP_new_curve_GF2m(
+ p: *const BIGNUM,
+ a: *const BIGNUM,
+ b: *const BIGNUM,
+ ctx: *mut BN_CTX,
+ ) -> *mut EC_GROUP;
+
+ pub fn EC_GROUP_new_by_curve_name(nid: c_int) -> *mut EC_GROUP;
+
+ pub fn EC_POINT_new(group: *const EC_GROUP) -> *mut EC_POINT;
+
+ pub fn EC_POINT_free(point: *mut EC_POINT);
+
+ pub fn 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_int;
+
+ #[cfg(not(osslconf = "OPENSSL_NO_EC2M"))]
+ pub fn 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_int;
+
+ pub fn 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_t;
+
+ pub fn EC_POINT_oct2point(
+ group: *const EC_GROUP,
+ p: *mut EC_POINT,
+ buf: *const c_uchar,
+ len: size_t,
+ ctx: *mut BN_CTX,
+ ) -> c_int;
+
+ pub fn EC_POINT_add(
+ group: *const EC_GROUP,
+ r: *mut EC_POINT,
+ a: *const EC_POINT,
+ b: *const EC_POINT,
+ ctx: *mut BN_CTX,
+ ) -> c_int;
+
+ pub fn EC_POINT_invert(group: *const EC_GROUP, r: *mut EC_POINT, ctx: *mut BN_CTX) -> c_int;
+
+ pub fn EC_POINT_cmp(
+ group: *const EC_GROUP,
+ a: *const EC_POINT,
+ b: *const EC_POINT,
+ ctx: *mut BN_CTX,
+ ) -> c_int;
+
+ pub fn 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_int;
+
+ pub fn EC_KEY_new() -> *mut EC_KEY;
+
+ pub fn EC_KEY_new_by_curve_name(nid: c_int) -> *mut EC_KEY;
+
+ pub fn EC_KEY_free(key: *mut EC_KEY);
+
+ pub fn EC_KEY_dup(key: *const EC_KEY) -> *mut EC_KEY;
+
+ pub fn EC_KEY_up_ref(key: *mut EC_KEY) -> c_int;
+
+ pub fn EC_KEY_get0_group(key: *const EC_KEY) -> *const EC_GROUP;
+
+ pub fn EC_KEY_set_group(key: *mut EC_KEY, group: *const EC_GROUP) -> c_int;
+
+ pub fn EC_KEY_get0_private_key(key: *const EC_KEY) -> *const BIGNUM;
+
+ pub fn EC_KEY_set_private_key(key: *mut EC_KEY, key: *const BIGNUM) -> c_int;
+
+ pub fn EC_KEY_get0_public_key(key: *const EC_KEY) -> *const EC_POINT;
+
+ pub fn EC_KEY_set_public_key(key: *mut EC_KEY, key: *const EC_POINT) -> c_int;
+
+ pub fn EC_KEY_generate_key(key: *mut EC_KEY) -> c_int;
+
+ pub fn EC_KEY_check_key(key: *const EC_KEY) -> c_int;
+
+ pub fn EC_KEY_set_public_key_affine_coordinates(
+ key: *mut EC_KEY,
+ x: *mut BIGNUM,
+ y: *mut BIGNUM,
+ ) -> c_int;
+}
+
+cfg_if! {
+ if #[cfg(ossl110)] {
+ pub enum ECDSA_SIG {}
+ } else {
+ #[repr(C)]
+ pub struct ECDSA_SIG {
+ pub r: *mut BIGNUM,
+ pub s: *mut BIGNUM,
+ }
+ }
+}
+
+extern "C" {
+ pub fn ECDSA_SIG_new() -> *mut ECDSA_SIG;
+
+ pub fn ECDSA_SIG_free(sig: *mut ECDSA_SIG);
+
+ #[cfg(any(ossl110, libressl273))]
+ pub fn ECDSA_SIG_get0(sig: *const ECDSA_SIG, pr: *mut *const BIGNUM, ps: *mut *const BIGNUM);
+
+ #[cfg(any(ossl110, libressl273))]
+ pub fn ECDSA_SIG_set0(sig: *mut ECDSA_SIG, pr: *mut BIGNUM, ps: *mut BIGNUM) -> c_int;
+
+ pub fn ECDSA_do_sign(
+ dgst: *const c_uchar,
+ dgst_len: c_int,
+ eckey: *mut EC_KEY,
+ ) -> *mut ECDSA_SIG;
+
+ pub fn ECDSA_do_verify(
+ dgst: *const c_uchar,
+ dgst_len: c_int,
+ sig: *const ECDSA_SIG,
+ eckey: *mut EC_KEY,
+ ) -> c_int;
+}