Loading openssl/src/pkey.rs +19 −19 Original line number Diff line number Diff line Loading @@ -70,26 +70,26 @@ pub enum Public {} /// A tag type indicating that a key has private components. pub enum Private {} /// The Oids that identify the type of a key. /// An identifier of a kind of key. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct Oid(c_int); pub struct Id(c_int); impl Oid { /// Creates a `Oid` from an integer representation. pub fn from_raw(value: c_int) -> Oid { Oid(value) impl Id { /// Creates a `Id` from an integer representation. pub fn from_raw(value: c_int) -> Id { Id(value) } /// Returns the integer representation of `Oid`. /// Returns the integer representation of the `Id`. pub fn as_raw(&self) -> c_int { self.0 } pub const RSA: Oid = Oid(ffi::EVP_PKEY_RSA); pub const HMAC: Oid = Oid(ffi::EVP_PKEY_HMAC); pub const DSA: Oid = Oid(ffi::EVP_PKEY_DSA); pub const DH: Oid = Oid(ffi::EVP_PKEY_DH); pub const EC: Oid = Oid(ffi::EVP_PKEY_EC); pub const RSA: Id = Id(ffi::EVP_PKEY_RSA); pub const HMAC: Id = Id(ffi::EVP_PKEY_HMAC); pub const DSA: Id = Id(ffi::EVP_PKEY_DSA); pub const DH: Id = Id(ffi::EVP_PKEY_DH); pub const EC: Id = Id(ffi::EVP_PKEY_EC); } /// A trait indicating that a key has parameters. Loading Loading @@ -178,14 +178,14 @@ impl<T> PKeyRef<T> { } } /// Returns the Oid that represents the type of this key. /// Returns the `Id` that represents the type of this key. /// /// This corresponds to [`EVP_PKEY_id`]. /// /// [`EVP_PKEY_id`]: https://www.openssl.org/docs/man1.1.0/crypto/EVP_PKEY_id.html pub fn oid(&self) -> Oid { pub fn id(&self) -> Id { unsafe { Oid::from_raw(ffi::EVP_PKEY_id(self.as_ptr())) Id::from_raw(ffi::EVP_PKEY_id(self.as_ptr())) } } } Loading Loading @@ -564,7 +564,7 @@ mod tests { let rsa = Rsa::generate(2048).unwrap(); let pkey = PKey::from_rsa(rsa).unwrap(); pkey.rsa().unwrap(); assert_eq!(pkey.oid(), Oid::RSA); assert_eq!(pkey.id(), Id::RSA); assert!(pkey.dsa().is_err()); } Loading @@ -573,7 +573,7 @@ mod tests { let dsa = Dsa::generate(2048).unwrap(); let pkey = PKey::from_dsa(dsa).unwrap(); pkey.dsa().unwrap(); assert_eq!(pkey.oid(), Oid::DSA); assert_eq!(pkey.id(), Id::DSA); assert!(pkey.rsa().is_err()); } Loading @@ -583,7 +583,7 @@ mod tests { let dh = Dh::params_from_pem(dh).unwrap(); let pkey = PKey::from_dh(dh).unwrap(); pkey.dh().unwrap(); assert_eq!(pkey.oid(), Oid::DH); assert_eq!(pkey.id(), Id::DH); assert!(pkey.rsa().is_err()); } Loading @@ -592,7 +592,7 @@ mod tests { let ec_key = EcKey::from_curve_name(Nid::X9_62_PRIME256V1).unwrap(); let pkey = PKey::from_ec_key(ec_key).unwrap(); pkey.ec_key().unwrap(); assert_eq!(pkey.oid(), Oid::EC); assert_eq!(pkey.id(), Id::EC); assert!(pkey.rsa().is_err()); } } Loading
openssl/src/pkey.rs +19 −19 Original line number Diff line number Diff line Loading @@ -70,26 +70,26 @@ pub enum Public {} /// A tag type indicating that a key has private components. pub enum Private {} /// The Oids that identify the type of a key. /// An identifier of a kind of key. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct Oid(c_int); pub struct Id(c_int); impl Oid { /// Creates a `Oid` from an integer representation. pub fn from_raw(value: c_int) -> Oid { Oid(value) impl Id { /// Creates a `Id` from an integer representation. pub fn from_raw(value: c_int) -> Id { Id(value) } /// Returns the integer representation of `Oid`. /// Returns the integer representation of the `Id`. pub fn as_raw(&self) -> c_int { self.0 } pub const RSA: Oid = Oid(ffi::EVP_PKEY_RSA); pub const HMAC: Oid = Oid(ffi::EVP_PKEY_HMAC); pub const DSA: Oid = Oid(ffi::EVP_PKEY_DSA); pub const DH: Oid = Oid(ffi::EVP_PKEY_DH); pub const EC: Oid = Oid(ffi::EVP_PKEY_EC); pub const RSA: Id = Id(ffi::EVP_PKEY_RSA); pub const HMAC: Id = Id(ffi::EVP_PKEY_HMAC); pub const DSA: Id = Id(ffi::EVP_PKEY_DSA); pub const DH: Id = Id(ffi::EVP_PKEY_DH); pub const EC: Id = Id(ffi::EVP_PKEY_EC); } /// A trait indicating that a key has parameters. Loading Loading @@ -178,14 +178,14 @@ impl<T> PKeyRef<T> { } } /// Returns the Oid that represents the type of this key. /// Returns the `Id` that represents the type of this key. /// /// This corresponds to [`EVP_PKEY_id`]. /// /// [`EVP_PKEY_id`]: https://www.openssl.org/docs/man1.1.0/crypto/EVP_PKEY_id.html pub fn oid(&self) -> Oid { pub fn id(&self) -> Id { unsafe { Oid::from_raw(ffi::EVP_PKEY_id(self.as_ptr())) Id::from_raw(ffi::EVP_PKEY_id(self.as_ptr())) } } } Loading Loading @@ -564,7 +564,7 @@ mod tests { let rsa = Rsa::generate(2048).unwrap(); let pkey = PKey::from_rsa(rsa).unwrap(); pkey.rsa().unwrap(); assert_eq!(pkey.oid(), Oid::RSA); assert_eq!(pkey.id(), Id::RSA); assert!(pkey.dsa().is_err()); } Loading @@ -573,7 +573,7 @@ mod tests { let dsa = Dsa::generate(2048).unwrap(); let pkey = PKey::from_dsa(dsa).unwrap(); pkey.dsa().unwrap(); assert_eq!(pkey.oid(), Oid::DSA); assert_eq!(pkey.id(), Id::DSA); assert!(pkey.rsa().is_err()); } Loading @@ -583,7 +583,7 @@ mod tests { let dh = Dh::params_from_pem(dh).unwrap(); let pkey = PKey::from_dh(dh).unwrap(); pkey.dh().unwrap(); assert_eq!(pkey.oid(), Oid::DH); assert_eq!(pkey.id(), Id::DH); assert!(pkey.rsa().is_err()); } Loading @@ -592,7 +592,7 @@ mod tests { let ec_key = EcKey::from_curve_name(Nid::X9_62_PRIME256V1).unwrap(); let pkey = PKey::from_ec_key(ec_key).unwrap(); pkey.ec_key().unwrap(); assert_eq!(pkey.oid(), Oid::EC); assert_eq!(pkey.id(), Id::EC); assert!(pkey.rsa().is_err()); } }