24 if (
const auto session = SSL_get_session(&sconn)) {
38 return !
id.isEmpty() && !random.isEmpty() && !key.isEmpty();
44 auto sawChange =
false;
80 if (
id.length() || key.length()) {
88 if (random.length() || key.length()) {
89 os <<
"CLIENT_RANDOM ";
120 char *
const space = random.rawAppendStart(expectedLength);
122 reinterpret_cast<unsigned char*
>(space), expectedLength);
123 random.rawAppendFinish(space, actualLength);
132 unsigned int idLength = 0;
135 if (idStart && idLength)
136 id.assign(
reinterpret_cast<const char *
>(idStart), idLength);
150 char *
const space = key.rawAppendStart(expectedLength);
152 reinterpret_cast<unsigned char*
>(space), expectedLength);
153 key.rawAppendFinish(space, actualLength);
static void PrintSecret(std::ostream &os, const SBuf &secret)
writes the given secret (in hex) or, if there is no secret, a placeholder
static void IgnorePlaceholder(SBuf &secret)
void PrintHex(std::ostream &os, const char *const data, const size_t n)
Prints the first n data bytes using hex notation. Does nothing if n is 0.
optimized set of C chars, with quick membership test and merge support
CharacterSet & add(const unsigned char c)
add a given character to the character set
const char * rawContent() const
static const size_type npos
size_type length() const
Returns the number of bytes stored in SBuf.
size_type findFirstNotOf(const CharacterSet &set, size_type startPos=0) const
SBuf key
TLS session (pre-)master key.
SBuf random
CLIENT_RANDOM from the TLS connection.
void getClientRandom(const Connection &sconn)
void getMasterKey(const Session &session)
void getSessionId(const Session &session)
bool learnNew(const CommunicationSecrets &news)
CommunicationSecrets()=default
void record(std::ostream &) const
logs all known secrets using a (multiline) SSLKEYLOGFILE format
bool gotAll() const
whether we know all the secrets that could be extracted
const unsigned char * SSL_SESSION_get_id(const SSL_SESSION *s, unsigned int *len)
size_t SSL_get_client_random(const SSL *ssl, unsigned char *outStart, size_t outSizeMax)
size_t SSL_SESSION_get_master_key(const SSL_SESSION *session, unsigned char *outStart, size_t outSizeMax)