openHiTLS API openHiTLS 0.1.0-Alpha1
crypt_eal_cipher.h
浏览该文件的文档.
1/*---------------------------------------------------------------------------------------------
2 * This file is part of the openHiTLS project.
3 * Copyright © 2023 Huawei Technologies Co.,Ltd. All rights reserved.
4 * Licensed under the openHiTLS Software license agreement 1.0. See LICENSE in the project root
5 * for license information.
6 *---------------------------------------------------------------------------------------------
7 */
8
15#ifndef CRYPT_EAL_CIPHER_H
16#define CRYPT_EAL_CIPHER_H
17
18#include <stdint.h>
19#include <stdbool.h>
20#include "crypt_algid.h"
21#include "crypt_types.h"
22#include "crypt_method.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif // __cplusplus
27
28typedef struct CryptEalCipherCtx CRYPT_EAL_CipherCtx;
29
39
51
61
83int32_t CRYPT_EAL_CipherInit(CRYPT_EAL_CipherCtx *ctx, const uint8_t *key, uint32_t keyLen, const uint8_t *iv,
84 uint32_t ivLen, bool enc);
85
96
108int32_t CRYPT_EAL_CipherReinit(CRYPT_EAL_CipherCtx *ctx, uint8_t *iv, uint32_t ivLen);
109
149int32_t CRYPT_EAL_CipherUpdate(CRYPT_EAL_CipherCtx *ctx, const uint8_t *in, uint32_t inLen, uint8_t *out,
150 uint32_t *outLen);
151
172int32_t CRYPT_EAL_CipherFinal(CRYPT_EAL_CipherCtx *ctx, uint8_t *out, uint32_t *outLen);
173
204int32_t CRYPT_EAL_CipherCtrl(CRYPT_EAL_CipherCtx *ctx, int32_t type, void *data, uint32_t len);
205
216
225
236int32_t CRYPT_EAL_CipherGetInfo(CRYPT_CIPHER_AlgId id, int32_t type, uint32_t *infoValue);
237
238#ifdef __cplusplus
239}
240#endif // __cplusplus
241
242#endif // CRYPT_EAL_CIPHER_H
CRYPT_CIPHER_AlgId
Symmetric algorithm mode ID
Definition crypt_algid.h:122
struct CryptEalCipherCtx CRYPT_EAL_CipherCtx
Definition crypt_eal_cipher.h:28
CRYPT_PaddingType
Definition crypt_types.h:426
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...
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...