mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 00:46:17 +08:00
Re-organize SM4/GCM related source files
This commit is contained in:
@@ -25,7 +25,6 @@ extern "C" {
|
||||
#define GHASH_SIZE (16)
|
||||
|
||||
|
||||
|
||||
void ghash(const uint8_t h[16], const uint8_t *aad, size_t aadlen,
|
||||
const uint8_t *c, size_t clen, uint8_t out[16]);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2023 The GmSSL Project. All Rights Reserved.
|
||||
* Copyright 2014-2024 The GmSSL Project. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
@@ -7,14 +7,13 @@
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
#ifndef GMSSL_AEAD_H
|
||||
#define GMSSL_AEAD_H
|
||||
#ifndef GMSSL_SM4_CBC_SM3_HMAC_H
|
||||
#define GMSSL_SM4_CBC_SM3_HMAC_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <gmssl/sm3.h>
|
||||
#include <gmssl/sm4.h>
|
||||
#include <gmssl/gcm.h>
|
||||
#include <gmssl/sm3.h>
|
||||
#include <gmssl/api.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -48,35 +47,6 @@ _gmssl_export int sm4_cbc_sm3_hmac_decrypt_finish(SM4_CBC_SM3_HMAC_CTX *ctx,
|
||||
uint8_t *out, size_t *outlen);
|
||||
|
||||
|
||||
typedef struct {
|
||||
SM4_CTR_CTX enc_ctx;
|
||||
SM3_HMAC_CTX mac_ctx;
|
||||
uint8_t mac[SM3_HMAC_SIZE];
|
||||
size_t maclen;
|
||||
} SM4_CTR_SM3_HMAC_CTX;
|
||||
|
||||
#define SM4_CTR_SM3_HMAC_KEY_SIZE 48
|
||||
#define SM4_CTR_SM3_HMAC_IV_SIZE 16
|
||||
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_encrypt_init(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
const uint8_t *key, size_t keylen, const uint8_t *iv, size_t ivlen,
|
||||
const uint8_t *aad, size_t aadlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_encrypt_update(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
const uint8_t *in, size_t inlen, uint8_t *out, size_t *outlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_encrypt_finish(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
uint8_t *out, size_t *outlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_decrypt_init(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
const uint8_t *key, size_t keylen, const uint8_t *iv, size_t ivlen,
|
||||
const uint8_t *aad, size_t aadlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_decrypt_update(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
const uint8_t *in, size_t inlen, uint8_t *out, size_t *outlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_decrypt_finish(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
uint8_t *out, size_t *outlen);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
53
include/gmssl/sm4_ctr_sm3_hmac.h
Normal file
53
include/gmssl/sm4_ctr_sm3_hmac.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2014-2024 The GmSSL Project. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
#ifndef GMSSL_SM4_CTR_SM3_HMAC_H
|
||||
#define GMSSL_SM4_CTR_SM3_HMAC_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <gmssl/sm4.h>
|
||||
#include <gmssl/sm3.h>
|
||||
#include <gmssl/api.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
SM4_CTR_CTX enc_ctx;
|
||||
SM3_HMAC_CTX mac_ctx;
|
||||
uint8_t mac[SM3_HMAC_SIZE];
|
||||
size_t maclen;
|
||||
} SM4_CTR_SM3_HMAC_CTX;
|
||||
|
||||
#define SM4_CTR_SM3_HMAC_KEY_SIZE 48
|
||||
#define SM4_CTR_SM3_HMAC_IV_SIZE 16
|
||||
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_encrypt_init(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
const uint8_t *key, size_t keylen, const uint8_t *iv, size_t ivlen,
|
||||
const uint8_t *aad, size_t aadlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_encrypt_update(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
const uint8_t *in, size_t inlen, uint8_t *out, size_t *outlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_encrypt_finish(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
uint8_t *out, size_t *outlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_decrypt_init(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
const uint8_t *key, size_t keylen, const uint8_t *iv, size_t ivlen,
|
||||
const uint8_t *aad, size_t aadlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_decrypt_update(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
const uint8_t *in, size_t inlen, uint8_t *out, size_t *outlen);
|
||||
_gmssl_export int sm4_ctr_sm3_hmac_decrypt_finish(SM4_CTR_SM3_HMAC_CTX *ctx,
|
||||
uint8_t *out, size_t *outlen);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user