Decryptor.cpp 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. // Enclave2.cpp : Defines the exported functions for the DLL application
  32. #include "sgx_eid.h"
  33. #include "sgx_tcrypto.h"
  34. #include "Decryptor_t.h"
  35. #include "EnclaveMessageExchange.h"
  36. #include "error_codes.h"
  37. #include "Utility_Decryptor.h"
  38. #include "sgx_thread.h"
  39. #include "sgx_dh.h"
  40. #include <map>
  41. #define UNUSED(val) (void)(val)
  42. //Function that is used to verify the trust of the other enclave
  43. //Each enclave can have its own way verifying the peer enclave identity
  44. extern "C" uint32_t verify_peer_enclave_trust(__attribute__((unused)) sgx_dh_session_enclave_identity_t* peer_enclave_identity)
  45. {
  46. if(!peer_enclave_identity)
  47. {
  48. return INVALID_PARAMETER_ERROR;
  49. }
  50. // sgx_measurement_t actual_mr_enclave = peer_enclave_identity->mr_enclave;
  51. // sgx_measurement_t actual_mr_signer = peer_enclave_identity->mr_signer;
  52. // verifier's mrsigner
  53. // uint8_t expected_mr_signer[32] ={0xdf, 0xd7, 0x3b, 0x93, 0xea, 0x39, 0x02, 0x02, 0x3c, 0xd0, 0x52, 0x1a, 0xbd, 0x00, 0xaf, 0xb9, 0xa6, 0x54, 0x57, 0x3e, 0xe5, 0xef, 0x36, 0xf4, 0x8c, 0xc2, 0x4d, 0x92, 0x70, 0xae, 0xd4, 0x7c};
  54. // int count;
  55. // for(count=0; count<SGX_HASH_SIZE; count++)
  56. // {
  57. /* if( actual_mr_enclave.m[count] != expected_mr_enclave[count] )
  58. {
  59. return ENCLAVE_TRUST_ERROR;
  60. }
  61. if( actual_mr_signer.m[count] != expected_mr_signer[count] )
  62. {
  63. return ENCLAVE_TRUST_ERROR; // TODO: Different error here.
  64. }*/
  65. // }
  66. return SGX_SUCCESS;
  67. //}
  68. /* if(peer_enclave_identity->isv_prod_id != 0 || !(peer_enclave_identity->attributes.flags & SGX_FLAGS_INITTED))
  69. {
  70. return ENCLAVE_TRUST_ERROR;
  71. }
  72. else
  73. {
  74. return SUCCESS;
  75. }*/
  76. return SUCCESS; //ENCLAVE_TRUST_ERROR;
  77. }
  78. uint32_t foo()
  79. {
  80. return 0;
  81. }