| ... | ... | @@ -11,7 +11,7 @@ const ApplicationCipher = tls.ApplicationCipher; |
| 11 | 11 | const CipherSuite = tls.CipherSuite; |
| 12 | 12 | const ContentType = tls.ContentType; |
| 13 | 13 | const HandshakeType = tls.HandshakeType; |
| 14 | | const CipherParams = tls.CipherParams; |
| 14 | const HandshakeCipher = tls.HandshakeCipher; |
| 15 | 15 | const max_ciphertext_len = tls.max_ciphertext_len; |
| 16 | 16 | const hkdfExpandLabel = tls.hkdfExpandLabel; |
| 17 | 17 | const int2 = tls.int2; |
| ... | ... | @@ -117,7 +117,7 @@ pub fn init(stream: net.Stream, ca_bundle: crypto.CertificateBundle, host: []con |
| 117 | 117 | |
| 118 | 118 | const client_hello_bytes1 = plaintext_header[5..]; |
| 119 | 119 | |
| 120 | | var cipher_params: CipherParams = undefined; |
| 120 | var handshake_cipher: HandshakeCipher = undefined; |
| 121 | 121 | |
| 122 | 122 | var handshake_buf: [8000]u8 = undefined; |
| 123 | 123 | var len: usize = 0; |
| ... | ... | @@ -243,8 +243,8 @@ pub fn init(stream: net.Stream, ca_bundle: crypto.CertificateBundle, host: []con |
| 243 | 243 | .AEGIS_256_SHA384, |
| 244 | 244 | .AEGIS_128L_SHA256, |
| 245 | 245 | => |tag| { |
| 246 | | const P = std.meta.TagPayloadByName(CipherParams, @tagName(tag)); |
| 247 | | cipher_params = @unionInit(CipherParams, @tagName(tag), .{ |
| 246 | const P = std.meta.TagPayloadByName(HandshakeCipher, @tagName(tag)); |
| 247 | handshake_cipher = @unionInit(HandshakeCipher, @tagName(tag), .{ |
| 248 | 248 | .handshake_secret = undefined, |
| 249 | 249 | .master_secret = undefined, |
| 250 | 250 | .client_handshake_key = undefined, |
| ... | ... | @@ -255,7 +255,7 @@ pub fn init(stream: net.Stream, ca_bundle: crypto.CertificateBundle, host: []con |
| 255 | 255 | .server_handshake_iv = undefined, |
| 256 | 256 | .transcript_hash = P.Hash.init(.{}), |
| 257 | 257 | }); |
| 258 | | const p = &@field(cipher_params, @tagName(tag)); |
| 258 | const p = &@field(handshake_cipher, @tagName(tag)); |
| 259 | 259 | p.transcript_hash.update(client_hello_bytes1); // Client Hello part 1 |
| 260 | 260 | p.transcript_hash.update(host); // Client Hello part 2 |
| 261 | 261 | p.transcript_hash.update(frag); // Server Hello |
| ... | ... | @@ -329,7 +329,7 @@ pub fn init(stream: net.Stream, ca_bundle: crypto.CertificateBundle, host: []con |
| 329 | 329 | }, |
| 330 | 330 | .application_data => { |
| 331 | 331 | var cleartext_buf: [8000]u8 = undefined; |
| 332 | | const cleartext = switch (cipher_params) { |
| 332 | const cleartext = switch (handshake_cipher) { |
| 333 | 333 | inline else => |*p| c: { |
| 334 | 334 | const P = @TypeOf(p.*); |
| 335 | 335 | const ciphertext_len = record_size - P.AEAD.tag_length; |
| ... | ... | @@ -366,7 +366,7 @@ pub fn init(stream: net.Stream, ca_bundle: crypto.CertificateBundle, host: []con |
| 366 | 366 | const handshake = cleartext[ct_i..next_handshake_i]; |
| 367 | 367 | switch (handshake_type) { |
| 368 | 368 | @enumToInt(HandshakeType.encrypted_extensions) => { |
| 369 | | switch (cipher_params) { |
| 369 | switch (handshake_cipher) { |
| 370 | 370 | inline else => |*p| p.transcript_hash.update(wrapped_handshake), |
| 371 | 371 | } |
| 372 | 372 | const total_ext_size = mem.readIntBig(u16, handshake[0..2]); |
| ... | ... | @@ -390,7 +390,7 @@ pub fn init(stream: net.Stream, ca_bundle: crypto.CertificateBundle, host: []con |
| 390 | 390 | } |
| 391 | 391 | }, |
| 392 | 392 | @enumToInt(HandshakeType.certificate) => cert: { |
| 393 | | switch (cipher_params) { |
| 393 | switch (handshake_cipher) { |
| 394 | 394 | inline else => |*p| p.transcript_hash.update(wrapped_handshake), |
| 395 | 395 | } |
| 396 | 396 | if (validated_cert) break :cert; |
| ... | ... | @@ -445,7 +445,7 @@ pub fn init(stream: net.Stream, ca_bundle: crypto.CertificateBundle, host: []con |
| 445 | 445 | } |
| 446 | 446 | }, |
| 447 | 447 | @enumToInt(HandshakeType.certificate_verify) => { |
| 448 | | switch (cipher_params) { |
| 448 | switch (handshake_cipher) { |
| 449 | 449 | inline else => |*p| p.transcript_hash.update(wrapped_handshake), |
| 450 | 450 | } |
| 451 | 451 | std.debug.print("ignoring certificate_verify\n", .{}); |
| ... | ... | @@ -458,7 +458,7 @@ pub fn init(stream: net.Stream, ca_bundle: crypto.CertificateBundle, host: []con |
| 458 | 458 | 0x00, 0x01, // length |
| 459 | 459 | 0x01, |
| 460 | 460 | }; |
| 461 | | const app_cipher = switch (cipher_params) { |
| 461 | const app_cipher = switch (handshake_cipher) { |
| 462 | 462 | inline else => |*p, tag| c: { |
| 463 | 463 | const P = @TypeOf(p.*); |
| 464 | 464 | const finished_digest = p.transcript_hash.peek(); |