API参考
载入中...
搜索中...
未找到
crypt_eal_cipher.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
21
22#ifndef CRYPT_EAL_CIPHER_H
23#define CRYPT_EAL_CIPHER_H
24
25#include <stdint.h>
26#include <stdbool.h>
27#include "crypt_algid.h"
28#include "crypt_types.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif // __cplusplus
33
34typedef struct CRYPT_EAL_CipherCtxLocal CRYPT_EAL_CipherCtx;
35
45bool CRYPT_EAL_CipherIsValidAlgId(CRYPT_CIPHER_AlgId id);
46
57CRYPT_EAL_CipherCtx *CRYPT_EAL_CipherNewCtx(CRYPT_CIPHER_AlgId id);
58
69CRYPT_EAL_CipherCtx *CRYPT_EAL_ProviderCipherNewCtx(CRYPT_EAL_LibCtx *libCtx, int32_t algId, const char *attrName);
70
79void CRYPT_EAL_CipherFreeCtx(CRYPT_EAL_CipherCtx *ctx);
80
102int32_t CRYPT_EAL_CipherInit(CRYPT_EAL_CipherCtx *ctx, const uint8_t *key, uint32_t keyLen, const uint8_t *iv,
103 uint32_t ivLen, bool enc);
104
114void CRYPT_EAL_CipherDeinit(CRYPT_EAL_CipherCtx *ctx);
115
127int32_t CRYPT_EAL_CipherReinit(CRYPT_EAL_CipherCtx *ctx, uint8_t *iv, uint32_t ivLen);
128
168int32_t CRYPT_EAL_CipherUpdate(CRYPT_EAL_CipherCtx *ctx, const uint8_t *in, uint32_t inLen, uint8_t *out,
169 uint32_t *outLen);
170
191int32_t CRYPT_EAL_CipherFinal(CRYPT_EAL_CipherCtx *ctx, uint8_t *out, uint32_t *outLen);
192
219int32_t CRYPT_EAL_CipherCtrl(CRYPT_EAL_CipherCtx *ctx, int32_t type, void *data, uint32_t len);
220
230int32_t CRYPT_EAL_CipherSetPadding(CRYPT_EAL_CipherCtx *ctx, CRYPT_PaddingType type);
231
239int32_t CRYPT_EAL_CipherGetPadding(CRYPT_EAL_CipherCtx *ctx);
240
251int32_t CRYPT_EAL_CipherGetInfo(CRYPT_CIPHER_AlgId id, int32_t type, uint32_t *infoValue);
252
263int32_t CRYPT_EAL_CipherCopyCtx(CRYPT_EAL_CipherCtx *to, const CRYPT_EAL_CipherCtx *from);
264
273CRYPT_EAL_CipherCtx *CRYPT_EAL_CipherDupCtx(const CRYPT_EAL_CipherCtx *from);
274
275#ifdef __cplusplus
276}
277#endif // __cplusplus
278
279#endif // CRYPT_EAL_CIPHER_H
CRYPT_EAL_CipherCtx * CRYPT_EAL_ProviderCipherNewCtx(CRYPT_EAL_LibCtx *libCtx, int32_t algId, const char *attrName)
Generate symmetric encryption and decryption handles in the providers
int32_t CRYPT_EAL_CipherCopyCtx(CRYPT_EAL_CipherCtx *to, const CRYPT_EAL_CipherCtx *from)
Copy the cipher context.
int32_t CRYPT_EAL_CipherGetInfo(CRYPT_CIPHER_AlgId id, int32_t type, uint32_t *infoValue)
Obtain the type of an algorithm based on the algorithm ID.
int32_t CRYPT_EAL_CipherGetPadding(CRYPT_EAL_CipherCtx *ctx)
Obtain the padding type.
int32_t CRYPT_EAL_CipherInit(CRYPT_EAL_CipherCtx *ctx, const uint8_t *key, uint32_t keyLen, const uint8_t *iv, uint32_t ivLen, bool enc)
Initialize the symmetric encryption/decryption handle. The key cannot be null. Except the ECB mode,...
int32_t CRYPT_EAL_CipherUpdate(CRYPT_EAL_CipherCtx *ctx, const uint8_t *in, uint32_t inLen, uint8_t *out, uint32_t *outLen)
int32_t CRYPT_EAL_CipherCtrl(CRYPT_EAL_CipherCtx *ctx, int32_t type, void *data, uint32_t len)
void CRYPT_EAL_CipherDeinit(CRYPT_EAL_CipherCtx *ctx)
Deinitialize the handle and restore the handle to the state, when the CRYPT_EAL_CipherNewCtx function...
CRYPT_EAL_CipherCtx * CRYPT_EAL_CipherDupCtx(const CRYPT_EAL_CipherCtx *from)
Dup the cipher context.
int32_t CRYPT_EAL_CipherSetPadding(CRYPT_EAL_CipherCtx *ctx, CRYPT_PaddingType type)
Set the padding mode.
void CRYPT_EAL_CipherFreeCtx(CRYPT_EAL_CipherCtx *ctx)
Release the symmetric encryption/decryption handle. Clear sensitive information before releasing the ...
int32_t CRYPT_EAL_CipherReinit(CRYPT_EAL_CipherCtx *ctx, uint8_t *iv, uint32_t ivLen)
CRYPT_EAL_CipherCtx * CRYPT_EAL_CipherNewCtx(CRYPT_CIPHER_AlgId id)
Generate symmetric encryption and decryption handles.
bool CRYPT_EAL_CipherIsValidAlgId(CRYPT_CIPHER_AlgId id)
Check whether the given symmetric algorithm ID is valid.
int32_t CRYPT_EAL_CipherFinal(CRYPT_EAL_CipherCtx *ctx, uint8_t *out, uint32_t *outLen)
Fill the data with the size of the block and output the encrypted data; the AEAD tag is obtained thro...