| ... | @@ -2557,12 +2557,12 @@ pub const Signature = union(enum) { | ... | @@ -2557,12 +2557,12 @@ pub const Signature = union(enum) { |
| 2557 | const sigformat = try sigfixed.readSlice(try sigfixed.readInt(u32, .big)); | 2557 | const sigformat = try sigfixed.readSlice(try sigfixed.readInt(u32, .big)); |
| 2558 | var pkfixed: nio.FixedBufferStream([]const u8) = .init(publickey); | 2558 | var pkfixed: nio.FixedBufferStream([]const u8) = .init(publickey); |
| 2559 | const pkformat = try pkfixed.readSlice(try pkfixed.readInt(u32, .big)); | 2559 | const pkformat = try pkfixed.readSlice(try pkfixed.readInt(u32, .big)); |
| 2560 | _ = pkformat; | | |
| 2561 | | 2560 | |
| 2562 | if (std.mem.eql(u8, sigformat, "ssh-rsa")) { | 2561 | if (std.mem.eql(u8, sigformat, "ssh-rsa")) { |
| 2563 | // intentionally skipped, rsa with sha1 | 2562 | // intentionally skipped, rsa with sha1 |
| 2564 | } | 2563 | } |
| 2565 | if (std.mem.eql(u8, sigformat, "rsa-sha2-256")) blk: { | 2564 | if (std.mem.eql(u8, sigformat, "rsa-sha2-256")) blk: { |
| | 2565 | if (!(std.mem.eql(u8, pkformat, "ssh-rsa"))) break :blk; |
| 2566 | const ns = std.crypto.Certificate.rsa; | 2566 | const ns = std.crypto.Certificate.rsa; |
| 2567 | const pk_e_len = pkfixed.readInt(u32, .big) catch break :blk; | 2567 | const pk_e_len = pkfixed.readInt(u32, .big) catch break :blk; |
| 2568 | var pk_e = pkfixed.readSlice(pk_e_len) catch break :blk; | 2568 | var pk_e = pkfixed.readSlice(pk_e_len) catch break :blk; |
| ... | @@ -2576,6 +2576,7 @@ pub const Signature = union(enum) { | ... | @@ -2576,6 +2576,7 @@ pub const Signature = union(enum) { |
| 2576 | valid = if (pgp_rsa_verify(pk_n.len, sig, signed_data.items, pk, .sha2_256)) true else |err| if (err == error.unrecognized) null else false; | 2576 | valid = if (pgp_rsa_verify(pk_n.len, sig, signed_data.items, pk, .sha2_256)) true else |err| if (err == error.unrecognized) null else false; |
| 2577 | } | 2577 | } |
| 2578 | if (std.mem.eql(u8, sigformat, "rsa-sha2-512")) blk: { | 2578 | if (std.mem.eql(u8, sigformat, "rsa-sha2-512")) blk: { |
| | 2579 | if (!(std.mem.eql(u8, pkformat, "ssh-rsa"))) break :blk; |
| 2579 | const ns = std.crypto.Certificate.rsa; | 2580 | const ns = std.crypto.Certificate.rsa; |
| 2580 | const pk_e_len = pkfixed.readInt(u32, .big) catch break :blk; | 2581 | const pk_e_len = pkfixed.readInt(u32, .big) catch break :blk; |
| 2581 | var pk_e = pkfixed.readSlice(pk_e_len) catch break :blk; | 2582 | var pk_e = pkfixed.readSlice(pk_e_len) catch break :blk; |
| ... | @@ -2589,6 +2590,7 @@ pub const Signature = union(enum) { | ... | @@ -2589,6 +2590,7 @@ pub const Signature = union(enum) { |
| 2589 | valid = if (pgp_rsa_verify(pk_n.len, sig, signed_data.items, pk, .sha2_512)) true else |err| if (err == error.unrecognized) null else false; | 2590 | valid = if (pgp_rsa_verify(pk_n.len, sig, signed_data.items, pk, .sha2_512)) true else |err| if (err == error.unrecognized) null else false; |
| 2590 | } | 2591 | } |
| 2591 | if (std.mem.eql(u8, sigformat, "ssh-ed25519")) blk: { | 2592 | if (std.mem.eql(u8, sigformat, "ssh-ed25519")) blk: { |
| | 2593 | if (!(std.mem.eql(u8, pkformat, "ssh-ed25519"))) break :blk; |
| 2592 | const ed = std.crypto.sign.Ed25519; | 2594 | const ed = std.crypto.sign.Ed25519; |
| 2593 | const pk_len = pkfixed.readInt(u32, .big) catch break :blk; | 2595 | const pk_len = pkfixed.readInt(u32, .big) catch break :blk; |
| 2594 | if (pk_len != ed.PublicKey.encoded_length) break :blk; | 2596 | if (pk_len != ed.PublicKey.encoded_length) break :blk; |
| ... | @@ -2601,6 +2603,7 @@ pub const Signature = union(enum) { | ... | @@ -2601,6 +2603,7 @@ pub const Signature = union(enum) { |
| 2601 | valid = if (sig.verifyStrict(signed_data.items, pk)) true else |_| false; | 2603 | valid = if (sig.verifyStrict(signed_data.items, pk)) true else |_| false; |
| 2602 | } | 2604 | } |
| 2603 | if (std.mem.eql(u8, sigformat, "ecdsa-sha2-nistp256")) blk: { | 2605 | if (std.mem.eql(u8, sigformat, "ecdsa-sha2-nistp256")) blk: { |
| | 2606 | if (!(std.mem.eql(u8, pkformat, "ecdsa-sha2-nistp256"))) break :blk; |
| 2604 | const C = std.crypto.ecc.P256; | 2607 | const C = std.crypto.ecc.P256; |
| 2605 | const H = std.crypto.hash.sha2.Sha256; | 2608 | const H = std.crypto.hash.sha2.Sha256; |
| 2606 | const ns = std.crypto.sign.ecdsa.Ecdsa(C, H); | 2609 | const ns = std.crypto.sign.ecdsa.Ecdsa(C, H); |
| ... | @@ -2624,6 +2627,7 @@ pub const Signature = union(enum) { | ... | @@ -2624,6 +2627,7 @@ pub const Signature = union(enum) { |
| 2624 | valid = if (sig.verify(signed_data.items, pk)) true else |_| false; | 2627 | valid = if (sig.verify(signed_data.items, pk)) true else |_| false; |
| 2625 | } | 2628 | } |
| 2626 | if (std.mem.eql(u8, sigformat, "ecdsa-sha2-nistp384")) blk: { | 2629 | if (std.mem.eql(u8, sigformat, "ecdsa-sha2-nistp384")) blk: { |
| | 2630 | if (!(std.mem.eql(u8, pkformat, "ecdsa-sha2-nistp384"))) break :blk; |
| 2627 | const C = std.crypto.ecc.P384; | 2631 | const C = std.crypto.ecc.P384; |
| 2628 | const H = std.crypto.hash.sha2.Sha384; | 2632 | const H = std.crypto.hash.sha2.Sha384; |
| 2629 | const ns = std.crypto.sign.ecdsa.Ecdsa(C, H); | 2633 | const ns = std.crypto.sign.ecdsa.Ecdsa(C, H); |