// Copyright 2017 Google Inc.
//
// 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.
//
////////////////////////////////////////////////////////////////////////////////

// Definitions for Elliptic Curve Digital Signature Algorithm (ECDSA).
syntax = "proto3";

package google.crypto.tink;

import "proto/common.proto";
import "proto/tink.proto";

option java_package = "com.google.crypto.tink.proto";
option java_multiple_files = true;
option go_package = "github.com/tink-crypto/tink-go/v2/proto/ecies_aead_hkdf_go_proto";

// Protos for keys for ECIES with HKDF and AEAD encryption.
//
// These definitions follow loosely ECIES ISO 18033-2 standard
// (Elliptic Curve Integrated Encryption Scheme, see
// http://www.shoup.net/iso/std6.pdf), with but with some differences:
//  * use of HKDF key derivation function (instead of KDF1 and KDF2) enabling
//  the use
//    of optional parameters to the key derivation function, which strenghten
//    the overall security and allow for binding the key material to
//    application-specific information (cf. RFC 5869,
//    https://tools.ietf.org/html/rfc5869)
//  * use of modern AEAD schemes rather than "manual composition" of symmetric
//  encryption
//    with message authentication codes (as in DEM1, DEM2, and DEM3 schemes of
//    ISO 18033-2)
//
// ECIES-keys represent HybridEncryption resp. HybridDecryption primitives.

// Parameters of KEM (Key Encapsulation Mechanism)
message EciesHkdfKemParams {
  // Required.
  EllipticCurveType curve_type = 1;

  // Required.
  HashType hkdf_hash_type = 2;

  // Optional.
  bytes hkdf_salt = 11;
}

// Parameters of AEAD DEM (Data Encapsulation Mechanism).
message EciesAeadDemParams {
  // Required.
  // Contains an Aead or DeterministicAead key format (e.g:
  // AesCtrHmacAeadKeyFormat, AesGcmKeyFormat or AesSivKeyFormat).
  // The output_prefix_type in this template here is ignored (RAW is assumed).
  KeyTemplate aead_dem = 2;
}

message EciesAeadHkdfParams {
  // Key Encapsulation Mechanism.
  // Required.
  EciesHkdfKemParams kem_params = 1;

  // Data Encapsulation Mechanism.
  // Required.
  EciesAeadDemParams dem_params = 2;

  // EC point format.
  // Required.
  EcPointFormat ec_point_format = 3;
}

// EciesAeadHkdfPublicKey represents HybridEncryption primitive.
// key_type: type.googleapis.com/google.crypto.tink.EciesAeadHkdfPublicKey
message EciesAeadHkdfPublicKey {
  // Required.
  uint32 version = 1;
  // Required.
  EciesAeadHkdfParams params = 2;

  // Affine coordinates of the public key in bigendian representation.
  // The public key is a point (x, y) on the curve defined by
  // params.kem_params.curve. Required.
  bytes x = 3;
  // Required.
  bytes y = 4;
}

// EciesKdfAeadPrivateKey represents HybridDecryption primitive.
// key_type: type.googleapis.com/google.crypto.tink.EciesAeadHkdfPrivateKey
message EciesAeadHkdfPrivateKey {
  // Required.
  uint32 version = 1;

  // Required.
  EciesAeadHkdfPublicKey public_key = 2;

  // Required.
  bytes key_value = 3 ;  // Placeholder for multi-line ctype and debug_redact.  // Big integer in bigendian representation.
}

message EciesAeadHkdfKeyFormat {
  // Required.
  EciesAeadHkdfParams params = 1;
}
