Skip to content

eBPF-based security platform

keys: fail when a certificate of another algorithm is refused

Daniel Borkmann993c555e85ee
diff --git a/builtin-keys.c b/builtin-keys.c
index 085e743b..f0dcd28b 100644
--- a/builtin-keys.c
+++ b/builtin-keys.c
@@ -569,7 +569,8 @@ static int keys_add(int argc, const char **argv)
pr_err("keys add: %s is not a certificate", cert);
goto out;
}
- if (check_cert_algorithm(der, der_sz, cert))
+ rc = check_cert_algorithm(der, der_sz, cert);
+ if (rc)
goto out;
shirudo_hex_encode(fp, 32, fp_hex);
diff --git a/tools/shirudo-build/vouch.c b/tools/shirudo-build/vouch.c
index 99e51e6b..1bd6ecd0 100644
--- a/tools/shirudo-build/vouch.c
+++ b/tools/shirudo-build/vouch.c
@@ -164,7 +164,8 @@ int shirudo_build_keys_vouch(int argc, char **argv)
pr_err("keys vouch: %s is not a certificate", input);
goto out;
}
- if (cert_algorithm_ok(der, der_sz, input))
+ rc = cert_algorithm_ok(der, der_sz, input);
+ if (rc)
goto out;
rc = shirudo_keys_read_der(cert, &own, &own_sz);
if (rc) {