#ifndef COMMON_ALGO_H
#define COMMON_ALGO_H
#include "common_cipher.h"
#include "common_utils.h"
#ifdef __cplusplus
extern "C" {
#endif
#define INTERNAL_MIN_INDEX_NUM 1
#define INTERNAL_MAX_INDEX_NUM 1024
#define GDAC_KEK_TYPE 9
#define GDAC_KEY_EXIST 0x100000
#define GDAC_KEY_NOT_EXIST 0
#define GDAC_MODE_CBC 0x00000002
#define GDAC_SM4 0x00000400
#define GDAC_AES128 0x00004000
#define GDAC_AES256 0x00008000
#define GDAC_SM4_CBC (GDAC_SM4|GDAC_MODE_CBC)
#define GDAC_AES128_CBC (GDAC_AES128|GDAC_MODE_CBC)
#define GDAC_AES256_CBC (GDAC_AES256|GDAC_MODE_CBC)
#define GDAC_SM3 0x00000001
#define GDAC_SHA256 0x00000004
#define GDAC_HMAC_SM3 0x00100001
#define GDAC_HMAC_SHA256 0x00100004
#define SWXA_SMS4_CBC 0x00000402
#define SWXA_SMS4_CTR 0x00000420
#define SWXA_AES_CBC 0x00002002
#define SWXA_AES_CTR 0x00002020
#define SWXA_SM3 0x00000001
#define SWXA_SHA256 0x00000004
typedef enum {
TA_HMAC_SHA256 = 6,
TA_HMAC_SM3 = 20,
}TA_HMAC_ALG;
typedef enum {
TA_AES128 = 3,
TA_AES256 = 5,
TA_SM4 = 7,
}TA_SYMM_ALG;
typedef enum {
TA_CBC = 1,
}TA_SYMM_MODE;
typedef enum {
TA_SM3 = 1,
TA_SHA256 = 4,
}TA_HASH_ALG;
#define TA_SM4_CBC 0X00000402
#define TA_AES_CBC 0x80000202
#define INTERNAL_DO_ENC 1
#define INTERNAL_DO_DEC 0
#define INTERNAL_MAX_KEY_LEN 32
#define INTERNAL_BLOCK_LEN 16
#define INTERNAL_IV_LEN 16
#define INTERNAL_HMAC_LEN 32
#define INTERNAL_MSG_BLOCK_LEN 8192
#define INTERNAL_KEY_128_BITS 128
#define INTERNAL_KEY_256_BITS 256
typedef struct {
void *session;
unsigned int algotype;
unsigned int algomode;
int enc;
unsigned int keysize;
unsigned char key[INTERNAL_MAX_KEY_LEN];
}InternalKeyCtx;
extern int get_supported_feature(ModuleType type, SupportedFeature *supported_feature);
extern int get_real_symm_algo_type(ModuleType moduletype, ModuleSymmKeyAlgo symmalgotype, unsigned int* realtype, unsigned int* realmode);
extern int get_real_digest_algo_type(ModuleType moduletype, ModuleDigestAlgo type, unsigned int* realtype);
extern int get_key_len_by_algo_type(ModuleSymmKeyAlgo type);
extern void transform_jnta_algo_type(unsigned int type, unsigned int mode, unsigned int *standardtype);
#ifdef __cplusplus
}
#endif
#endif