//
// Copyright 2023 The Project Oak Authors
//
// 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 oak.key_provisioning.v1;

import "proto/crypto/crypto.proto";
import "proto/attestation/evidence.proto";
import "proto/attestation/endorsement.proto";

message GroupKeys {
  // Encryption private key that was encrypted with HPKE using the encryption
  // public key provided in the endorsed evidence.
  oak.crypto.v1.EncryptedRequest encrypted_encryption_private_key = 1;
}

message GetGroupKeysRequest {
  // Evidence contains the encryption public key for encrypting the group
  // encryption key with Hybrid Encryption.
  // <https://datatracker.ietf.org/doc/rfc9180/>
  oak.attestation.v1.Evidence evidence = 1;
  oak.attestation.v1.Endorsements endorsements = 2;
}

message GetGroupKeysResponse {
  GroupKeys group_keys = 1;
}

// Defines the Key Provisioning Service that distributes keys between enclaves.
service KeyProvisioning {
  // Request enclave group keys from for other enclaves as part of Key
  // Provisioning.
  rpc GetGroupKeys(GetGroupKeysRequest) returns (GetGroupKeysResponse) {}
}
