rust/x509: replace rs_ naming with SC

pull/13170/head
Jason Ish 6 months ago committed by Victor Julien
parent afce53c8b7
commit d16c014641

@ -67,7 +67,7 @@ impl fmt::Display for SCGeneralName<'_> {
/// ///
/// input must be a valid buffer of at least input_len bytes /// input must be a valid buffer of at least input_len bytes
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_x509_decode( pub unsafe extern "C" fn SCX509Decode(
input: *const u8, input: *const u8,
input_len: u32, input_len: u32,
err_code: *mut u32, err_code: *mut u32,
@ -85,7 +85,7 @@ pub unsafe extern "C" fn rs_x509_decode(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_x509_get_subject(ptr: *const X509) -> *mut c_char { pub unsafe extern "C" fn SCX509GetSubject(ptr: *const X509) -> *mut c_char {
if ptr.is_null() { if ptr.is_null() {
return std::ptr::null_mut(); return std::ptr::null_mut();
} }
@ -95,7 +95,7 @@ pub unsafe extern "C" fn rs_x509_get_subject(ptr: *const X509) -> *mut c_char {
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_x509_get_subjectaltname_len(ptr: *const X509) -> u16 { pub unsafe extern "C" fn SCX509GetSubjectAltNameLen(ptr: *const X509) -> u16 {
if ptr.is_null() { if ptr.is_null() {
return 0; return 0;
} }
@ -111,7 +111,7 @@ pub unsafe extern "C" fn rs_x509_get_subjectaltname_len(ptr: *const X509) -> u16
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_x509_get_subjectaltname_at(ptr: *const X509, idx: u16) -> *mut c_char { pub unsafe extern "C" fn SCX509GetSubjectAltNameAt(ptr: *const X509, idx: u16) -> *mut c_char {
if ptr.is_null() { if ptr.is_null() {
return std::ptr::null_mut(); return std::ptr::null_mut();
} }
@ -126,7 +126,7 @@ pub unsafe extern "C" fn rs_x509_get_subjectaltname_at(ptr: *const X509, idx: u1
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_x509_get_issuer(ptr: *const X509) -> *mut c_char { pub unsafe extern "C" fn SCX509GetIssuer(ptr: *const X509) -> *mut c_char {
if ptr.is_null() { if ptr.is_null() {
return std::ptr::null_mut(); return std::ptr::null_mut();
} }
@ -136,7 +136,7 @@ pub unsafe extern "C" fn rs_x509_get_issuer(ptr: *const X509) -> *mut c_char {
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_x509_get_serial(ptr: *const X509) -> *mut c_char { pub unsafe extern "C" fn SCX509GetSerial(ptr: *const X509) -> *mut c_char {
if ptr.is_null() { if ptr.is_null() {
return std::ptr::null_mut(); return std::ptr::null_mut();
} }
@ -151,9 +151,9 @@ pub unsafe extern "C" fn rs_x509_get_serial(ptr: *const X509) -> *mut c_char {
/// ///
/// # Safety /// # Safety
/// ///
/// ptr must be a valid object obtained using `rs_x509_decode` /// ptr must be a valid object obtained using `SCX509Decode`
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_x509_get_validity( pub unsafe extern "C" fn SCX509GetValidity(
ptr: *const X509, ptr: *const X509,
not_before: *mut i64, not_before: *mut i64,
not_after: *mut i64, not_after: *mut i64,
@ -173,9 +173,9 @@ pub unsafe extern "C" fn rs_x509_get_validity(
/// ///
/// # Safety /// # Safety
/// ///
/// ptr must be a valid object obtained using `rs_x509_decode` /// ptr must be a valid object obtained using `SCX509Decode`
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_x509_free(ptr: *mut X509) { pub unsafe extern "C" fn SCX509Free(ptr: *mut X509) {
if ptr.is_null() { if ptr.is_null() {
return; return;
} }

@ -572,49 +572,49 @@ static int TlsDecodeHSCertificate(SSLState *ssl_state, SSLStateConnp *connp,
/* only store fields from the first certificate in the chain */ /* only store fields from the first certificate in the chain */
if (certn == 0 && connp->cert0_subject == NULL && connp->cert0_issuerdn == NULL && if (certn == 0 && connp->cert0_subject == NULL && connp->cert0_issuerdn == NULL &&
connp->cert0_serial == NULL) { connp->cert0_serial == NULL) {
x509 = rs_x509_decode(input, cert_len, &err_code); x509 = SCX509Decode(input, cert_len, &err_code);
if (x509 == NULL) { if (x509 == NULL) {
TlsDecodeHSCertificateErrSetEvent(ssl_state, err_code); TlsDecodeHSCertificateErrSetEvent(ssl_state, err_code);
goto next; goto next;
} }
char *str = rs_x509_get_subject(x509); char *str = SCX509GetSubject(x509);
if (str == NULL) { if (str == NULL) {
err_code = ERR_EXTRACT_SUBJECT; err_code = ERR_EXTRACT_SUBJECT;
goto error; goto error;
} }
connp->cert0_subject = str; connp->cert0_subject = str;
str = rs_x509_get_issuer(x509); str = SCX509GetIssuer(x509);
if (str == NULL) { if (str == NULL) {
err_code = ERR_EXTRACT_ISSUER; err_code = ERR_EXTRACT_ISSUER;
goto error; goto error;
} }
connp->cert0_issuerdn = str; connp->cert0_issuerdn = str;
connp->cert0_sans_len = rs_x509_get_subjectaltname_len(x509); connp->cert0_sans_len = SCX509GetSubjectAltNameLen(x509);
char **sans = SCCalloc(connp->cert0_sans_len, sizeof(char *)); char **sans = SCCalloc(connp->cert0_sans_len, sizeof(char *));
if (sans == NULL) { if (sans == NULL) {
goto error; goto error;
} }
for (uint16_t i = 0; i < connp->cert0_sans_len; i++) { for (uint16_t i = 0; i < connp->cert0_sans_len; i++) {
sans[i] = rs_x509_get_subjectaltname_at(x509, i); sans[i] = SCX509GetSubjectAltNameAt(x509, i);
} }
connp->cert0_sans = sans; connp->cert0_sans = sans;
str = rs_x509_get_serial(x509); str = SCX509GetSerial(x509);
if (str == NULL) { if (str == NULL) {
err_code = ERR_INVALID_SERIAL; err_code = ERR_INVALID_SERIAL;
goto error; goto error;
} }
connp->cert0_serial = str; connp->cert0_serial = str;
rc = rs_x509_get_validity(x509, &connp->cert0_not_before, &connp->cert0_not_after); rc = SCX509GetValidity(x509, &connp->cert0_not_before, &connp->cert0_not_after);
if (rc != 0) { if (rc != 0) {
err_code = ERR_EXTRACT_VALIDITY; err_code = ERR_EXTRACT_VALIDITY;
goto error; goto error;
} }
rs_x509_free(x509); SCX509Free(x509);
x509 = NULL; x509 = NULL;
rc = TlsDecodeHSCertificateFingerprint(connp, input, cert_len); rc = TlsDecodeHSCertificateFingerprint(connp, input, cert_len);
@ -638,7 +638,7 @@ error:
if (err_code != 0) if (err_code != 0)
TlsDecodeHSCertificateErrSetEvent(ssl_state, err_code); TlsDecodeHSCertificateErrSetEvent(ssl_state, err_code);
if (x509 != NULL) if (x509 != NULL)
rs_x509_free(x509); SCX509Free(x509);
SSLStateCertSANFree(connp); SSLStateCertSANFree(connp);
return -1; return -1;

Loading…
Cancel
Save