ProtobufLAMessages.proto 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Design decision - could define structures within a structure as messages *within* a message and then refer to the nested msg in another msg as Msg1.nested_msg
  2. // Or could define the nested message separately and use it within the message 1 as a type.
  3. // *Think* that the first option effectively "exposes" the nested msg as a valid msg that can be set/get by the application. Want to "hide" this.
  4. // The second method is easy to automatically generate from the C code and so am using it for now. TODO: Define a CPP class that hides the undesired getters/setters, as per the best practice at https://developers.google.com/protocol-buffers/docs/cpptutorial under "Protocol Buffers and O-O Design"
  5. // TODO: Hide setters/getters for these fields in the generated .h file..?
  6. // uint8_t, uint16_t for Protobuf - uint32, as per here - https://stackoverflow.com/questions/42295695/small-scalar-types-and-google-protocol-buffers
  7. // TODO: Do I need to ensure that the value here is within the defined here? Seems not, as it comes from a trusted source.
  8. // "Repeated" - can be repeated 0 or more times - however, arrays in C or CPP with fixed size that have all their elements defined - are a stricter version of this. (Protobuf doesn't let you define constant-sized arrays.)
  9. // packed=true is necessary to ensure successive, efficient 'packing'
  10. syntax = "proto2";
  11. option optimize_for = LITE_RUNTIME;
  12. // LITE_RUNTIME supports serializetocodedstream - which is helpful to read/write multiple messages - https://groups.google.com/forum/#!topic/protobuf/MlUMUPp5WDc and https://developers.google.com/protocol-buffers/docs/techniques?csw=1#streaming
  13. // Only have base classes for those structs in the composite structs that have more than 1 element - this causes a significant reduction in the size of the generated .cc and .h files.
  14. message protobuf_sgx_attributes_t {
  15. required uint64 flags = 1;
  16. required uint64 xfrm = 2;
  17. }
  18. message protobuf_sgx_ec256_public_t {
  19. repeated uint32 gx = 1 [packed=true];
  20. repeated uint32 gy = 2 [packed=true];
  21. }
  22. // Composite message types
  23. // Tag numbers - first all the repeated ones (arrays) and then the required ones, as per the docs.
  24. message protobuf_sgx_report_body_t {
  25. repeated uint32 cpu_svn = 1 [packed=true];
  26. required uint32 misc_select = 9;
  27. repeated uint32 reserved1 = 2 [packed=true];
  28. required protobuf_sgx_attributes_t attributes = 10;
  29. repeated uint32 mr_enclave = 3 [packed=true];
  30. repeated uint32 reserved2 = 4 [packed=true];
  31. repeated uint32 mr_signer = 5 [packed=true];
  32. repeated uint32 reserved3 = 6 [packed=true];
  33. required uint32 isv_prod_id = 11;
  34. required uint32 isv_svn = 12;
  35. repeated uint32 reserved4 = 7 [packed=true];
  36. repeated uint32 report_data = 8 [packed=true];
  37. }
  38. message protobuf_sgx_report_t {
  39. required protobuf_sgx_report_body_t body = 1;
  40. repeated uint32 key_id = 2 [packed=true];
  41. repeated uint32 mac = 3 [packed=true];
  42. }
  43. message protobuf_sgx_target_info_t {
  44. repeated uint32 mr_enclave = 1 [packed=true];
  45. required protobuf_sgx_attributes_t attributes = 4;
  46. repeated uint32 reserved1 = 2 [packed=true];
  47. required uint32 misc_select = 5;
  48. repeated uint32 reserved2 = 3 [packed=true];
  49. }
  50. message protobuf_sgx_dh_msg1_t {
  51. required protobuf_sgx_ec256_public_t g_a = 1;
  52. required protobuf_sgx_target_info_t target = 2;
  53. }
  54. message protobuf_sgx_dh_msg2_t {
  55. required protobuf_sgx_ec256_public_t g_b = 1;
  56. required protobuf_sgx_report_t report = 2;
  57. repeated uint32 cmac = 3 [packed=true];
  58. }
  59. message protobuf_sgx_dh_msg3_body_t {
  60. required protobuf_sgx_report_t report = 1;
  61. repeated uint32 additional_prop = 2;
  62. }
  63. message protobuf_sgx_dh_msg3_t {
  64. required protobuf_sgx_dh_msg3_body_t msg3_body = 1;
  65. repeated uint32 cmac = 2 [packed=true];
  66. }
  67. // for post-LA key establishment and other msgs (in particular, between Apache and Decryptor)
  68. message protobuf_post_LA_encrypted_msg_t {
  69. required bytes msg = 1 ;
  70. }