ProtobufLAMessages.proto 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. /*
  15. message protobuf_sgx_cpu_svn_t {
  16. repeated uint32 svn = 1 [packed=true];
  17. }
  18. message protobuf_sgx_report_data_t {
  19. repeated uint32 d = 1 [packed=true];
  20. }
  21. message protobuf_sgx_key_id_t {
  22. repeated uint32 id = 1 [packed=true];
  23. }
  24. message protobuf_sgx_mac_t {
  25. repeated uint32 mac = 1 [packed=true];
  26. }
  27. message protobuf_sgx_measurement_t {
  28. repeated uint32 m = 1 [packed=true];
  29. }
  30. */
  31. message protobuf_sgx_attributes_t {
  32. required uint64 flags = 1;
  33. required uint64 xfrm = 2;
  34. }
  35. message protobuf_sgx_ec256_public_t {
  36. repeated uint32 gx = 1 [packed=true];
  37. repeated uint32 gy = 2 [packed=true];
  38. }
  39. // Composite message types
  40. // Tag numbers - first all the repeated ones (arrays) and then the required ones, as per the docs.
  41. message protobuf_sgx_report_body_t {
  42. repeated uint32 cpu_svn = 1 [packed=true];
  43. required uint32 misc_select = 9;
  44. repeated uint32 reserved1 = 2 [packed=true];
  45. required protobuf_sgx_attributes_t attributes = 10;
  46. repeated uint32 mr_enclave = 3 [packed=true];
  47. repeated uint32 reserved2 = 4 [packed=true];
  48. repeated uint32 mr_signer = 5 [packed=true];
  49. repeated uint32 reserved3 = 6 [packed=true];
  50. required uint32 isv_prod_id = 11;
  51. required uint32 isv_svn = 12;
  52. repeated uint32 reserved4 = 7 [packed=true];
  53. repeated uint32 report_data = 8 [packed=true];
  54. }
  55. message protobuf_sgx_report_t {
  56. required protobuf_sgx_report_body_t body = 1;
  57. repeated uint32 key_id = 2 [packed=true];
  58. repeated uint32 mac = 3 [packed=true];
  59. }
  60. message protobuf_sgx_target_info_t {
  61. repeated uint32 mr_enclave = 1 [packed=true];
  62. required protobuf_sgx_attributes_t attributes = 4;
  63. repeated uint32 reserved1 = 2 [packed=true];
  64. required uint32 misc_select = 5;
  65. repeated uint32 reserved2 = 3 [packed=true];
  66. }
  67. message protobuf_sgx_dh_msg1_t {
  68. required protobuf_sgx_ec256_public_t g_a = 1;
  69. required protobuf_sgx_target_info_t target = 2;
  70. }
  71. message protobuf_sgx_dh_msg2_t {
  72. required protobuf_sgx_ec256_public_t g_b = 1;
  73. required protobuf_sgx_report_t report = 2;
  74. repeated uint32 cmac = 3 [packed=true];
  75. }
  76. message protobuf_sgx_dh_msg3_body_t {
  77. required protobuf_sgx_report_t report = 1;
  78. repeated uint32 additional_prop = 2;
  79. }
  80. message protobuf_sgx_dh_msg3_t {
  81. required protobuf_sgx_dh_msg3_body_t msg3_body = 1;
  82. repeated uint32 cmac = 2 [packed=true];
  83. }
  84. // for post-LA key establishment and other msgs (in particular, between Apache and Decryptor)
  85. message protobuf_post_LA_encrypted_msg_t {
  86. required bytes msg = 1 ;
  87. }