diff -Naur openssl-1.1.0i/engines/afalg/e_afalg.c openssl-1.1.0i-ok/engines/afalg/e_afalg.c
--- openssl-1.1.0i/engines/afalg/e_afalg.c	2021-11-10 14:33:20.368683157 +0800
+++ openssl-1.1.0i-ok/engines/afalg/e_afalg.c	2021-11-10 14:34:46.839679383 +0800
@@ -101,13 +101,6 @@
 static int afalg_cipher_cleanup(EVP_CIPHER_CTX *ctx);
 static int afalg_chk_platform(void);
 
-/*digest*/
-static int afalg_digests(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
-static int afalg_digest_init(EVP_MD_CTX *ctx);
-static int afalg_digest_update(EVP_MD_CTX *ctx, const void *data, size_t length);
-static int afalg_digest_cleanup(EVP_MD_CTX *ctx);
-static int afalg_digest_final(EVP_MD_CTX *ctx, unsigned char *md);
-
 //#define SUPPORT_CE_V3_2
 //#define SUPPORT_CE_V3_1
 
@@ -126,10 +119,18 @@
 	NID_aes_192_cbc,
 	NID_aes_256_cbc,
 
+#ifdef CE_CTR_MODE_ENABLE
 	NID_aes_128_ctr,
 	NID_aes_192_ctr,
 	NID_aes_256_ctr,
+#endif
+
+#if 0 //def CE_XTS_MODE_ENABLE
+	NID_aes_128_xts,
+	NID_aes_256_xts,
+#endif
 
+#ifdef CE_CFB_MODE_ENABLE
 	NID_aes_128_cfb1,
 	NID_aes_192_cfb1,
 	NID_aes_256_cfb1,
@@ -141,11 +142,13 @@
 	NID_aes_128_cfb128,
 	NID_aes_192_cfb128,
 	NID_aes_256_cfb128,
+#endif
 
+#ifdef CE_OFB_MODE_ENABLE
 	NID_aes_128_ofb128,
 	NID_aes_192_ofb128,
 	NID_aes_256_ofb128,
-
+#endif
 #ifndef OPENSSL_NO_DES
 	NID_des_ecb,
 	NID_des_cbc,
@@ -189,7 +192,7 @@
 		AES_BLOCK_SIZE, ALG_AES_IV_LEN,
 		EVP_CIPH_CBC_MODE, "cbc(aes)", NULL
 	},
-
+#ifdef CE_CTR_MODE_ENABLE
 	{
 		NID_aes_128_ctr, AES_KEY_SIZE_128,
 		AES_BLOCK_SIZE, ALG_AES_IV_LEN,
@@ -205,7 +208,8 @@
 		AES_BLOCK_SIZE, ALG_AES_IV_LEN,
 		EVP_CIPH_CTR_MODE, "ctr(aes)", NULL
 	},
-
+#endif
+#ifdef CE_CFB_MODE_ENABLE
 	{
 		NID_aes_128_cfb1, AES_KEY_SIZE_128,
 		AES_BLOCK_SIZE, ALG_AES_IV_LEN,
@@ -251,7 +255,8 @@
 		AES_BLOCK_SIZE, ALG_AES_IV_LEN,
 		EVP_CIPH_CFB_MODE, "cfb128(aes)", NULL
 	},
-
+#endif
+#ifdef CE_OFB_MODE_ENABLE
 	{
 		NID_aes_128_ofb128, AES_KEY_SIZE_128,
 		AES_BLOCK_SIZE, ALG_AES_IV_LEN,
@@ -267,7 +272,7 @@
 		AES_BLOCK_SIZE, ALG_AES_IV_LEN,
 		EVP_CIPH_OFB_MODE, "ofb(aes)", NULL
 	},
-
+#endif
 #ifndef OPENSSL_NO_DES
 	/* About DES algorithm type */
 	{
@@ -294,6 +299,7 @@
 };
 #define CIPHER_INFO_NUM       ALG_ARRAY_SIZE(x)
 
