API参考
载入中...
搜索中...
未找到
crypt_modes_aes_wrap.h
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 CRYPT_MODES_AES_WRAP_H
17#define CRYPT_MODES_AES_WRAP_H
18
19#include "hitls_build.h"
20#ifdef HITLS_CRYPTO_WRAP
21
22#include <stdint.h>
23#include "crypt_eal_cipher.h"
24#include "crypt_types.h"
25#include "crypt_algid.h"
26#include "crypt_local_types.h"
27#include "crypt_modes.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif // __cplusplus
32
33#define CRYPT_WRAP_BLOCKSIZE 8
34#define CRYPT_WRAP_AIV_SIZE 4
35#define CRYPT_WRAP_MAX_INPUT_LEN (UINT32_MAX - 2 * CRYPT_WRAP_BLOCKSIZE)
36
37typedef struct {
38 void *ciphCtx; /* AES context */
39 const EAL_SymMethod *ciphMeth; /* Functions of AES */
40 uint8_t iv[CRYPT_WRAP_BLOCKSIZE]; /* Processed IV information. The length is 8 bytes. */
41 bool flagPad; /* Indicates whether to support padding. */
42 uint8_t blockSize; /* Save the block size. */
43} MODES_CipherWRAPCtx;
44
45struct ModesWRAPCtx {
46 int32_t algId;
47 MODES_CipherWRAPCtx wrapCtx;
48 bool enc;
49};
50
51typedef struct ModesWRAPCtx MODES_WRAP_Ctx;
52
53MODES_WRAP_Ctx *MODES_WRAP_PadNewCtx(int32_t algId);
54
55MODES_WRAP_Ctx *MODES_WRAP_NoPadNewCtx(int32_t algId);
56
57MODES_WRAP_Ctx *MODES_WRAP_PadNewCtxEx(void *libCtx, int32_t algId);
58
59MODES_WRAP_Ctx *MODES_WRAP_NoPadNewCtxEx(void *libCtx, int32_t algId);
60
61int32_t MODES_WRAP_InitCtx(MODES_WRAP_Ctx *modeCtx, const uint8_t *key, uint32_t keyLen, const uint8_t *iv,
62 uint32_t ivLen, void *param, bool enc);
63
64int32_t MODES_WRAP_Update(MODES_WRAP_Ctx *modeCtx, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen);
65
66int32_t MODES_WRAP_Final(MODES_WRAP_Ctx *modeCtx, uint8_t *out, uint32_t *outLen);
67
68int32_t MODE_WRAP_Ctrl(MODES_WRAP_Ctx *modeCtx, int32_t opt, void *val, uint32_t len);
69
70int32_t MODE_WRAP_DeInitCtx(MODES_WRAP_Ctx *modeCtx);
71
72void MODES_WRAP_FreeCtx(MODES_WRAP_Ctx *modeCtx);
73
74MODES_WRAP_Ctx *MODES_WRAP_DupCtx(const MODES_WRAP_Ctx *modeCtx);
75
76#ifdef __cplusplus
77}
78#endif // __cplusplus
79
80#endif // HITLS_CRYPTO_WRAP
81
82#endif // CRYPT_MODES_AES_WRAP_H
定义 crypt_local_types.h:241