+bool OpenSSLUtils::getTLSMasterKey(
+ const SSL_SESSION* session,
+ MutableByteRange keyOut) {
+#if OPENSSL_IS_101 || OPENSSL_IS_102
+ if (session &&
+ session->master_key_length == static_cast<int>(keyOut.size())) {
+ auto masterKey = session->master_key;
+ std::copy(
+ masterKey, masterKey + session->master_key_length, keyOut.begin());
+ return true;
+ }
+#endif
+ return false;
+}
+
+bool OpenSSLUtils::getTLSClientRandom(
+ const SSL* ssl,
+ MutableByteRange randomOut) {
+#if OPENSSL_IS_101 || OPENSSL_IS_102
+ if ((SSL_version(ssl) >> 8) == TLS1_VERSION_MAJOR && ssl->s3 &&
+ randomOut.size() == SSL3_RANDOM_SIZE) {
+ auto clientRandom = ssl->s3->client_random;
+ std::copy(clientRandom, clientRandom + SSL3_RANDOM_SIZE, randomOut.begin());
+ return true;
+ }
+#endif
+ return false;
+}
+