/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * 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 = "proto2";

package keystore;

option optimize_for = LITE_RUNTIME;

// A single operation config
message OperationConfig {
  // What type of encryption algorithm is the key being used in the op for.
  optional string algorithm = 1;

  // Size of the key being used in this op
  optional int32 key_size = 2;

  // Log whether the key in this op was generated, imported,
  // securely imported, or derived.
  optional string origin = 3;

  // What auth types does this op require? If none, then no auth required.
  optional string user_auth_type = 4;

  // If user authentication is required, is the requirement time based? If it
  // is not time based then this field will not be used and the key is per
  // operation. Per operation keys must be user authenticated on each usage.
  optional int32 user_auth_key_timeout = 5;

  // Track which padding mode was used for this operation.
  optional string padding = 6;

  // Keep track of the digest algorithm being used.
  optional string digest = 7;

  // Check what block mode is being used depending on the mode of encryption
  optional string block_mode = 8;

  // Did the operation succeed? If it didn't, this represents bugs or
  // error cases occurring.
  optional bool was_op_successful = 9;

  // What purpose is this operation serving? Encrypt, decrypt, sign verify?
  optional string purpose = 10;

  // Which ec curve was selected if elliptic curve cryptography is in use
  optional string ec_curve = 11;

  // Standalone or is a file system required
  optional string key_blob_usage_reqs = 12;
}

message OperationConfigEvent {
  optional OperationConfig op_config = 1;

  // counts corresponds to the number of times each op_config in the above array
  // was recorded during the collection period.
  optional uint32 count = 2;
}

message OperationConfigEvents {
    repeated OperationConfigEvent op_config_events = 1;
}