tiny.quic.crypto.initial
Defined in crypto.
API (3)
Actions
Public operations.
Types and contracts
Public types and contracts.
Values and defaults
Public values and defaults.
v1_salt: The 20-byte Initial salt RFC 9001 section 5.2 fixes for QUIC version 1 serves a caller deriving Initial keys by hand so both endpoints use the same salt.
Source
Source: lib/quic/src/crypto/initial.zig
zig
const std = @import("std");const quic = @import("../root.zig");const Hkdf = std.crypto.kdf.hkdf.HkdfSha256;const Secret = quic.crypto.Secret;const tls = std.crypto.tls;/// The 20-byte Initial salt RFC 9001 section 5.2 fixes for QUIC version 1 serves a caller deriving/// Initial keys by hand so both endpoints use the same salt. This value acts as the salt of the/// extraction that turns a client's destination connection ID into the Initial secret, from which/// the client and server traffic secrets follow. A version other than 1 uses a different salt, so/// this value belongs to version 1 alone.pub const v1_salt = [_]u8{ 0x38, 0x76, 0x2c, 0xf7, 0xf5, 0x59, 0x34, 0xb3, 0x4d, 0x17, 0x9a, 0xe6, 0xa4, 0xc8, 0x0c, 0xad, 0xcc, 0xbb, 0x7f, 0x0a,};pub const Secrets = struct { client: Secret, server: Secret,};fn extracted(dcid: []const u8) Secret { return Hkdf.extract(&v1_salt, dcid);}pub fn secrets(dcid: []const u8) Secrets { const initial_secret = extracted(dcid); return .{ .client = tls.hkdfExpandLabel( Hkdf, initial_secret, "client in", "", quic.crypto.secret_bytes, ), .server = tls.hkdfExpandLabel( Hkdf, initial_secret, "server in", "", quic.crypto.secret_bytes, ), };}fn hex(comptime text: []const u8) [text.len / 2]u8 { var result: [text.len / 2]u8 = undefined; _ = std.fmt.hexToBytes(&result, text) catch unreachable; return result;}test "RFC 9001 Appendix A.1 version 1 initial secret" { const dcid = hex("8394c8f03e515708"); const expected = hex( "7db5df06e7a69e432496adedb0085192" ++ "3595221596ae2ae9fb8115c1e9ed0a44", ); try std.testing.expectEqual(expected, extracted(&dcid));}Source: lib/quic/src/crypto/root.zig:18
zig
pub const initial = @import("initial.zig");Complete caller list for crypto.initial.secrets
7 direct callers.
lib.quic.src.crypto.test.test_RFC_9000_sections_17.2_and_17.3_reject_authenticated_reserved_bits[function] — test source atlib/quic/src/crypto/test.zig:642in nearest public ownerlib.quic.src.crypto.testlib.quic.src.crypto.test.test_RFC_9001_Appendix_A.1_Initial_secrets_and_packet_keys[function] — test source atlib/quic/src/crypto/test.zig:116in nearest public ownerlib.quic.src.crypto.testlib.quic.src.crypto.test.test_RFC_9001_Appendix_A.2_client_Initial_packet_protection[function] — test source atlib/quic/src/crypto/test.zig:247in nearest public ownerlib.quic.src.crypto.testlib.quic.src.crypto.test.test_RFC_9001_Appendix_A.3_server_Initial_packet_protection[function] — test source atlib/quic/src/crypto/test.zig:268in nearest public ownerlib.quic.src.crypto.testlib.quic.src.crypto.test.test_RFC_9001_section_5.2_the_draft_salt_yields_a_different_client_Initial_secret[function] — test source atlib/quic/src/crypto/test.zig:176in nearest public ownerlib.quic.src.crypto.testlib.quic.src.crypto.test.test_RFC_9001_section_5.4.2_rejects_a_long_packet_beyond_its_buffer[function] — test source atlib/quic/src/crypto/test.zig:701in nearest public ownerlib.quic.src.crypto.testlib.quic.src.properties.protection.InitialSecretsMirror.property[function] — private source atlib/quic/src/properties/protection.zig:1054in nearest public ownerlib.quic.src.properties.protection
Audit
| Definitions | 4 |
|---|---|
| Public names | 4 |
| Members | 2 |
| Version | 26.7.0 |
| Revision | daab053ee433 |