28 if (buf.
empty() || !cursor.canAdvance(kPlaintextHeaderSize)) {
38 auto length = cursor.readBE<
uint16_t>();
58 throw std::runtime_error(folly::to<std::string>(
59 "received plaintext content type ",
60 static_cast<ContentTypeType>(msg.
type),
68 auto length = cursor.readBE<
uint16_t>();
69 if (length > kMaxPlaintextRecordSize) {
70 throw std::runtime_error(
"received too long plaintext record");
73 throw std::runtime_error(
"received empty plaintext record");
106 Buf encodedClientHello)
const {
116 throw std::runtime_error(
"refusing to send plaintext application data");
121 std::unique_ptr<folly::IOBuf>
data;
122 while (!cursor.isAtEnd()) {
124 auto len = cursor.cloneAtMost(thisFragment, kMaxPlaintextRecordSize);
128 appender.
writeBE(static_cast<ContentTypeType>(msg.
type));
129 appender.writeBE(static_cast<ProtocolVersionType>(recordVersion));
137 data->prependChain(
std::move(thisFragment));
const folly::IOBuf * front() const
size_t chainLength() const
folly::Optional< TLSMessage > read(folly::IOBufQueue &buf) override
std::unique_ptr< folly::IOBuf > splitAtMost(size_t n)
void write(const T &in, folly::io::Appender &appender)
static std::unique_ptr< IOBuf > create(std::size_t capacity)
constexpr detail::Map< Move > move
virtual TLSContent writeInitialClientHello(Buf encodedClientHello) const
EncryptionLevel getEncryptionLevel() const override
EncryptionLevel getEncryptionLevel() const override
constexpr uint16_t kMaxPlaintextRecordSize
EncryptionLevel encryptionLevel
static constexpr size_t kPlaintextHeaderSize
folly::Optional< ProtocolVersion > receivedRecordVersion_
typename std::underlying_type< ProtocolVersion >::type ProtocolVersionType
std::unique_ptr< folly::IOBuf > Buf
bool skipEncryptedRecords_
void trimStart(size_t amount)
TLSContent write(TLSMessage &&msg) const override
bool hexlify(const InputString &input, OutputString &output, bool append_output)
typename std::underlying_type< ContentType >::type ContentTypeType
static constexpr uint64_t data[1]