+#if CE_DIGESTS_ALG
 # define MD5_DIGEST_LENGTH 16
 
 static int afalg_digest_nids[] = {
@@ -345,7 +351,7 @@
 #define DIGEST_INFO_NUM       ALG_ARRAY_SIZE(x)
 
 static int afalg_digest_nids_num = (sizeof(afalg_digest_nids) / sizeof(afalg_digest_nids[0]));
-
+#endif
 
 void print_hex(void *_data, int _len, int _addr)
 {
@@ -1126,6 +1132,8 @@
 }
 
 /********digest function***********************/
+#if CE_DIGESTS_ALG
+
 static int afalg_digest_init(EVP_MD_CTX *ctx)
 {
 	afalg_ctx *actx = NULL;
@@ -1435,9 +1443,9 @@
 	return r;
 
 }
-
+#endif
 #ifndef OPENSSL_NO_RSA
-
+#if CE_ASYMMETRIC_ALG
 /*rsa algorithm*/
 #define RSA_MAX_LEN			4096
 #define ALG_OP_DECRYPT		0
@@ -1917,7 +1925,7 @@
 	return 1;
 }
 #endif /* OPENSSL_NO_RSA */
-
+#endif
 
 static int bind_afalg(ENGINE *e)
 {
@@ -1935,21 +1943,23 @@
 		AFALGerr(AFALG_F_BIND_AFALG, AFALG_R_INIT_FAILED);
 		return 0;
 	}
-
+#if CE_CIPHERS_ALG
 	/*set cipher handling for engine*/
 	if (!ENGINE_set_ciphers(e, afalg_ciphers)) {
 		AFALGerr(AFALG_F_BIND_AFALG, AFALG_R_INIT_FAILED);
 	} else {
 		success++;
 	}
-
+#endif
+#if CE_DIGESTS_ALG
 	if (!ENGINE_set_digests(e, afalg_digests)) {
 		AFALGerr(AFALG_F_BIND_AFALG, AFALG_R_INIT_FAILED);
 	} else {
 		success++;
 	}
-
+#endif
 #ifndef OPENSSL_NO_RSA
+#if CE_ASYMMETRIC_ALG
 	RSA_METHOD *afalg_rsa_method = NULL;
 
 	if (ENGINE_get_RSA(e))
@@ -1980,7 +1990,7 @@
 	}
 skip_rsa:
 #endif
-
+#endif
 out:
 	return success;
 }
@@ -2095,8 +2105,10 @@
 	int cnt = sizeof(nid2cipher_info) / sizeof(cipher_info_t);
 
 #ifndef OPENSSL_NO_RSA
+#if CE_ASYMMETRIC_ALG
 	RSA_meth_free(ENGINE_get_RSA(e));
 #endif
+#endif
 
 	for (i = 0; i < cnt; i++) {
 		if (nid2cipher_info[i].evp_cipher != NULL) {
diff -Naur openssl-1.1.0i/engines/afalg/e_afalg.h openssl-1.1.0i-ok/engines/afalg/e_afalg.h
--- openssl-1.1.0i/engines/afalg/e_afalg.h	2021-11-10 14:33:20.368683157 +0800
+++ openssl-1.1.0i-ok/engines/afalg/e_afalg.h	2021-11-10 14:34:58.917926864 +0800
@@ -37,6 +37,44 @@
                     perror(NULL); \
                 } while(0)
 
+#define CE_CIPHERS_ALG		1
+#define CE_DIGESTS_ALG		0
+#define CE_ASYMMETRIC_ALG	0
+
+#if CE_CIPHERS_ALG
+#define CE_CTR_MODE_ENABLE		1
+#define CE_CTS_MODE_ENABLE		1
+#define CE_OFB_MODE_ENABLE		1
+#define CE_CFB_MODE_ENABLE		1
+//#define CE_XTS_MODE_ENABLE		1
+
+#endif
+
+#if CE_DIGESTS_ALG
+#define CE_SHA224_ENABLE		1
+#define CE_SHA256_ENABLE		1
+#define CE_SHA384_ENABLE		1
+#define CE_SHA512_ENABLE		1
+#define CE_HMAC_SHA1_ENABLE		1
+#define CE_HMAC_SHA256_ENABLE	1
+
+#define MD5_DIGEST_LENGTH 16
+
+/*digest*/
+static int afalg_digests(ENGINE *e, const EVP_MD **digest, const int **nids, int nid);
+static int afalg_digest_init(EVP_MD_CTX *ctx);
+static int afalg_digest_update(EVP_MD_CTX *ctx, const void *data, size_t length);
+static int afalg_digest_cleanup(EVP_MD_CTX *ctx);
+static int afalg_digest_final(EVP_MD_CTX *ctx, unsigned char *md);
+
+#endif
+
+#if CE_ASYMMETRIC_ALG
+#define CE_RSA_ENABLE			1
+#define CE_DH_ENABLE			1
+#define CE_ECC_ENABLE			1
+#endif
+
 # ifndef AES_BLOCK_SIZE
 #  define AES_BLOCK_SIZE   16
 # endif
