comms.hpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef __COMMS_HPP__
  2. #define __COMMS_HPP__
  3. #include "enclave_api.h"
  4. // The enclave-to-enclave communication protocol is as follows. It
  5. // probably could just be attested TLS in a production environment, but
  6. // we're not implementing remote attestation at this time. This means
  7. // that the list of other enclaves' public keys are currently just
  8. // blindly trusted, so add a remote attestation step to validate them if
  9. // you want to deploy this for real.
  10. //
  11. // The protocol starts with a Sign-and-MAC (SIGMA) handshake, in the
  12. // pre-specified peer setting. The client is the lower-numbered node,
  13. // and the server is the higher-numbered node. The protocol is:
  14. //
  15. // Message 1 C -> S: g^x
  16. // Message 2 S -> C: g^y, Sig_S(MAC_{H_1a(g^{xy})}(g^y, g^x, Pub_S, Pub_C)
  17. // Message 3 C -> S: Sig_C(MAC_{H_1b(g^{xy})}(g^x, g^y, Pub_C, Pub_S)
  18. //
  19. // where Pub_C and Pub_S are the long-term signature keys of C and S.
  20. //
  21. // After the handshake, the client-to-server AES-GCM key is set to
  22. // H_2a(g^{xy}) and the server-to-client AES-GCM key is set to
  23. // H_2b(g^{xy}). H_na(x) and H_nb(x) are the first 128 bits and the
  24. // last 128 bits of SHA256(n || x) respectively.
  25. //
  26. // After the handshake, data is sent in logical messages, which are
  27. // divided into chunks of size at most FRAME_SIZE - SGX_AESGCM_MAC_SIZE
  28. // bytes of plaintext, which will expand to at most FRAME_SIZE bytes of
  29. // ciphertext. The IV for the first chunk in each direction is
  30. // 0x01 0x00 0x00 ... 0x00 (remember they use different keys in the two
  31. // directions), and each chunk increments the IV in a little-endian
  32. // manner. The MAC tag of SGX_AESGCM_MAC_SIZE bytes is at the end of
  33. // the chunk.
  34. bool comms_init_nodestate(const EnclaveAPINodeConfig *apinodeconfigs,
  35. nodenum_t num_nodes, nodenum_t my_node_num);
  36. #endif