1
0
mirror of https://github.com/facebookincubator/mvfst.git synced 2025-08-08 09:42:06 +03:00

Add getExportedKeyingMaterial to QuicSocket API.

Summary: This allows for applications to derive exported key material.

Reviewed By: hanidamlaj

Differential Revision: D55643408

fbshipit-source-id: 00a2bb7d050dc37ea5917d4b1f70bf9e0975de0c
This commit is contained in:
Kyle Nekritz
2024-04-25 08:24:54 -07:00
committed by Facebook GitHub Bot
parent 3570f0122f
commit 5986d37294
6 changed files with 44 additions and 2 deletions

View File

@@ -401,6 +401,15 @@ class QuicSocket {
return nullptr; return nullptr;
} }
/**
* Derive exported key material (RFC5705) from the transport's TLS layer, if
* the transport is capable.
*/
virtual folly::Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
const std::string& label,
const folly::Optional<folly::ByteRange>& context,
uint16_t keyLength) const = 0;
/** /**
* Determine if transport is open and ready to read or write. * Determine if transport is open and ready to read or write.
* *

View File

@@ -56,6 +56,11 @@ class MockQuicSocket : public QuicSocket {
getPeerTransportParams, getPeerTransportParams,
(), (),
(const)); (const));
MOCK_METHOD(
(folly::Optional<std::vector<uint8_t>>),
getExportedKeyingMaterial,
(const std::string&, const folly::Optional<folly::ByteRange>&, uint16_t),
(const));
MOCK_METHOD(std::shared_ptr<QuicEventBase>, getEventBase, (), (const)); MOCK_METHOD(std::shared_ptr<QuicEventBase>, getEventBase, (), (const));
MOCK_METHOD( MOCK_METHOD(
(folly::Expected<size_t, LocalErrorCode>), (folly::Expected<size_t, LocalErrorCode>),

View File

@@ -554,6 +554,13 @@ class TestQuicTransport
return observerContainer_.get(); return observerContainer_.get();
} }
folly::Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
const std::string&,
const folly::Optional<folly::ByteRange>&,
uint16_t) const override {
return folly::none;
}
QuicServerConnectionState* transportConn; QuicServerConnectionState* transportConn;
std::unique_ptr<Aead> aead; std::unique_ptr<Aead> aead;
std::unique_ptr<PacketNumberCipher> headerCipher; std::unique_ptr<PacketNumberCipher> headerCipher;

View File

@@ -179,6 +179,13 @@ class TestQuicTransport
return observerContainer_.get(); return observerContainer_.get();
} }
folly::Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
const std::string&,
const folly::Optional<folly::ByteRange>&,
uint16_t) const override {
return folly::none;
}
std::unique_ptr<Aead> aead; std::unique_ptr<Aead> aead;
std::unique_ptr<PacketNumberCipher> headerCipher; std::unique_ptr<PacketNumberCipher> headerCipher;
bool closed{false}; bool closed{false};

View File

@@ -111,10 +111,10 @@ class QuicClientTransport
* context is the context value argument for the TLS exporter. * context is the context value argument for the TLS exporter.
* keyLength is the length of the exported key. * keyLength is the length of the exported key.
*/ */
virtual folly::Optional<std::vector<uint8_t>> getExportedKeyingMaterial( folly::Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
const std::string& label, const std::string& label,
const folly::Optional<folly::ByteRange>& context, const folly::Optional<folly::ByteRange>& context,
uint16_t keyLength) { uint16_t keyLength) const override {
return clientConn_->clientHandshakeLayer->getExportedKeyingMaterial( return clientConn_->clientHandshakeLayer->getExportedKeyingMaterial(
label, context, keyLength); label, context, keyLength);
} }

View File

@@ -163,6 +163,20 @@ class QuicServerTransport
virtual CipherInfo getOneRttCipherInfo() const; virtual CipherInfo getOneRttCipherInfo() const;
/*
* Export the underlying TLS key material.
* label is the label argument for the TLS exporter.
* context is the context value argument for the TLS exporter.
* keyLength is the length of the exported key.
*/
folly::Optional<std::vector<uint8_t>> getExportedKeyingMaterial(
const std::string& label,
const folly::Optional<folly::ByteRange>& context,
uint16_t keyLength) const override {
return serverConn_->serverHandshakeLayer->getExportedKeyingMaterial(
label, context, keyLength);
}
/* Log a collection of statistics that are meant to be sampled consistently /* Log a collection of statistics that are meant to be sampled consistently
* over time, rather than driven by transport events. * over time, rather than driven by transport events.
*/ */