]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: make sign_verity_roothash() take Context
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 26 Oct 2025 12:40:42 +0000 (21:40 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 2 Nov 2025 07:07:46 +0000 (16:07 +0900)
No functional change, just refactoring.

src/repart/repart.c

index 3089c46baabe9cc52968978fc7b26cef6b36d26a..5ae14b32181ad30aa38d7e5127d0e8fb9f8e22b4 100644 (file)
@@ -5490,9 +5490,8 @@ static int partition_format_verity_hash(
 }
 
 static int sign_verity_roothash(
+                Context *context,
                 const struct iovec *roothash,
-                X509 *certificate,
-                EVP_PKEY *private_key,
                 struct iovec *ret_signature) {
 
 #if HAVE_OPENSSL
@@ -5502,8 +5501,10 @@ static int sign_verity_roothash(
         _cleanup_free_ uint8_t *sig = NULL;
         int sigsz;
 
+        assert(context);
+        assert(context->certificate);
+        assert(context->private_key);
         assert(roothash);
-        assert(private_key);
         assert(iovec_is_set(roothash));
         assert(ret_signature);
 
@@ -5515,7 +5516,7 @@ static int sign_verity_roothash(
         if (!rb)
                 return log_oom();
 
-        p7 = PKCS7_sign(certificate, private_key, NULL, rb, PKCS7_DETACHED|PKCS7_NOATTR|PKCS7_BINARY);
+        p7 = PKCS7_sign(context->certificate, context->private_key, NULL, rb, PKCS7_DETACHED|PKCS7_NOATTR|PKCS7_BINARY);
         if (!p7)
                 return log_error_errno(SYNTHETIC_ERRNO(EIO), "Failed to calculate PKCS7 signature: %s",
                                        ERR_error_string(ERR_get_error(), NULL));
@@ -5601,7 +5602,7 @@ static int partition_format_verity_sig(Context *context, Partition *p) {
                         .iov_len = verity_settings->root_hash_size,
                 };
         } else {
-                r = sign_verity_roothash(&hp->roothash, context->certificate, context->private_key, &sig_free);
+                r = sign_verity_roothash(context, &hp->roothash, &sig_free);
                 if (r < 0)
                         return r;