chromium/third_party/openscreen/src/cast/receiver/channel/static_credentials.h

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CAST_RECEIVER_CHANNEL_STATIC_CREDENTIALS_H_
#define CAST_RECEIVER_CHANNEL_STATIC_CREDENTIALS_H_

#include <memory>
#include <string>
#include <vector>

#include "cast/receiver/channel/device_auth_namespace_handler.h"
#include "platform/base/error.h"
#include "platform/base/tls_credentials.h"

namespace openscreen::cast {

class StaticCredentialsProvider final
    : public DeviceAuthNamespaceHandler::CredentialsProvider {};

struct GeneratedCredentials {};

// Generates a private key and root TLS server certificate for use with cast
// sockets.
void GenerateDeveloperCredentialsToFile();

// Generates a valid set of credentials for use with cast sockets/TLS.
// Both the private key and server certificate paths are required, except
// in testing where they can be omitted.
ErrorOr<GeneratedCredentials> GenerateCredentials(
    const std::string& device_certificate_id,
    const std::string& private_key_path,
    const std::string& server_certificate_path);

ErrorOr<GeneratedCredentials> GenerateCredentialsForTesting(
    const std::string& device_certificate_id);

}  // namespace openscreen::cast

#endif  // CAST_RECEIVER_CHANNEL_STATIC_CREDENTIALS_H_