authorgravatar for dec05eba@protonmail.comdec05eba <dec05eba@protonmail.com> 2023-07-07 00:19:30+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-06 18:36:15-07:00
log2e424e019f6e7e12656a045ed4b9804f786dede9
tree7af674a05bc7e6e25c21d56f7420cb9c8e82c896
parent44df3a148b4fa823979638dd8debb484a94a51af

Client.zig: support rsa_pss_rsae_sha384 and rsa_pss_rsae_sha512

This fixes HTTP GET to https://www.iana.org/domains/reserved for example

1 files changed, 14 insertions(+), 2 deletions(-)

lib/std/crypto/tls/Client.zig+14-2
......@@ -595,11 +595,14 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
595595 const key = try Ecdsa.PublicKey.fromSec1(main_cert_pub_key);
596596 try sig.verify(verify_bytes, key);
597597 },
598 .rsa_pss_rsae_sha256 => {
598 inline .rsa_pss_rsae_sha256,
599 .rsa_pss_rsae_sha384,
600 .rsa_pss_rsae_sha512,
601 => |comptime_scheme| {
599602 if (main_cert_pub_key_algo != .rsaEncryption)
600603 return error.TlsBadSignatureScheme;
601604
602 const Hash = crypto.hash.sha2.Sha256;
605 const Hash = SchemeHash(comptime_scheme);
603606 const rsa = Certificate.rsa;
604607 const components = try rsa.PublicKey.parseDer(main_cert_pub_key);
605608 const exponent = components.exponent;
......@@ -1295,6 +1298,15 @@ fn SchemeEcdsa(comptime scheme: tls.SignatureScheme) type {
12951298 };
12961299}
12971300
1301fn SchemeHash(comptime scheme: tls.SignatureScheme) type {
1302 return switch (scheme) {
1303 .rsa_pss_rsae_sha256 => crypto.hash.sha2.Sha256,
1304 .rsa_pss_rsae_sha384 => crypto.hash.sha2.Sha384,
1305 .rsa_pss_rsae_sha512 => crypto.hash.sha2.Sha512,
1306 else => @compileError("bad scheme"),
1307 };
1308}
1309
12981310/// Abstraction for sending multiple byte buffers to a slice of iovecs.
12991311const VecPut = struct {
13001312 iovecs: []const std.os.iovec,