summaryrefslogtreecommitdiff
path: root/openssl/src/ec.rs
diff options
context:
space:
mode:
authorSteven Fackler <sfackler@gmail.com>2017-12-25 19:38:00 -0700
committerSteven Fackler <sfackler@gmail.com>2017-12-25 19:38:11 -0700
commitbbae793eb3ba06e5ad8813ce8182e52fb4a2abd3 (patch)
treeed619314cb51bc7597c3ac1a4ab3ea864f766d24 /openssl/src/ec.rs
parent2aaba8bd7ac9953edc0d86f9575862412ac26d98 (diff)
downloadrust-openssl-bbae793eb3ba06e5ad8813ce8182e52fb4a2abd3.zip
Upgrade bitflags to 1.0
Closes #756
Diffstat (limited to 'openssl/src/ec.rs')
-rw-r--r--openssl/src/ec.rs65
1 files changed, 32 insertions, 33 deletions
diff --git a/openssl/src/ec.rs b/openssl/src/ec.rs
index 97b095d0..37a33cb4 100644
--- a/openssl/src/ec.rs
+++ b/openssl/src/ec.rs
@@ -20,10 +20,10 @@
//!
//! ```
//! use openssl::ec::{EcGroup, EcPoint};
-//! use openssl::nid;
+//! use openssl::nid::Nid;
//! use openssl::error::ErrorStack;
-//! fn get_ec_point() -> Result< EcPoint, ErrorStack > {
-//! let group = EcGroup::from_curve_name(nid::SECP224R1)?;
+//! fn get_ec_point() -> Result<EcPoint, ErrorStack> {
+//! let group = EcGroup::from_curve_name(Nid::SECP224R1)?;
//! let point = EcPoint::new(&group)?;
//! Ok(point)
//! }
@@ -38,7 +38,7 @@ use std::mem;
use libc::c_int;
use {cvt, cvt_n, cvt_p, init};
-use bn::{BigNumRef, BigNumContextRef};
+use bn::{BigNumContextRef, BigNumRef};
use error::ErrorStack;
use nid::Nid;
@@ -606,14 +606,14 @@ impl EcKey {
/// ```no_run
/// use openssl::bn::BigNumContext;
/// use openssl::ec::*;
- /// use openssl::nid;
+ /// use openssl::nid::Nid;
/// use openssl::pkey::PKey;
///
/// // get bytes from somewhere, i.e. this will not produce a valid key
/// let public_key: Vec<u8> = vec![];
///
/// // create an EcKey from the binary form of a EcPoint
- /// let group = EcGroup::from_curve_name(nid::SECP256K1).unwrap();
+ /// let group = EcGroup::from_curve_name(Nid::SECP256K1).unwrap();
/// let mut ctx = BigNumContext::new().unwrap();
/// let point = EcPoint::from_bytes(&group, &public_key, &mut ctx).unwrap();
/// let key = EcKey::from_public_key(&group, &point);
@@ -645,7 +645,6 @@ impl EcKey {
private_key_from_der!(EcKey, ffi::d2i_ECPrivateKey);
}
-
foreign_type_and_impl_send_sync! {
type CType = ffi::EC_KEY;
fn drop = ffi::EC_KEY_free;
@@ -731,18 +730,18 @@ impl EcKeyBuilderRef {
#[cfg(test)]
mod test {
use bn::{BigNum, BigNumContext};
- use nid;
+ use nid::Nid;
use data_encoding::BASE64URL_NOPAD;
use super::*;
#[test]
fn key_new_by_curve_name() {
- EcKey::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
+ EcKey::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
}
#[test]
fn generate() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
let key = EcKey::generate(&group).unwrap();
key.public_key().unwrap();
key.private_key().unwrap();
@@ -750,20 +749,20 @@ mod test {
#[test]
fn dup() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
let key = EcKey::generate(&group).unwrap();
key.to_owned().unwrap();
}
#[test]
fn point_new() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
EcPoint::new(&group).unwrap();
}
#[test]
fn point_bytes() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
let key = EcKey::generate(&group).unwrap();
let point = key.public_key().unwrap();
let mut ctx = BigNumContext::new().unwrap();
@@ -776,7 +775,7 @@ mod test {
#[test]
fn mul_generator() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
let key = EcKey::generate(&group).unwrap();
let mut ctx = BigNumContext::new().unwrap();
let mut public_key = EcPoint::new(&group).unwrap();
@@ -792,7 +791,7 @@ mod test {
#[test]
fn key_from_public_key() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
let key = EcKey::generate(&group).unwrap();
let mut ctx = BigNumContext::new().unwrap();
let bytes = key.public_key()
@@ -810,13 +809,13 @@ mod test {
#[test]
fn key_from_affine_coordinates() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
- let x = BASE64URL_NOPAD.decode(
- "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4".as_bytes(),
- ).unwrap();
- let y = BASE64URL_NOPAD.decode(
- "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM".as_bytes(),
- ).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
+ let x = BASE64URL_NOPAD
+ .decode("MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4".as_bytes())
+ .unwrap();
+ let y = BASE64URL_NOPAD
+ .decode("4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM".as_bytes())
+ .unwrap();
let xbn = BigNum::from_slice(&x).unwrap();
let ybn = BigNum::from_slice(&y).unwrap();
@@ -834,10 +833,10 @@ mod test {
#[test]
fn set_private_key() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
- let d = BASE64URL_NOPAD.decode(
- "870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE".as_bytes(),
- ).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
+ let d = BASE64URL_NOPAD
+ .decode("870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE".as_bytes())
+ .unwrap();
let dbn = BigNum::from_slice(&d).unwrap();
@@ -851,13 +850,13 @@ mod test {
#[test]
fn get_affine_coordinates() {
- let group = EcGroup::from_curve_name(nid::X9_62_PRIME256V1).unwrap();
- let x = BASE64URL_NOPAD.decode(
- "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4".as_bytes(),
- ).unwrap();
- let y = BASE64URL_NOPAD.decode(
- "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM".as_bytes(),
- ).unwrap();
+ let group = EcGroup::from_curve_name(Nid::X9_62_PRIME256V1).unwrap();
+ let x = BASE64URL_NOPAD
+ .decode("MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4".as_bytes())
+ .unwrap();
+ let y = BASE64URL_NOPAD
+ .decode("4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM".as_bytes())
+ .unwrap();
let xbn = BigNum::from_slice(&x).unwrap();
let ybn = BigNum::from_slice(&y).unwrap();