]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/x509: replace rs_ naming with SC
authorJason Ish <jason.ish@oisf.net>
Mon, 5 May 2025 15:48:55 +0000 (09:48 -0600)
committerVictor Julien <victor@inliniac.net>
Mon, 5 May 2025 19:41:03 +0000 (21:41 +0200)
rust/src/x509/mod.rs
src/app-layer-ssl.c

index a38cf85317aca756407eec12a9a54db8726d104c..4873f392b2d6b47f3c37ddf00646796265135f80 100644 (file)
@@ -67,7 +67,7 @@ impl fmt::Display for SCGeneralName<'_> {
 ///
 /// input must be a valid buffer of at least input_len bytes
 #[no_mangle]
-pub unsafe extern "C" fn rs_x509_decode(
+pub unsafe extern "C" fn SCX509Decode(
     input: *const u8,
     input_len: u32,
     err_code: *mut u32,
@@ -85,7 +85,7 @@ pub unsafe extern "C" fn rs_x509_decode(
 }
 
 #[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() {
         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]
-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() {
         return 0;
     }
@@ -111,7 +111,7 @@ pub unsafe extern "C" fn rs_x509_get_subjectaltname_len(ptr: *const X509) -> u16
 }
 
 #[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() {
         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]
-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() {
         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]
-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() {
         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
 ///
-/// ptr must be a valid object obtained using `rs_x509_decode`
+/// ptr must be a valid object obtained using `SCX509Decode`
 #[no_mangle]
-pub unsafe extern "C" fn rs_x509_get_validity(
+pub unsafe extern "C" fn SCX509GetValidity(
     ptr: *const X509,
     not_before: *mut i64,
     not_after: *mut i64,
@@ -173,9 +173,9 @@ pub unsafe extern "C" fn rs_x509_get_validity(
 ///
 /// # Safety
 ///
-/// ptr must be a valid object obtained using `rs_x509_decode`
+/// ptr must be a valid object obtained using `SCX509Decode`
 #[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() {
         return;
     }
index 8cdc1c784e7871d16e132a7c664f4988ccd1e6dd..10c9dce7cae47ad7ba4e02c24d8eb72e17ff6388 100644 (file)
@@ -572,49 +572,49 @@ static int TlsDecodeHSCertificate(SSLState *ssl_state, SSLStateConnp *connp,
     /* only store fields from the first certificate in the chain */
     if (certn == 0 && connp->cert0_subject == NULL && connp->cert0_issuerdn == NULL &&
             connp->cert0_serial == NULL) {
-        x509 = rs_x509_decode(input, cert_len, &err_code);
+        x509 = SCX509Decode(input, cert_len, &err_code);
         if (x509 == NULL) {
             TlsDecodeHSCertificateErrSetEvent(ssl_state, err_code);
             goto next;
         }
 
-        char *str = rs_x509_get_subject(x509);
+        char *str = SCX509GetSubject(x509);
         if (str == NULL) {
             err_code = ERR_EXTRACT_SUBJECT;
             goto error;
         }
         connp->cert0_subject = str;
 
-        str = rs_x509_get_issuer(x509);
+        str = SCX509GetIssuer(x509);
         if (str == NULL) {
             err_code = ERR_EXTRACT_ISSUER;
             goto error;
         }
         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 *));
         if (sans == NULL) {
             goto error;
         }
         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;
-        str = rs_x509_get_serial(x509);
+        str = SCX509GetSerial(x509);
         if (str == NULL) {
             err_code = ERR_INVALID_SERIAL;
             goto error;
         }
         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) {
             err_code = ERR_EXTRACT_VALIDITY;
             goto error;
         }
 
-        rs_x509_free(x509);
+        SCX509Free(x509);
         x509 = NULL;
 
         rc = TlsDecodeHSCertificateFingerprint(connp, input, cert_len);
@@ -638,7 +638,7 @@ error:
     if (err_code != 0)
         TlsDecodeHSCertificateErrSetEvent(ssl_state, err_code);
     if (x509 != NULL)
-        rs_x509_free(x509);
+        SCX509Free(x509);
 
     SSLStateCertSANFree(connp);
     return -1;