// Copyright 2018 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package configpb;

import "github.com/google/trillian/crypto/keyspb/keyspb.proto";
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";

// LogConfig describes the configuration options for a source Log,
// whose STH values are tracked/monitored.
message LogConfig {
  // Human-readable name for the log; must be unique
  string name = 1;
  // Base URL for the log.
  string url = 2;
  // Log's public key. This is optional, but if omitted signatures from
  // the log will not be checked.
  keyspb.PublicKey public_key = 3;
  // Minimum interval between requests to the log, for rate limiting.
  google.protobuf.Duration min_req_interval = 4;
}

// HubConfig describes the configuration options for a destination
// Gossip repository, which may be either a Gossip Hub or a regular
// CT log.
message HubConfig {
  // Human-readable name for the hub, must be unique.
  string name = 1;
  // Base URL for the hub.
  string url = 2;
  // Hub's public key. This is optional, but if omitted signatures from
  // the log will not be checked.
  keyspb.PublicKey public_key = 3;
  // Minimum interval between requests to the hub, for rate limiting.
  google.protobuf.Duration min_req_interval = 4;
  // Whether the hub is a true Gossip Hub.
  bool is_hub = 5;
  // Start point in a Hub beyond which entries of interest are found.
  // For example, for a Hub that is a regular CT Log this might be
  // a known point where the earliest encoded STH is to be found.
  // Specific to goshawk; not used by gosmin.
  int64 start_index = 6;
}

// GossipConfig describes the configuration of a gossiper.
message GossipConfig {
  // The source logs whose STHs will be logged.
  repeated LogConfig source_log = 1;
  // The destination hubs to which the minimal-gossip certificates will
  // be submitted.  These destination hubs need to be configured to accept
  // submissions.
  repeated HubConfig dest_hub = 2;

  // The root certificate used for submissions to any CT logs, in PEM format;
  // this should include the public key corresponding to private_key below.
  // This field is unused if all destination hubs are true Gossip Hubs (rather
  // than CT logs that accept synthetic certificates).
  string root_cert = 3;
  // The private key that will be used to sign synthetic leaf certificates
  // that chain to the root_cert.
  google.protobuf.Any private_key = 4;
  // Number of buffered STHs allowed.
  // TODO(drysdale): investigate sensible ranges for this.
  int32 buffer_size = 5;
}

// GoshawkConfig describes the configuration of a gossiper.
message GoshawkConfig {
  // The source logs whose STHs will be checked.
  repeated LogConfig source_log = 1;
  // The destination hubs which will be scanned for minimal-gossip certificates.
  repeated HubConfig dest_hub = 2;
  // Number of STHs pending verification that can be buffered up for each source log.
  int32 buffer_size = 5;
}
