Commit 3a0d24f7 authored by Steven Fackler's avatar Steven Fackler Committed by GitHub
Browse files

Merge pull request #568 from mredlek/x509_req_version_subject

X509 request information
parents ad07b19e 5ad4af70
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ pub enum X509_CRL {}
pub enum X509_EXTENSION {}
pub enum X509_NAME {}
pub enum X509_NAME_ENTRY {}
pub enum X509_REQ {}
pub enum X509_STORE {}
pub enum X509_STORE_CTX {}
pub enum bio_st {}
@@ -1404,6 +1403,7 @@ extern {
    pub fn AES_set_decrypt_key(userKey: *const c_uchar, bits: c_int, key: *mut AES_KEY) -> c_int;
    pub fn AES_ige_encrypt(in_: *const c_uchar, out: *mut c_uchar, length: size_t, key: *const AES_KEY, ivec: *mut c_uchar, enc: c_int);

    pub fn ASN1_INTEGER_get(dest: *const ASN1_INTEGER) -> c_long;
    pub fn ASN1_INTEGER_set(dest: *mut ASN1_INTEGER, value: c_long) -> c_int;
    pub fn ASN1_GENERALIZEDTIME_free(tm: *mut ASN1_GENERALIZEDTIME);
    pub fn ASN1_GENERALIZEDTIME_print(b: *mut BIO, tm: *const ASN1_GENERALIZEDTIME) -> c_int;
@@ -1945,6 +1945,8 @@ extern {
    pub fn ASN1_STRING_free(x: *mut ASN1_STRING);
    pub fn ASN1_STRING_length(x: *const ASN1_STRING) -> c_int;

    pub fn ASN1_INTEGER_free(x: *mut ASN1_INTEGER);

    pub fn X509_STORE_new() -> *mut X509_STORE;
    pub fn X509_STORE_free(store: *mut X509_STORE);
    pub fn X509_STORE_add_cert(store: *mut X509_STORE, x: *mut X509) -> c_int;
@@ -1960,6 +1962,9 @@ 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;
    pub fn X509_REQ_set_version(x: *mut X509_REQ, version: c_long) -> c_int;
    pub fn X509_REQ_set_subject_name(req: *mut X509_REQ, name: *mut ::X509_NAME) -> c_int;


    #[cfg(not(ossl101))]
    pub fn X509_VERIFY_PARAM_free(param: *mut X509_VERIFY_PARAM);
+17 −0
Original line number Diff line number Diff line
@@ -304,6 +304,23 @@ pub struct X509_VAL {
    pub notAfter: *mut ::ASN1_TIME,
}

#[repr(C)]
pub struct X509_REQ_INFO {
    pub enc: ASN1_ENCODING,
    pub version: *mut ::ASN1_INTEGER,
    pub subject: *mut ::X509_NAME,
    pubkey: *mut c_void,
    pub attributes: *mut stack_st_X509_ATTRIBUTE
}

#[repr(C)]
pub struct X509_REQ {
    pub req_info: *mut X509_REQ_INFO,
    sig_alg: *mut c_void,
    signature: *mut c_void,
    references: c_int
}

#[repr(C)]
pub struct SSL {
    version: c_int,
+17 −0
Original line number Diff line number Diff line
@@ -311,6 +311,23 @@ pub struct X509_VAL {
    pub notAfter: *mut ::ASN1_TIME,
}

#[repr(C)]
pub struct X509_REQ_INFO {
    pub enc: ASN1_ENCODING,
    pub version: *mut ::ASN1_INTEGER,
    pub subject: *mut ::X509_NAME,
    pubkey: *mut c_void,
    pub attributes: *mut stack_st_X509_ATTRIBUTE
}

#[repr(C)]
pub struct X509_REQ {
    pub req_info: *mut X509_REQ_INFO,
    sig_alg: *mut c_void,
    signature: *mut c_void,
    references: c_int
}

#[repr(C)]
pub struct SSL {
    version: c_int,
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ pub enum stack_st_SSL_CIPHER {}
pub enum X509 {}
pub enum X509_ALGOR {}
pub enum X509_VERIFY_PARAM {}
pub enum X509_REQ {}

pub const SSL_OP_MICROSOFT_SESS_ID_BUG: c_ulong =                   0x00000000;
pub const SSL_OP_NETSCAPE_CHALLENGE_BUG: c_ulong =                  0x00000000;
@@ -195,4 +196,6 @@ extern {
                         iter: c_int,
                         mac_iter: c_int,
                         keytype: c_int) -> *mut PKCS12;
    pub fn X509_REQ_get_version(req: *const X509_REQ) -> c_long;
    pub fn X509_REQ_get_subject_name(req: *const X509_REQ) -> *mut ::X509_NAME;
}
+23 −0
Original line number Diff line number Diff line
@@ -94,6 +94,29 @@ impl Asn1StringRef {
    }
}

foreign_type! {
    type CType = ffi::ASN1_INTEGER;
    fn drop = ffi::ASN1_INTEGER_free;

    pub struct Asn1Integer;
    pub struct Asn1IntegerRef;
}

impl Asn1IntegerRef {
    pub fn get(&self) -> i64 {
        unsafe {
            ::ffi::ASN1_INTEGER_get(self.as_ptr()) as i64
        }
    }

    pub fn set(&mut self, value: i32) -> Result<(), ErrorStack>
    {
        unsafe {
            cvt(::ffi::ASN1_INTEGER_set(self.as_ptr(), value as c_long)).map(|_| ())
        }
    }
}

foreign_type! {
    type CType = ffi::ASN1_BIT_STRING;
    fn drop = ffi::ASN1_BIT_STRING_free;
Loading