Skip to content

Commit 2e424e0

Browse files
dec05ebaandrewrk
authored andcommitted
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 parent 44df3a1 commit 2e424e0

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/std/crypto/tls/Client.zig

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1301+
fn 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.
12991311
const VecPut = struct {
13001312
iovecs: []const std.os.iovec,

0 commit comments

Comments
 (0)