sgx_dh_internal.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (C) 2011-2017 Intel Corporation. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in
  12. * the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Intel Corporation nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *
  30. */
  31. #ifndef _SGX_DH_INTERNAL_H_
  32. #define _SGX_DH_INTERNAL_H_
  33. #include "sgx.h"
  34. #include "sgx_defs.h"
  35. #include "sgx_ecp_types.h"
  36. #include "sgx_dh.h"
  37. #include "arch.h"
  38. #pragma pack(push, 1)
  39. typedef enum _sgx_dh_session_state_t
  40. {
  41. SGX_DH_SESSION_STATE_ERROR,
  42. SGX_DH_SESSION_STATE_RESET,
  43. SGX_DH_SESSION_RESPONDER_WAIT_M2,
  44. SGX_DH_SESSION_INITIATOR_WAIT_M1,
  45. SGX_DH_SESSION_INITIATOR_WAIT_M3,
  46. SGX_DH_SESSION_ACTIVE
  47. } sgx_dh_session_state_t;
  48. typedef struct _sgx_dh_responder_t{
  49. sgx_dh_session_state_t state; /*Responder State Machine State */
  50. sgx_ec256_private_t prv_key; /* 256bit EC private key */
  51. sgx_ec256_public_t pub_key; /* 512 bit EC public key */
  52. } sgx_dh_responder_t;
  53. typedef struct _sgx_dh_initator_t{
  54. sgx_dh_session_state_t state; /* Initiator State Machine State */
  55. union{
  56. sgx_ec256_private_t prv_key; /* 256bit EC private key */
  57. sgx_key_128bit_t smk_aek; /* 128bit SMK or AEK. Depending on the State */
  58. };
  59. sgx_ec256_public_t pub_key; /* 512 bit EC public key */
  60. sgx_ec256_public_t peer_pub_key; /* 512 bit EC public key from the Responder */
  61. sgx_ec256_dh_shared_t shared_key;
  62. } sgx_dh_initator_t;
  63. typedef struct _sgx_internal_dh_session_t{
  64. sgx_dh_session_role_t role; /* Initiator or Responder */
  65. union{
  66. sgx_dh_responder_t responder;
  67. sgx_dh_initator_t initiator;
  68. };
  69. } sgx_internal_dh_session_t;
  70. se_static_assert(sizeof(sgx_internal_dh_session_t) == SGX_DH_SESSION_DATA_SIZE); /*size mismatch on sgx_internal_dh_session_t and sgx_dh_session_t*/
  71. #pragma pack(pop)
  72. #endif