Commit 87a3bc26 authored by Steven Fackler's avatar Steven Fackler
Browse files

Merge branch 'release-sys-v0.7.17-v0.8.2' into release

parents 0f428d19 4718a88e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

[![Build Status](https://travis-ci.org/sfackler/rust-openssl.svg?branch=master)](https://travis-ci.org/sfackler/rust-openssl)

[Documentation](https://sfackler.github.io/rust-openssl/doc/v0.8.1/openssl).
[Documentation](https://sfackler.github.io/rust-openssl/doc/v0.8.2/openssl).

## Building

+2 −2
Original line number Diff line number Diff line
[package]
name = "openssl-sys"
version = "0.7.16"
version = "0.7.17"
authors = ["Alex Crichton <alex@alexcrichton.com>",
           "Steven Fackler <sfackler@gmail.com>"]
license = "MIT"
description = "FFI bindings to OpenSSL"
repository = "https://github.com/sfackler/rust-openssl"
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.16/openssl_sys"
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.7.17/openssl_sys"
links = "openssl"
build = "build.rs"

+6 −2
Original line number Diff line number Diff line
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(dead_code)]
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.16")]
#![doc(html_root_url="https://sfackler.github.io/rust-openssl/doc/v0.7.17")]

extern crate libc;

#[cfg(target_os = "nacl")]
extern crate libressl_pnacl_sys;

use libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t};
use libc::{c_void, c_int, c_char, c_ulong, c_long, c_uint, c_uchar, size_t, FILE};
use std::mem;
use std::ptr;
use std::sync::{Mutex, MutexGuard};
@@ -625,13 +625,16 @@ extern "C" {
    pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int;
    pub fn ASN1_STRING_type_new(ty: c_int) -> *mut ASN1_STRING;
    pub fn ASN1_TIME_free(tm: *mut ASN1_TIME);
    pub fn ASN1_TIME_print(b: *mut BIO, tm: *const ASN1_TIME) -> c_int;

    pub fn BIO_ctrl(b: *mut BIO, cmd: c_int, larg: c_long, parg: *mut c_void) -> c_long;
    pub fn BIO_free_all(b: *mut BIO);
    pub fn BIO_new(type_: *const BIO_METHOD) -> *mut BIO;
    pub fn BIO_new_fp(stream: *mut FILE, close_flag: c_int) -> *mut BIO;
    pub fn BIO_new_socket(sock: c_int, close_flag: c_int) -> *mut BIO;
    pub fn BIO_read(b: *mut BIO, buf: *mut c_void, len: c_int) -> c_int;
    pub fn BIO_write(b: *mut BIO, buf: *const c_void, len: c_int) -> c_int;
    pub fn BIO_s_file() -> *const BIO_METHOD;
    pub fn BIO_s_mem() -> *const BIO_METHOD;
    pub fn BIO_new_mem_buf(buf: *const c_void, len: c_int) -> *mut BIO;
    pub fn BIO_set_flags(b: *mut BIO, flags: c_int);
@@ -1070,6 +1073,7 @@ extern "C" {
    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;

    pub fn d2i_X509(a: *mut *mut X509, pp: *mut *mut c_uchar, length: c_long) -> *mut X509;
    pub fn i2d_X509_bio(b: *mut BIO, x: *mut X509) -> c_int;
    pub fn i2d_X509_REQ_bio(b: *mut BIO, x: *mut X509_REQ) -> c_int;

+4 −3
Original line number Diff line number Diff line
[package]
name = "openssl"
version = "0.8.1"
version = "0.8.2"
authors = ["Steven Fackler <sfackler@gmail.com>"]
license = "Apache-2.0"
description = "OpenSSL bindings"
repository = "https://github.com/sfackler/rust-openssl"
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.8.1/openssl"
documentation = "https://sfackler.github.io/rust-openssl/doc/v0.8.2/openssl"
readme = "../README.md"
keywords = ["crypto", "tls", "ssl", "dtls"]
build = "build.rs"
@@ -30,6 +30,7 @@ hmac_clone = ["openssl-sys/hmac_clone"]
c_helpers = ["gcc"]
x509_clone = ["c_helpers"]
x509_generator_request = ["c_helpers"]
x509_expiry = ["c_helpers"]
ssl_context_clone = ["c_helpers"]
hmac = ["c_helpers"]
dh_from_params = ["c_helpers"]
@@ -38,7 +39,7 @@ dh_from_params = ["c_helpers"]
bitflags = "0.7"
lazy_static = "0.2"
libc = "0.2"
openssl-sys = { version = "0.7.16", path = "../openssl-sys" }
openssl-sys = { version = "0.7.17", path = "../openssl-sys" }

[build-dependencies]
gcc = { version = "0.3", optional = true }
+37 −4
Original line number Diff line number Diff line
use libc::c_long;
use std::ptr;
use std::{ptr, fmt};
use std::marker::PhantomData;
use std::ops::Deref;

use bio::MemBio;
use ffi;
use error::ErrorStack;

pub struct Asn1Time(*mut ffi::ASN1_TIME);
/// Corresponds to the ASN.1 structure Time defined in RFC5280
pub struct Asn1Time(Asn1TimeRef<'static>);

impl Asn1Time {
    /// Wraps existing ASN1_TIME and takes ownership
    pub unsafe fn from_ptr(handle: *mut ffi::ASN1_TIME) -> Asn1Time {
        Asn1Time(handle)
        Asn1Time(Asn1TimeRef::from_ptr(handle))
    }

    fn from_period(period: c_long) -> Result<Asn1Time, ErrorStack> {
@@ -25,6 +29,24 @@ impl Asn1Time {
    pub fn days_from_now(days: u32) -> Result<Asn1Time, ErrorStack> {
        Asn1Time::from_period(days as c_long * 60 * 60 * 24)
    }
}

impl Deref for Asn1Time {
    type Target = Asn1TimeRef<'static>;

    fn deref(&self) -> &Asn1TimeRef<'static> {
        &self.0
    }
}

/// A borrowed Asn1Time
pub struct Asn1TimeRef<'a>(*mut ffi::ASN1_TIME, PhantomData<&'a ()>);

impl<'a> Asn1TimeRef<'a> {
    /// Creates a new `Asn1TimeRef` wrapping the provided handle.
    pub unsafe fn from_ptr(handle: *mut ffi::ASN1_TIME) -> Asn1TimeRef<'a> {
        Asn1TimeRef(handle, PhantomData)
    }

    /// Returns the raw handle
    pub fn as_ptr(&self) -> *mut ffi::ASN1_TIME {
@@ -32,8 +54,19 @@ impl Asn1Time {
    }
}

impl<'a> fmt::Display for Asn1TimeRef<'a> {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        let mem_bio = try!(MemBio::new());
        let as_str = unsafe {
            try_ssl!(ffi::ASN1_TIME_print(mem_bio.as_ptr(), self.0));
            String::from_utf8_unchecked(mem_bio.get_buf().to_owned())
        };
        write!(f, "{}", as_str)
    }
}

impl Drop for Asn1Time {
    fn drop(&mut self) {
        unsafe { ffi::ASN1_TIME_free(self.0) };
        unsafe { ffi::ASN1_TIME_free(self.as_ptr()) };
    }
}
Loading