syntax = "proto3";

package tpm;
option go_package = "github.com/google/go-tpm-tools/proto/tpm";

// Enum values come from TCG Algorithm Registry - v1.27 - Table 3
enum ObjectType {
  OBJECT_INVALID = 0x0000;
  RSA = 0x0001;
  ECC = 0x0023;
}

enum HashAlgo {
  HASH_INVALID = 0x0000;
  SHA1 = 0x0004;
  SHA256 = 0x000B;
  SHA384 = 0x000C;
  SHA512 = 0x000D;
}

// SealedBytes stores the result of a TPM2_Seal. The private portion (priv) has
// already been encrypted and is no longer sensitive. The hash algorithm is
// assumed to be SHA256.
message SealedBytes {
  bytes priv = 1;
  bytes pub = 2;
  repeated uint32 pcrs = 3;
  HashAlgo hash = 4;
  ObjectType srk = 5;
  PCRs certified_pcrs = 6;
  bytes creation_data = 7;
  bytes ticket = 8;
}

message ImportBlob {
  bytes duplicate = 1;
  bytes encrypted_seed = 2;
  bytes public_area = 3;
  PCRs pcrs = 4;
}

message Quote {
  // TPM2 quote, encoded as a TPMS_ATTEST
  bytes quote = 1;
  // TPM2 signature, encoded as a TPMT_SIGNATURE
  bytes raw_sig = 2;
  // PCR values of the bank being quoted
  PCRs pcrs = 3;
}

message PCRs {
  HashAlgo hash = 1;
  map<uint32, bytes> pcrs = 2;
}

// Contains information corresponding an object certified with TPM2_Certify.
message CertifiedBlob {
  // Public area of certified object, encoded as a TPMT_PUBLIC
  bytes pub_area = 1;
  // TPM2 certification, encoded as a TPMS_ATTEST
  bytes certify_info = 2;
  // TPM2 signature, encoded as a TPMT_Signature
  bytes raw_sig = 3;
}