authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-07-11 18:52:52 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-07-11 20:00:23 -07:00
log90d3639411a06f2a665355a00fa314fe15488aac
treeb0e5d8976dd68887fcf1066e9d7c62004aa5f900
parent88f69f71a19d141f810e5fe550909bad616c87c4
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

Signature: detect pgp so it doesn't show up as unrecognized


1 files changed, 23 insertions(+), 8 deletions(-)

git.zig+23-8
......@@ -2153,8 +2153,13 @@ pub const Ref = struct {
21532153pub const Signature = union(enum) {
21542154 none,
21552155 unrecognized,
2156 pgp: Pgp,
21562157 ssh: Ssh,
21572158
2159 pub const Pgp = struct {
2160 valid: ?bool,
2161 };
2162
21582163 pub const Ssh = struct {
21592164 publickey: []const u8,
21602165 hash_algorithm: []const u8,
......@@ -2169,6 +2174,18 @@ pub const Signature = union(enum) {
21692174 if (pem_sig.len == 0) {
21702175 return .none;
21712176 }
2177 if (std.mem.startsWith(u8, pem_sig, "-----BEGIN PGP SIGNATURE-----\n \n ") and std.mem.endsWith(u8, pem_sig, "\n -----END PGP SIGNATURE-----\n ")) {
2178 const pembody = pem_sig[33 .. std.mem.indexOf(u8, pem_sig, "\n =") orelse pem_sig.len - 31];
2179 const sigcontent = pembody[0..std.mem.lastIndexOf(u8, pembody, "\n ").?];
2180 var fixed: nio.FixedBufferStream([]const u8) = .init(sigcontent);
2181 var skip = nio.SkipReader(void).from(&fixed, "\n ");
2182 var b64r = nio.Base64Reader(void).from(&skip);
2183 _ = &b64r;
2184
2185 return .{ .pgp = .{
2186 .valid = null,
2187 } };
2188 }
21722189 if (std.mem.startsWith(u8, pem_sig, "-----BEGIN SSH SIGNATURE-----\n") and std.mem.endsWith(u8, pem_sig, "\n -----END SSH SIGNATURE-----")) {
21732190 const sigcontent = pem_sig[30 .. pem_sig.len - 29];
21742191 var fixed: nio.FixedBufferStream([]const u8) = .init(sigcontent);
......@@ -2272,14 +2289,12 @@ pub const Signature = union(enum) {
22722289 // rsa-sha2-256
22732290 // rsa-sha2-512
22742291
2275 return .{
2276 .ssh = .{
2277 .publickey = publickey,
2278 .hash_algorithm = hash_algorithm,
2279 .signature = signature,
2280 .valid = valid,
2281 },
2282 };
2292 return .{ .ssh = .{
2293 .publickey = publickey,
2294 .hash_algorithm = hash_algorithm,
2295 .signature = signature,
2296 .valid = valid,
2297 } };
22832298 }
22842299 return .unrecognized;
22852300 }