| ... | @@ -2153,8 +2153,13 @@ pub const Ref = struct { | ... | @@ -2153,8 +2153,13 @@ pub const Ref = struct { |
| 2153 | pub const Signature = union(enum) { | 2153 | pub const Signature = union(enum) { |
| 2154 | none, | 2154 | none, |
| 2155 | unrecognized, | 2155 | unrecognized, |
| | 2156 | pgp: Pgp, |
| 2156 | ssh: Ssh, | 2157 | ssh: Ssh, |
| 2157 | | 2158 | |
| | 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-256 | 2289 | // rsa-sha2-256 |
| 2273 | // rsa-sha2-512 | 2290 | // rsa-sha2-512 |
| 2274 | | 2291 | |
| 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 | } |