/* This function returns the TLS/SSL master key material currently used in the specified TLS connection. */
EFI_STATUS EFIAPI TlsGetKeyMaterial(IN VOID *Tls, IN OUT UINT8 *KeyMaterial)
/* This function returns the TLS/SSL master key material currently used in the specified TLS connection. */
EFI_STATUS EFIAPI TlsGetKeyMaterial(IN VOID *Tls, IN OUT UINT8 *KeyMaterial)
{
  TLS_CONNECTION  *TlsConn;
  SSL_SESSION     *Session;
  TlsConn = (TLS_CONNECTION *)Tls;
  Session = NULL;
  if ((TlsConn == NULL) || (TlsConn->Ssl == NULL) || (KeyMaterial == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  Session = SSL_get_session (TlsConn->Ssl);
  if (Session == NULL) {
    return EFI_UNSUPPORTED;
  }
  SSL_SESSION_get_master_key (Session, KeyMaterial, SSL3_MASTER_SECRET_SIZE);
  return EFI_SUCCESS;
}