Skip to content

Commit

Permalink
ta: crypto_perf: add asymmetric crypto perf tests
Browse files Browse the repository at this point in the history
Add perf test for DH, RSA, ECDH, ECDSA algorithm

Signed-off-by: Zexi Yu <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
  • Loading branch information
yuzexiyzx committed Feb 4, 2024
1 parent e18381f commit b31cbb5
Show file tree
Hide file tree
Showing 4 changed files with 604 additions and 0 deletions.
74 changes: 74 additions & 0 deletions ta/crypto_perf/include/ta_crypto_perf.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
#define TA_CRYPTO_PERF_CMD_CIPHER_PROCESS_SDP 2
#define TA_CRYPTO_PERF_CMD_HASH_PREPARE_OP 3
#define TA_CRYPTO_PERF_CMD_HASH_PROCESS 4
#define TA_CRYPTO_PERF_CMD_ASYM_PREPARE_OBJ 5
#define TA_CRYPTO_PERF_CMD_ASYM_PREPARE_HASH 6
#define TA_CRYPTO_PERF_CMD_ASYM_PREPARE_KEYPAIR 7
#define TA_CRYPTO_PERF_CMD_ASYM_PREPARE_ENC_SIGN 8
#define TA_CRYPTO_PERF_CMD_ASYM_PREPARE_ATTRS 9
#define TA_CRYPTO_PERF_CMD_ASYM_PROCESS_GEN_KEYPAIR 10
#define TA_CRYPTO_PERF_CMD_ASYM_PROCESS 11
#define TA_CRYPTO_PERF_CMD_ASYM_FREE_ATTRS 12

/*
* Supported AES modes of operation
Expand Down Expand Up @@ -53,4 +61,70 @@
#define TA_HMAC_SHA512 10
#define TA_HMAC_SM3 11

/*
* Asymmetric cryptographic algorithms
*/
#define PKCS_V1_5_MIN 11
#define BITS_TO_BYTES(len) (((len) + 7) / 8)
#define OAEP_HASH_LEN(hsz) ((hsz) * 2)
#define OAEP_OTHER_LEN 2
#define PSS_OTHER_LEN 2

#define DERCODE_SHA1_LEN 15
#define DERCODE_SHA_LEN 19
#define SHA1_LEN 20
#define SHA224_LEN 28
#define SHA256_LEN 32
#define SHA384_LEN 48
#define SHA512_LEN 64

#define WIDTH_BITS_25519 256

#define ECC_CURVE_192 192
#define ECC_CURVE_224 224
#define ECC_CURVE_256 256
#define ECC_CURVE_384 384
#define ECC_CURVE_521 521

#define TEE_MAX_OUT_SIZE 4096

#define DH_MAX_SIZE 4096
#define DH_G_SIZE 1

enum asym_algorithm {
ALGO_DH = 1,
ALGO_RSA = 2,
ALGO_ECDSA = 3,
ALGO_ECDH = 4,
ALGO_X25519 = 5,
};

enum asym_cipher_mode {
MODE_ENCRYPT = 0,
MODE_DECRYPT = 1,
MODE_SIGN = 2,
MODE_VERIFY = 3,
MODE_GENKEYPAIR = 4,
};

enum rsa_mode {
RSA_NOPAD = 0,
RSAES_PKCS1_V1_5 = 1,
RSAES_PKCS1_OAEP_SHA1 = 2,
RSAES_PKCS1_OAEP_SHA224 = 3,
RSAES_PKCS1_OAEP_SHA256 = 4,
RSAES_PKCS1_OAEP_SHA384 = 5,
RSAES_PKCS1_OAEP_SHA512 = 6,
RSASSA_PKCS1_V1_5_SHA1 = 7,
RSASSA_PKCS1_V1_5_SHA224 = 8,
RSASSA_PKCS1_V1_5_SHA256 = 9,
RSASSA_PKCS1_V1_5_SHA384 = 10,
RSASSA_PKCS1_V1_5_SHA512 = 11,
RSASSA_PKCS1_PSS_MGF1_SHA1 = 12,
RSASSA_PKCS1_PSS_MGF1_SHA224 = 13,
RSASSA_PKCS1_PSS_MGF1_SHA256 = 14,
RSASSA_PKCS1_PSS_MGF1_SHA384 = 15,
RSASSA_PKCS1_PSS_MGF1_SHA512 = 16,
};

#endif /* TA_CRYPTO_PERF_H */
9 changes: 9 additions & 0 deletions ta/crypto_perf/include/ta_crypto_perf_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ TEE_Result cmd_cipher_process(uint32_t param_types, TEE_Param params[4],
bool sdp);
TEE_Result cmd_hash_prepare_op(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_hash_process(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_asym_process_keypair(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_asym_process_rsa_ecc(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_asym_prepare_obj(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_asym_prepare_keypair(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_asym_prepare_hash(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_asym_prepare_enc_sign(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_asym_prepare_attrs(uint32_t param_types, TEE_Param params[4]);
TEE_Result cmd_asym_free_attrs(uint32_t param_types, TEE_Param params[4]);
void cmd_clean_obj(void);
void cmd_clean_res(void);

#endif /* TA_CRYPTO_PERF_PRIV_H */
Loading

0 comments on commit b31cbb5

Please sign in to comment.