// Copyright 2016 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";

option go_package = "github.com/google/trillian/crypto/sigpb";

package sigpb;

// Protocol buffer encoding of the TLS DigitallySigned type, from RFC 5246 §4.7.
message DigitallySigned {
  // HashAlgorithm defines the approved methods for object hashing.
  //
  // Supported hash algorithms. The numbering space is the same as for TLS,
  // given in RFC 5246 s7.4.1.4.1 and at:
  // http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-18
  enum HashAlgorithm {
    // No hash algorithm is used.
    NONE = 0;
    // SHA256 is used.
    SHA256 = 4;
  }

  // SignatureAlgorithm defines the algorithm used to sign the object.
  //
  // Supported signature algorithms. The numbering space is the same as for TLS,
  // given in RFC 5246 s7.4.1.4.1 and at:
  // http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#tls-parameters-16
  enum SignatureAlgorithm {
    // Anonymous signature scheme.
    ANONYMOUS = 0;
    // RSA signature scheme.
    RSA = 1;
    // ECDSA signature scheme.
    ECDSA = 3;
  }

  // SignatureCipherSuite defines the set of algorithms used for signing.
  enum SignatureCipherSuite {
    // Signature and hash algorithm are unknown / not set. 
    UNKNOWN_CIPHER_SUITE = 0;
    // RSA with SHA256.
    RSA_SHA256 = 1;
    // ECDSA with SHA256.
    ECDSA_SHA256 = 2;
  }

  // hash_algorithm contains the hash algorithm used.
  // TODO(gdbelvin): deprecate in favor of cipher_suite.
  HashAlgorithm hash_algorithm = 1;
  // sig_algorithm contains the signing algorithm used.
  // TODO(gdbelvin): deprecate in favor of cipher_suite.
  SignatureAlgorithm signature_algorithm = 2;
  // cipher_suite contains the combination of ciphers used for this signature.
  SignatureCipherSuite signature_cipher_suite = 4;
  // signature contains the object signature.
  bytes signature = 3;
}
