1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #include "sgx_tcrypto.h"
- #include "ippcp.h"
- #include "stdlib.h"
- #ifndef SAFE_FREE
- #define SAFE_FREE(ptr) {if (NULL != (ptr)) {free(ptr); (ptr)=NULL;}}
- #endif
- sgx_status_t sgx_sha256_msg(const uint8_t *p_src, uint32_t src_len, sgx_sha256_hash_t *p_hash)
- {
- if ((p_src == NULL) || (p_hash == NULL))
- {
- return SGX_ERROR_INVALID_PARAMETER;
- }
- IppStatus ipp_ret = ippStsNoErr;
- ipp_ret = ippsHashMessage((const Ipp8u *) p_src, src_len, (Ipp8u *)p_hash, IPP_ALG_HASH_SHA256);
- switch (ipp_ret)
- {
- case ippStsNoErr: return SGX_SUCCESS;
- case ippStsMemAllocErr: return SGX_ERROR_OUT_OF_MEMORY;
- case ippStsNullPtrErr:
- case ippStsLengthErr: return SGX_ERROR_INVALID_PARAMETER;
- default: return SGX_ERROR_UNEXPECTED;
- }
- }
|