• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FILLP_HMAC_H
17 #define FILLP_HMAC_H
18 #include "sha256.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 /* HMAC PAD value */
26 #define FILLP_HMAC_IPAD 0x36u
27 
28 /* HMAC PAD value */
29 #define FILLP_HMAC_OPAD 0x5Cu
30 
31 
32 #define FILLP_HMAC_SHA256_CTX_SIZE 208
33 
34 typedef struct {
35     FillpSha256Ctx hashki[1];
36     FillpSha256Ctx hashko[1];
37 } FillpHmacSha256Ctx;
38 
39 
40 /**
41 * @defgroup FillpHmacSha256
42 * @ingroup sec_cryptoStructures
43 * @par Prototype
44 * @code
45 * typedef struct
46 {
47     SEC_UCHAR data[FILLP_HMAC_SHA256_CTX_SIZE];
48 }FillHmacSha256CtxOld;
49 * @endcode
50 *
51 * @datastruct data[FILLP_HMAC_SHA256_CTX_SIZE] Represents the buffer for
52 * HMAC SHA256
53 * context.
54 */
55 
56 typedef struct {
57     FILLP_UINT8 data[FILLP_HMAC_SHA256_CTX_SIZE];
58 } FillpHmacSha256;
59 
60 
61 void FillpHmacSha256Init(OUT FillpHmacSha256 ctx[1], IN FILLP_UINT8 *key, FILLP_UINT32 klen,
62     struct SpungeInstance *pcbInst);
63 
64 void FillpHmacSha256Update(IO FillpHmacSha256 ctx[1], FILLP_CONST FILLP_UINT8 *data, FILLP_UINT32 dlen);
65 
66 void FillpHmacSha256Final(IO FillpHmacSha256 ctx[1], OUT FILLP_UINT8 digest[FILLP_SHA256_DIGEST_SIZE],
67     FILLP_UINT32 size);
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif /* FILLP_HMAC_H */
74