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 {...@@ -2153,8 +2153,13 @@ pub const Ref = struct {
2153pub const Signature = union(enum) {2153pub const Signature = union(enum) {
2154 none,2154 none,
2155 unrecognized,2155 unrecognized,
2156 pgp: Pgp,
2156 ssh: Ssh,2157 ssh: Ssh,
21572158
2159 pub const Pgp = struct {
2160 valid: ?bool,
2161 };
2162
2158 pub const Ssh = struct {2163 pub const Ssh = struct {
2159 publickey: []const u8,2164 publickey: []const u8,
2160 hash_algorithm: []const u8,2165 hash_algorithm: []const u8,
...@@ -2169,6 +2174,18 @@ pub const Signature = union(enum) {...@@ -2169,6 +2174,18 @@ pub const Signature = union(enum) {
2169 if (pem_sig.len == 0) {2174 if (pem_sig.len == 0) {
2170 return .none;2175 return .none;
2171 }2176 }
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 }
2172 if (std.mem.startsWith(u8, pem_sig, "-----BEGIN SSH SIGNATURE-----\n") and std.mem.endsWith(u8, pem_sig, "\n -----END SSH SIGNATURE-----")) {2189 if (std.mem.startsWith(u8, pem_sig, "-----BEGIN SSH SIGNATURE-----\n") and std.mem.endsWith(u8, pem_sig, "\n -----END SSH SIGNATURE-----")) {
2173 const sigcontent = pem_sig[30 .. pem_sig.len - 29];2190 const sigcontent = pem_sig[30 .. pem_sig.len - 29];
2174 var fixed: nio.FixedBufferStream([]const u8) = .init(sigcontent);2191 var fixed: nio.FixedBufferStream([]const u8) = .init(sigcontent);
...@@ -2272,14 +2289,12 @@ pub const Signature = union(enum) {...@@ -2272,14 +2289,12 @@ pub const Signature = union(enum) {
2272 // rsa-sha2-2562289 // rsa-sha2-256
2273 // rsa-sha2-5122290 // rsa-sha2-512
22742291
2275 return .{2292 return .{ .ssh = .{
2276 .ssh = .{2293 .publickey = publickey,
2277 .publickey = publickey,2294 .hash_algorithm = hash_algorithm,
2278 .hash_algorithm = hash_algorithm,2295 .signature = signature,
2279 .signature = signature,2296 .valid = valid,
2280 .valid = valid,2297 } };
2281 },
2282 };
2283 }2298 }
2284 return .unrecognized;2299 return .unrecognized;
2285 }2300 }