You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Description
Adds a new preview API, `ConnectionExportKeyingMaterial`, letting
applications export TLS keying material per RFC 5705 / RFC 8446 §7.5
(label + optional context). Requested by Azure SQL to authenticate
connections. Supported by the user-mode TLS providers (Schannel,
OpenSSL/quictls); kernel mode returns `QUIC_STATUS_NOT_SUPPORTED`. The
API runs inline when the calling thread is safe, otherwise queues a
connection operation, and exits early with `QUIC_STATUS_INVALID_STATE`
if the TLS context is gone.
## Testing
New tests: parameter/state validation (`ApiTest.cpp`), functional
cross-peer export over a live connection (`HandshakeTest.cpp`), and RFC
5705 exporter properties at the TLS layer (`TlsTest.cpp`). All run in UM
and KM (KM validates the `NOT_SUPPORTED` path).
## Documentation
Public API declared in `msquic.h` (preview) with a C++ wrapper in
`msquic.hpp`.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Exports keying material derived from the connection's TLS session, as described in [RFC 5705](https://www.rfc-editor.org/rfc/rfc5705) and [RFC 8446 Section 7.5](https://www.rfc-editor.org/rfc/rfc8446#section-7.5).
5
+
The exported material is bound to the TLS session and can be used by the app for its own purposes (for example, to authenticate the peer at the application layer).
6
+
7
+
> **Note** - This API is in [preview](../PreviewFeatures.md). It should be considered unstable and can be subject to breaking changes.
The valid handle to an open and connected connection object.
28
+
29
+
`Config`
30
+
31
+
A pointer to a [QUIC_KEYING_MATERIAL_CONFIG](QUIC_KEYING_MATERIAL_CONFIG.md) that specifies the label, optional context, and the number of bytes to export.
32
+
33
+
`Output`
34
+
35
+
A caller-allocated buffer of at least `Config->OutputLength` bytes that receives the exported keying material on success. Its contents are undefined if the call fails.
36
+
37
+
# Return Value
38
+
39
+
The function returns a [QUIC_STATUS](QUIC_STATUS.md). The app may use `QUIC_FAILED` or `QUIC_SUCCEEDED` to determine if the function failed or succeeded.
40
+
41
+
The following errors are the most likely to be returned:
42
+
43
+
Value | Meaning
44
+
--- | ---
45
+
**QUIC_STATUS_SUCCESS** | The keying material was exported into `Output`.
46
+
**QUIC_STATUS_INVALID_PARAMETER** | `Config`, `Config->Label`, or `Output` is NULL; `Config->OutputLength` is 0; `Config->Context` is NULL while `Config->ContextLength` is non-zero; or `Connection` is not a connection handle.
47
+
**QUIC_STATUS_INVALID_STATE** | The connection's TLS context is no longer available. This happens if the handshake has not completed yet, or if it has already been released after handshake completion (see Remarks).
48
+
**QUIC_STATUS_NOT_SUPPORTED** | The underlying TLS provider does not support exporting keying material. This is the case in kernel mode.
49
+
50
+
# Remarks
51
+
52
+
The keying material can only be exported once the handshake is completed and while the connection's TLS context is alive.
53
+
On a server, the TLS context is is released shortly after the handshake completes (unless resumption tickets are used)
54
+
55
+
This API is best called inline while handling the `QUIC_CONNECTION_EVENT_CONNECTED` event to ensure the TLS context is still alive.
56
+
Calling it later may return `QUIC_STATUS_INVALID_STATE` if the context has already been released.
57
+
58
+
This API is not supported for Windows Kernel Mode, where it returns `QUIC_STATUS_NOT_SUPPORTED`.
A non-NULL, null-terminated ASCII string that disambiguates the exported keying material between different uses. Both peers must use the same label to derive the same material. See [RFC 5705](https://www.rfc-editor.org/rfc/rfc5705) for guidance on choosing a label.
24
+
25
+
`ContextLength`
26
+
27
+
The length, in bytes, of the buffer pointed to by `Context`. May be 0.
28
+
29
+
`Context`
30
+
31
+
An optional pointer to a `ContextLength`-byte context buffer that is mixed into the derivation, further scoping the exported material. May be NULL, in which case `ContextLength` must be 0.
32
+
33
+
`OutputLength`
34
+
35
+
The number of bytes of keying material to export. Must be non-zero. The `Output` buffer passed to [ConnectionExportKeyingMaterial](ConnectionExportKeyingMaterial.md) must be at least this large.
36
+
37
+
# Remarks
38
+
39
+
Both peers of a connection derive identical keying material for the same `Label` and `Context`. Different labels or contexts produce independent, unrelated material.
0 commit comments