• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*############################################################################
2   # Copyright 2016-2017 Intel Corporation
3   #
4   # Licensed under the Apache License, Version 2.0 (the "License");
5   # you may not use this file except in compliance with the License.
6   # You may obtain a copy of the License at
7   #
8   #     http://www.apache.org/licenses/LICENSE-2.0
9   #
10   # Unless required by applicable law or agreed to in writing, software
11   # distributed under the License is distributed on an "AS IS" BASIS,
12   # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   # See the License for the specific language governing permissions and
14   # limitations under the License.
15   ############################################################################*/
16 
17 /*!
18  * \file
19  * \brief Hash primitives.
20  */
21 
22 #ifndef EPID_COMMON_MATH_HASH_H_
23 #define EPID_COMMON_MATH_HASH_H_
24 
25 #include <limits.h>  // for CHAR_BIT
26 #include <stddef.h>
27 #include <stdint.h>
28 #include "epid/common/errors.h"
29 
30 /// Hash primitives
31 /*!
32   \defgroup HashPrimitives hash
33   Provides APIs for computing digests of messages.
34 
35   \ingroup EpidMath
36   @{
37 */
38 
39 #pragma pack(1)
40 /// SHA256 digest
41 typedef struct Sha256Digest {
42   unsigned char data[256 / CHAR_BIT];  ///< 256 bit data
43 } Sha256Digest;
44 #pragma pack()
45 
46 /// Computes SHA256 digest of a message.
47 /*!
48   \param[in] msg
49   Message to compute digest for.
50   \param[in] len
51   The size of msg in bytes.
52   \param[out] digest
53   The resulting message digest.
54 
55   \returns ::EpidStatus
56 */
57 EpidStatus Sha256MessageDigest(void const* msg, size_t len,
58                                Sha256Digest* digest);
59 
60 /*!
61   @}
62 */
63 #endif  // EPID_COMMON_MATH_HASH_H_
64