Update verify

This commit is contained in:
Steven Fackler 2016-10-31 20:19:59 -07:00
parent e9d78181c3
commit 16e398e005
4 changed files with 14 additions and 19 deletions

View File

@ -1675,6 +1675,8 @@ extern {
pub fn X509_REQ_add_extensions(req: *mut X509_REQ, exts: *mut stack_st_X509_EXTENSION) -> c_int;
pub fn X509_REQ_sign(x: *mut X509_REQ, pkey: *mut EVP_PKEY, md: *const EVP_MD) -> c_int;
#[cfg(not(ossl101))]
pub fn X509_VERIFY_PARAM_free(param: *mut X509_VERIFY_PARAM);
#[cfg(not(ossl101))]
pub fn X509_VERIFY_PARAM_set_hostflags(param: *mut X509_VERIFY_PARAM, flags: c_uint);
#[cfg(not(ossl101))]

View File

@ -63,13 +63,14 @@ use {cvt, cvt_p};
use hash::MessageDigest;
use pkey::PKey;
use error::ErrorStack;
use types::Ref;
#[cfg(ossl110)]
use ffi::{EVP_MD_CTX_new, EVP_MD_CTX_free};
#[cfg(any(ossl101, ossl102))]
use ffi::{EVP_MD_CTX_create as EVP_MD_CTX_new, EVP_MD_CTX_destroy as EVP_MD_CTX_free};
pub struct Signer<'a>(*mut ffi::EVP_MD_CTX, PhantomData<&'a PKey>);
pub struct Signer<'a>(*mut ffi::EVP_MD_CTX, PhantomData<&'a Ref<PKey>>);
impl<'a> Drop for Signer<'a> {
fn drop(&mut self) {
@ -80,7 +81,7 @@ impl<'a> Drop for Signer<'a> {
}
impl<'a> Signer<'a> {
pub fn new(type_: MessageDigest, pkey: &'a PKey) -> Result<Signer<'a>, ErrorStack> {
pub fn new(type_: MessageDigest, pkey: &'a Ref<PKey>) -> Result<Signer<'a>, ErrorStack> {
unsafe {
ffi::init();
@ -128,7 +129,7 @@ impl<'a> Write for Signer<'a> {
}
}
pub struct Verifier<'a>(*mut ffi::EVP_MD_CTX, PhantomData<&'a PKey>);
pub struct Verifier<'a>(*mut ffi::EVP_MD_CTX, PhantomData<&'a Ref<PKey>>);
impl<'a> Drop for Verifier<'a> {
fn drop(&mut self) {
@ -139,7 +140,7 @@ impl<'a> Drop for Verifier<'a> {
}
impl<'a> Verifier<'a> {
pub fn new(type_: MessageDigest, pkey: &'a PKey) -> Result<Verifier<'a>, ErrorStack> {
pub fn new(type_: MessageDigest, pkey: &'a Ref<PKey>) -> Result<Verifier<'a>, ErrorStack> {
unsafe {
ffi::init();

View File

@ -95,7 +95,7 @@ use dh::Dh;
use ec_key::EcKey;
use x509::{X509StoreContextRef, X509FileType, X509, X509Ref, X509VerifyError};
#[cfg(any(ossl102, ossl110))]
use verify::X509VerifyParamRef;
use verify::X509VerifyParam;
use pkey::PKey;
use error::ErrorStack;
use opaque::Opaque;
@ -1109,13 +1109,13 @@ impl SslRef {
///
/// Requires the `v102` or `v110` features and OpenSSL 1.0.2 or 1.1.0.
#[cfg(any(all(feature = "v102", ossl102), all(feature = "v110", ossl110)))]
pub fn param_mut(&mut self) -> &mut X509VerifyParamRef {
pub fn param_mut(&mut self) -> &mut Ref<X509VerifyParam> {
self._param_mut()
}
#[cfg(any(ossl102, ossl110))]
fn _param_mut(&mut self) -> &mut X509VerifyParamRef {
unsafe { X509VerifyParamRef::from_ptr_mut(ffi::SSL_get0_param(self.as_ptr())) }
fn _param_mut(&mut self) -> &mut Ref<X509VerifyParam> {
unsafe { Ref::from_ptr_mut(ffi::SSL_get0_param(self.as_ptr())) }
}
/// Returns the result of X509 certificate verification.

View File

@ -3,7 +3,7 @@ use ffi;
use cvt;
use error::ErrorStack;
use opaque::Opaque;
use types::Ref;
bitflags! {
pub flags X509CheckFlags: c_uint {
@ -19,17 +19,9 @@ bitflags! {
}
}
pub struct X509VerifyParamRef(Opaque);
impl X509VerifyParamRef {
pub unsafe fn from_ptr_mut<'a>(ptr: *mut ffi::X509_VERIFY_PARAM) -> &'a mut X509VerifyParamRef {
&mut *(ptr as *mut _)
}
pub fn as_ptr(&self) -> *mut ffi::X509_VERIFY_PARAM {
self as *const _ as *mut _
}
type_!(X509VerifyParam, ffi::X509_VERIFY_PARAM, ffi::X509_VERIFY_PARAM_free);
impl Ref<X509VerifyParam> {
pub fn set_hostflags(&mut self, hostflags: X509CheckFlags) {
unsafe {
ffi::X509_VERIFY_PARAM_set_hostflags(self.as_ptr(), hostflags.bits);