handshaker.proto 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // Copyright 2018 gRPC authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. import "test/core/tsi/alts/fake_handshaker/transport_security_common.proto";
  16. package grpc.gcp;
  17. option java_package = "io.grpc.alts.internal";
  18. enum HandshakeProtocol {
  19. // Default value.
  20. HANDSHAKE_PROTOCOL_UNSPECIFIED = 0;
  21. // TLS handshake protocol.
  22. TLS = 1;
  23. // Application Layer Transport Security handshake protocol.
  24. ALTS = 2;
  25. }
  26. enum NetworkProtocol {
  27. NETWORK_PROTOCOL_UNSPECIFIED = 0;
  28. TCP = 1;
  29. UDP = 2;
  30. }
  31. message Endpoint {
  32. // IP address. It should contain an IPv4 or IPv6 string literal, e.g.
  33. // "192.168.0.1" or "2001:db8::1".
  34. string ip_address = 1;
  35. // Port number.
  36. int32 port = 2;
  37. // Network protocol (e.g., TCP, UDP) associated with this endpoint.
  38. NetworkProtocol protocol = 3;
  39. }
  40. message Identity {
  41. oneof identity_oneof {
  42. // Service account of a connection endpoint.
  43. string service_account = 1;
  44. // Hostname of a connection endpoint.
  45. string hostname = 2;
  46. }
  47. }
  48. message StartClientHandshakeReq {
  49. // Handshake security protocol requested by the client.
  50. HandshakeProtocol handshake_security_protocol = 1;
  51. // The application protocols supported by the client, e.g., "h2" (for http2),
  52. // "grpc".
  53. repeated string application_protocols = 2;
  54. // The record protocols supported by the client, e.g.,
  55. // "ALTSRP_GCM_AES128".
  56. repeated string record_protocols = 3;
  57. // (Optional) Describes which server identities are acceptable by the client.
  58. // If target identities are provided and none of them matches the peer
  59. // identity of the server, handshake will fail.
  60. repeated Identity target_identities = 4;
  61. // (Optional) Application may specify a local identity. Otherwise, the
  62. // handshaker chooses a default local identity.
  63. Identity local_identity = 5;
  64. // (Optional) Local endpoint information of the connection to the server,
  65. // such as local IP address, port number, and network protocol.
  66. Endpoint local_endpoint = 6;
  67. // (Optional) Endpoint information of the remote server, such as IP address,
  68. // port number, and network protocol.
  69. Endpoint remote_endpoint = 7;
  70. // (Optional) If target name is provided, a secure naming check is performed
  71. // to verify that the peer authenticated identity is indeed authorized to run
  72. // the target name.
  73. string target_name = 8;
  74. // (Optional) RPC protocol versions supported by the client.
  75. RpcProtocolVersions rpc_versions = 9;
  76. // (Optional) Maximum frame size supported by the client.
  77. uint32 max_frame_size = 10;
  78. }
  79. message ServerHandshakeParameters {
  80. // The record protocols supported by the server, e.g.,
  81. // "ALTSRP_GCM_AES128".
  82. repeated string record_protocols = 1;
  83. // (Optional) A list of local identities supported by the server, if
  84. // specified. Otherwise, the handshaker chooses a default local identity.
  85. repeated Identity local_identities = 2;
  86. }
  87. message StartServerHandshakeReq {
  88. // The application protocols supported by the server, e.g., "h2" (for http2),
  89. // "grpc".
  90. repeated string application_protocols = 1;
  91. // Handshake parameters (record protocols and local identities supported by
  92. // the server) mapped by the handshake protocol. Each handshake security
  93. // protocol (e.g., TLS or ALTS) has its own set of record protocols and local
  94. // identities. Since protobuf does not support enum as key to the map, the key
  95. // to handshake_parameters is the integer value of HandshakeProtocol enum.
  96. map<int32, ServerHandshakeParameters> handshake_parameters = 2;
  97. // Bytes in out_frames returned from the peer's HandshakerResp. It is possible
  98. // that the peer's out_frames are split into multiple HandshakReq messages.
  99. bytes in_bytes = 3;
  100. // (Optional) Local endpoint information of the connection to the client,
  101. // such as local IP address, port number, and network protocol.
  102. Endpoint local_endpoint = 4;
  103. // (Optional) Endpoint information of the remote client, such as IP address,
  104. // port number, and network protocol.
  105. Endpoint remote_endpoint = 5;
  106. // (Optional) RPC protocol versions supported by the server.
  107. RpcProtocolVersions rpc_versions = 6;
  108. // (Optional) Maximum frame size supported by the server.
  109. uint32 max_frame_size = 7;
  110. }
  111. message NextHandshakeMessageReq {
  112. // Bytes in out_frames returned from the peer's HandshakerResp. It is possible
  113. // that the peer's out_frames are split into multiple NextHandshakerMessageReq
  114. // messages.
  115. bytes in_bytes = 1;
  116. }
  117. message HandshakerReq {
  118. oneof req_oneof {
  119. // The start client handshake request message.
  120. StartClientHandshakeReq client_start = 1;
  121. // The start server handshake request message.
  122. StartServerHandshakeReq server_start = 2;
  123. // The next handshake request message.
  124. NextHandshakeMessageReq next = 3;
  125. }
  126. }
  127. message HandshakerResult {
  128. // The application protocol negotiated for this connection.
  129. string application_protocol = 1;
  130. // The record protocol negotiated for this connection.
  131. string record_protocol = 2;
  132. // Cryptographic key data. The key data may be more than the key length
  133. // required for the record protocol, thus the client of the handshaker
  134. // service needs to truncate the key data into the right key length.
  135. bytes key_data = 3;
  136. // The authenticated identity of the peer.
  137. Identity peer_identity = 4;
  138. // The local identity used in the handshake.
  139. Identity local_identity = 5;
  140. // Indicate whether the handshaker service client should keep the channel
  141. // between the handshaker service open, e.g., in order to handle
  142. // post-handshake messages in the future.
  143. bool keep_channel_open = 6;
  144. // The RPC protocol versions supported by the peer.
  145. RpcProtocolVersions peer_rpc_versions = 7;
  146. // The maximum frame size of the peer.
  147. uint32 max_frame_size = 8;
  148. }
  149. message HandshakerStatus {
  150. // The status code. This could be the gRPC status code.
  151. uint32 code = 1;
  152. // The status details.
  153. string details = 2;
  154. }
  155. message HandshakerResp {
  156. // Frames to be given to the peer for the NextHandshakeMessageReq. May be
  157. // empty if no out_frames have to be sent to the peer or if in_bytes in the
  158. // HandshakerReq are incomplete. All the non-empty out frames must be sent to
  159. // the peer even if the handshaker status is not OK as these frames may
  160. // contain the alert frames.
  161. bytes out_frames = 1;
  162. // Number of bytes in the in_bytes consumed by the handshaker. It is possible
  163. // that part of in_bytes in HandshakerReq was unrelated to the handshake
  164. // process.
  165. uint32 bytes_consumed = 2;
  166. // This is set iff the handshake was successful. out_frames may still be set
  167. // to frames that needs to be forwarded to the peer.
  168. HandshakerResult result = 3;
  169. // Status of the handshaker.
  170. HandshakerStatus status = 4;
  171. }
  172. service HandshakerService {
  173. // Handshaker service accepts a stream of handshaker request, returning a
  174. // stream of handshaker response. Client is expected to send exactly one
  175. // message with either client_start or server_start followed by one or more
  176. // messages with next. Each time client sends a request, the handshaker
  177. // service expects to respond. Client does not have to wait for service's
  178. // response before sending next request.
  179. rpc DoHandshake(stream HandshakerReq)
  180. returns (stream HandshakerResp) {
  181. }
  182. }