• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * This file is part of the openHiTLS project.
3  *
4  * openHiTLS is licensed under the Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *
8  *     http://license.coscl.org.cn/MulanPSL2
9  *
10  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
11  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
12  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
13  * See the Mulan PSL v2 for more details.
14  */
15 
16 #ifndef EAL_MD_LOCAL_H
17 #define EAL_MD_LOCAL_H
18 
19 #include "hitls_build.h"
20 #if defined(HITLS_CRYPTO_EAL) && defined(HITLS_CRYPTO_MD)
21 
22 #include <stdint.h>
23 #include "crypt_algid.h"
24 #include "crypt_local_types.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif // __cplusplus
29 
30 typedef enum {
31     CRYPT_MD_STATE_NEW = 0,
32     CRYPT_MD_STATE_INIT,
33     CRYPT_MD_STATE_UPDATE,
34     CRYPT_MD_STATE_FINAL,
35     CRYPT_MD_STATE_SQUEEZE
36 } CRYPT_MD_WORKSTATE;
37 
38 struct EAL_MdCtx {
39     bool isProvider;
40     EAL_MdUnitaryMethod *method;  /* algorithm operation entity */
41     void *data;        /* Algorithm ctx, mainly context */
42     uint32_t state;
43     CRYPT_MD_AlgId id;
44 };
45 
46 /**
47  * @ingroup eal
48  * @brief Method for generating the hash algorithm
49  *
50  * @param id [IN] Algorithm ID
51  *
52  * @return Pointer to CRYPT_MD_Method
53  * For other error codes, see crypt_errno.h.
54  */
55 const EAL_MdMethod *EAL_MdFindMethod(CRYPT_MD_AlgId id);
56 
57 int32_t EAL_Md(CRYPT_MD_AlgId id, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen);
58 
59 #ifdef __cplusplus
60 }
61 #endif // __cplusplus
62 
63 #endif // HITLS_CRYPTO_MD
64 
65 #endif // EAL_MD_LOCAL_H
66