]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod/libkmod-signature: move sig_info->id_type assignment further up
authorEmil Velikov <emil.l.velikov@gmail.com>
Sun, 15 Feb 2026 21:34:01 +0000 (21:34 +0000)
committerLucas De Marchi <demarchi@kernel.org>
Wed, 22 Apr 2026 13:54:42 +0000 (08:54 -0500)
It is identical across all the (3) code paths. So move it to the caller,
thus we no longer need to pass the struct module_signature in the PKCS7
case.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/427
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
libkmod/libkmod-signature.c

index ed8d166b16cdd0d4fbc92121a1f8850464043f1d..c3d43b21b7c7c7e1d63e94c903e62a82036ad8c9 100644 (file)
@@ -104,7 +104,6 @@ static bool fill_default(const char *mem, off_t size,
 
        sig_info->algo = pkey_algo[modsig->algo];
        sig_info->hash_algo = pkey_hash_algo[modsig->hash];
-       sig_info->id_type = pkey_id_type[modsig->id_type];
 
        return true;
 }
@@ -156,8 +155,8 @@ static const char *x509_name_to_str(X509_NAME *name)
        return str;
 }
 
-static bool fill_pkcs7(const char *mem, off_t size, const struct module_signature *modsig,
-                      size_t sig_len, struct kmod_signature_info *sig_info)
+static bool fill_pkcs7(const char *mem, off_t size, size_t sig_len,
+                      struct kmod_signature_info *sig_info)
 {
        const char *pkcs7_raw;
        PKCS7 *pkcs7;
@@ -250,8 +249,6 @@ static bool fill_pkcs7(const char *mem, off_t size, const struct module_signatur
        // Assign libcrypto hash algo string or number
        sig_info->hash_algo = hash_algo;
 
-       sig_info->id_type = pkey_id_type[modsig->id_type];
-
        pvt = malloc(sizeof(*pvt));
        if (pvt == NULL)
                goto err4;
@@ -278,11 +275,10 @@ err:
 
 #else
 
-static bool fill_pkcs7(const char *mem, off_t size, const struct module_signature *modsig,
-                      size_t sig_len, struct kmod_signature_info *sig_info)
+static bool fill_pkcs7(const char *mem, off_t size, size_t sig_len,
+                      struct kmod_signature_info *sig_info)
 {
        sig_info->hash_algo = "unknown";
-       sig_info->id_type = pkey_id_type[modsig->id_type];
        return true;
 }
 
@@ -335,9 +331,11 @@ bool kmod_module_signature_info(const struct kmod_file *file,
            size < (int64_t)sig_len + modsig.signer_len + modsig.key_id_len)
                return false;
 
+       sig_info->id_type = pkey_id_type[modsig.id_type];
+
        switch (modsig.id_type) {
        case PKEY_ID_PKCS7:
-               return fill_pkcs7(mem, size, &modsig, sig_len, sig_info);
+               return fill_pkcs7(mem, size, sig_len, sig_info);
        default:
                return fill_default(mem, size, &modsig, sig_len, sig_info);
        }