-
Notifications
You must be signed in to change notification settings - Fork 638
Expand file tree
/
Copy pathCommunicationSecrets.h
More file actions
56 lines (43 loc) · 1.76 KB
/
CommunicationSecrets.h
File metadata and controls
56 lines (43 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Copyright (C) 1996-2026 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
* Please see the COPYING and CONTRIBUTORS files for details.
*/
#ifndef SQUID_SRC_SECURITY_COMMUNICATIONSECRETS_H
#define SQUID_SRC_SECURITY_COMMUNICATIONSECRETS_H
#include "sbuf/SBuf.h"
#include "security/Session.h"
#include <iosfwd>
namespace Security {
/// extracts and formats TLS exchange info for (later) decryption that exchange:
/// early secrets, handshake secrets, (pre)master key, client random, etc.
class CommunicationSecrets
{
public:
CommunicationSecrets() = default;
explicit CommunicationSecrets(const Connection &sconn);
/// whether we know all the secrets that could be extracted
bool gotAll() const;
/// copy all new secrets (i.e. previously unknown or changed)
/// while preserving previously known secrets that have disappeared
/// \returns whether any secrets were copied (i.e. this object has changed)
bool learnNew(const CommunicationSecrets &news);
/// logs all known secrets using a (multiline) SSLKEYLOGFILE format
void record(std::ostream &) const;
private:
#if USE_OPENSSL
void getClientRandom(const Connection &sconn);
void getSessionId(const Session &session);
void getMasterKey(const Session &session);
#else
// Secret extraction is not supported in builds using other TLS libraries.
// Secret extraction is impractical in builds without TLS libraries.
#endif
SBuf id; ///< TLS session ID
SBuf random; ///< CLIENT_RANDOM from the TLS connection
SBuf key; ///< TLS session (pre-)master key
};
} // namespace Security
#endif /* SQUID_SRC_SECURITY_COMMUNICATIONSECRETS_H */