mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 00:46:17 +08:00
Add AEAD modes
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <gmssl/sm3.h>
|
||||
#include <gmssl/sm4.h>
|
||||
#include <gmssl/zuc.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -19,8 +22,10 @@ extern "C" {
|
||||
|
||||
|
||||
typedef struct {
|
||||
SM4_CBC_CTX cbc_ctx;
|
||||
SM3_HMAC_CTX hmac_ctx;
|
||||
SM4_CBC_CTX enc_ctx;
|
||||
SM3_HMAC_CTX mac_ctx;
|
||||
uint8_t mac[SM3_HMAC_SIZE];
|
||||
size_t maclen;
|
||||
} SM4_CBC_SM3_HMAC_CTX;
|
||||
|
||||
int sm4_cbc_sm3_hmac_encrypt_init(SM4_CBC_SM3_HMAC_CTX *ctx,
|
||||
@@ -36,8 +41,10 @@ int sm4_cbc_sm3_hmac_decrypt_finish(SM4_CBC_SM3_HMAC_CTX *ctx, uint8_t *out, siz
|
||||
|
||||
|
||||
typedef struct {
|
||||
SM4_CTR_CTX ctr_ctx;
|
||||
SM3_HMAC_CTX hmac_ctx;
|
||||
SM4_CTR_CTX enc_ctx;
|
||||
SM3_HMAC_CTX mac_ctx;
|
||||
uint8_t mac[SM3_HMAC_SIZE];
|
||||
size_t maclen;
|
||||
} SM4_CTR_SM3_HMAC_CTX;
|
||||
|
||||
int sm4_ctr_sm3_hmac_encrypt_init(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
@@ -74,10 +81,6 @@ int sm4_gcm_decrypt_finish(SM4_GCM_CTX *ctx, uint8_t *out, size_t *outlen);
|
||||
typedef struct {
|
||||
} ZUC_WITH_MAC_CTX;
|
||||
|
||||
int zuc_encrypt_init(ZUC_CTX *ctx, const uint8_t key[ZUC_KEY_SIZE], const uint8_t iv[ZUC_IV_SIZE]);
|
||||
int zuc_encrypt_update(ZUC_CTX *ctx, const uint8_t *in, size_t inlen, uint8_t *out, size_t *outlen);
|
||||
int zuc_encrypt_finish(ZUC_CTX *ctx, uint8_t *out, size_t *outlen);
|
||||
|
||||
int zuc_with_mac_encrypt_init(ZUC_WITH_MAC_CTX *ctx,
|
||||
const uint8_t key[ZUC_KEY_SIZE], const uint8_t iv[ZUC_IV_SIZE],
|
||||
const uint8_t *aad, size_t aadlen);
|
||||
|
||||
Reference in New Issue
Block a user