From: Chenghai Huang huangchenghai2@huawei.com
The sec algorithm has multiple common header files, so they are centrally stored in wd_alg_common.
Signed-off-by: Chenghai Huang huangchenghai2@huawei.com --- drv/hisi_sec.c | 11 ++--------- include/wd_alg_common.h | 13 +++++++++++++ include/wd_cipher.h | 1 - include/wd_digest.h | 2 -- wd_aead.c | 9 --------- wd_cipher.c | 7 ------- wd_digest.c | 9 --------- 7 files changed, 15 insertions(+), 37 deletions(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c index 9102a27..5b114f6 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -63,13 +63,6 @@ #define SEC_MAC_LEN_MASK 0x1F #define SEC_AUTH_LEN_MASK 0x3F
-#define DES_KEY_SIZE 8 -#define SEC_3DES_2KEY_SIZE (2 * DES_KEY_SIZE) -#define SEC_3DES_3KEY_SIZE (3 * DES_KEY_SIZE) -#define AES_KEYSIZE_128 16 -#define AES_KEYSIZE_192 24 -#define AES_KEYSIZE_256 32 - #define DES3_BLOCK_SIZE 8 #define AES_BLOCK_SIZE 16 #define CTR_128BIT_COUNTER 16 @@ -823,9 +816,9 @@ static void update_iv_sgl(struct wd_cipher_msg *msg)
static int get_3des_c_key_len(struct wd_cipher_msg *msg, __u8 *c_key_len) { - if (msg->key_bytes == SEC_3DES_2KEY_SIZE) { + if (msg->key_bytes == DES3_2KEY_SIZE) { *c_key_len = CKEY_LEN_3DES_2KEY; - } else if (msg->key_bytes == SEC_3DES_3KEY_SIZE) { + } else if (msg->key_bytes == DES3_3KEY_SIZE) { *c_key_len = CKEY_LEN_3DES_3KEY; } else { WD_ERR("failed to check 3des key size, size = %u\n", diff --git a/include/wd_alg_common.h b/include/wd_alg_common.h index 5652db3..32b8630 100644 --- a/include/wd_alg_common.h +++ b/include/wd_alg_common.h @@ -29,6 +29,19 @@ extern "C" { #define CTX_TYPE_INVALID 9999 #define POLL_TIME 1000
+/* Key size of chiper */ +#define MAX_CIPHER_KEY_SIZE 64 +#define AES_KEYSIZE_128 16 +#define AES_KEYSIZE_192 24 +#define AES_KEYSIZE_256 32 +#define SM4_KEY_SIZE 16 +#define DES_KEY_SIZE 8 +#define DES3_2KEY_SIZE (2 * DES_KEY_SIZE) +#define DES3_3KEY_SIZE (3 * DES_KEY_SIZE) + +/* Key size of digest */ +#define MAX_HMAC_KEY_SIZE 128U + enum alg_task_type { TASK_MIX = 0x0, TASK_HW, diff --git a/include/wd_cipher.h b/include/wd_cipher.h index a712b53..d54f7fe 100644 --- a/include/wd_cipher.h +++ b/include/wd_cipher.h @@ -18,7 +18,6 @@ extern "C" { #define AES_BLOCK_SIZE 16 #define GCM_IV_SIZE 12 #define DES3_BLOCK_SIZE 8 -#define MAX_CIPHER_KEY_SIZE 64 #define MAX_IV_SIZE AES_BLOCK_SIZE
/** diff --git a/include/wd_digest.h b/include/wd_digest.h index ad4d579..f0916c3 100644 --- a/include/wd_digest.h +++ b/include/wd_digest.h @@ -14,8 +14,6 @@ extern "C" { #endif
-#define MAX_HMAC_KEY_SIZE 128U - /** * wd_digest_type - Algorithm type of digest * algorithm should be offered by struct wd_digest_arg diff --git a/wd_aead.c b/wd_aead.c index 6d49d76..34a3b86 100644 --- a/wd_aead.c +++ b/wd_aead.c @@ -10,15 +10,6 @@ #include "include/drv/wd_aead_drv.h" #include "wd_aead.h"
-#define XTS_MODE_KEY_DIVISOR 2 -#define SM4_KEY_SIZE 16 -#define DES_KEY_SIZE 8 -#define DES3_2KEY_SIZE (2 * DES_KEY_SIZE) -#define DES3_3KEY_SIZE (3 * DES_KEY_SIZE) -#define AES_KEYSIZE_128 16 -#define AES_KEYSIZE_192 24 -#define AES_KEYSIZE_256 32 - #define WD_AEAD_CCM_GCM_MIN 4U #define WD_AEAD_CCM_GCM_MAX 16
diff --git a/wd_cipher.c b/wd_cipher.c index 47c0bf8..f35ce6f 100644 --- a/wd_cipher.c +++ b/wd_cipher.c @@ -13,13 +13,6 @@
#define XTS_MODE_KEY_SHIFT 1 #define XTS_MODE_KEY_LEN_MASK 0x1 -#define SM4_KEY_SIZE 16 -#define DES_KEY_SIZE 8 -#define DES3_2KEY_SIZE (2 * DES_KEY_SIZE) -#define DES3_3KEY_SIZE (3 * DES_KEY_SIZE) -#define AES_KEYSIZE_128 16 -#define AES_KEYSIZE_192 24 -#define AES_KEYSIZE_256 32
#define DES_WEAK_KEY_NUM 16
diff --git a/wd_digest.c b/wd_digest.c index 9008bcb..acf341a 100644 --- a/wd_digest.c +++ b/wd_digest.c @@ -10,16 +10,7 @@ #include "include/drv/wd_digest_drv.h" #include "wd_digest.h"
-#define XTS_MODE_KEY_DIVISOR 2 -#define SM4_KEY_SIZE 16 -#define DES_KEY_SIZE 8 -#define DES3_3KEY_SIZE (3 * DES_KEY_SIZE) #define GMAC_IV_LEN 16 -#define AES_KEYSIZE_128 16 -#define AES_KEYSIZE_192 24 -#define AES_KEYSIZE_256 32 - -#define DES_WEAK_KEY_NUM 4
static __u32 g_digest_mac_len[WD_DIGEST_TYPE_MAX] = { WD_DIGEST_SM3_LEN, WD_DIGEST_MD5_LEN, WD_DIGEST_SHA1_LEN,