aesm_encode.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (C) 2011-2016 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 _AESM_ENCODE_H_
  32. #define _AESM_ENCODE_H_
  33. #include "sgx_urts.h"
  34. #include "se_thread.h"
  35. #ifdef __cplusplus
  36. extern "C"{
  37. #endif
  38. /*Function to provide an upper bound of buffer size of encoded message for an input request
  39. *@param req, the header for the input request such as ProvMsg1 or ProvMsg3
  40. *@return an upper bound of the required buffer size for the encoded message
  41. */
  42. uint32_t get_request_encoding_length(const uint8_t *req);
  43. /*Function to provide an upper bound of the response body size given the length of encoded response message
  44. *@param buf_len, the length of the encoded message for an response message
  45. *@return an upper bound of the length in bytes of decoded response message body such as ProvMsg2 or ProvMsg4
  46. */
  47. uint32_t get_response_decoding_length(uint32_t buf_len);
  48. /*Function to encode an request message so that we could send it to Provisioning server
  49. *@param req, pointer to the request
  50. *@param out_buf, pointer to a buffer to receive the encoded request message
  51. *@param out_len, *out_len to pass in the buffer len and return the encoded message length when successful
  52. *@return true if successful and false if there's any error. No error code provided
  53. */
  54. bool encode_request(const uint8_t *req, uint32_t req_len, uint8_t *out_buf, uint32_t *out_len);
  55. /*Function to decode an response message from Provisioning Server
  56. *@param input_buf, pointer to the encoded response message
  57. *@param input_len, length in bytes of the encoded response message
  58. *@param resp, pointer to a bufer to recieve the decoded message
  59. *@param out_len, *out_len to pass in the buffer len and return the decoded response message
  60. *@return true if successful and false if there's any error. No error code provided
  61. */
  62. bool decode_response(const uint8_t *input_buf, uint32_t input_len, uint8_t *resp, uint32_t *out_len);
  63. #ifdef __cplusplus
  64. };
  65. #endif/*__cplusplus*/
  66. #endif/*_AESM_ENCOCE_H_*/