1a9de470cSBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause 2a9de470cSBruce Richardson * Copyright(c) 2016-2017 Intel Corporation 3a9de470cSBruce Richardson */ 4a9de470cSBruce Richardson 5a9de470cSBruce Richardson #ifndef TEST_CRYPTODEV_BLOCKCIPHER_H_ 6a9de470cSBruce Richardson #define TEST_CRYPTODEV_BLOCKCIPHER_H_ 7a9de470cSBruce Richardson 8a9de470cSBruce Richardson #ifndef BLOCKCIPHER_TEST_MSG_LEN 9a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_MSG_LEN 256 10a9de470cSBruce Richardson #endif 11a9de470cSBruce Richardson 12a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_OP_ENCRYPT 0x01 13a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_OP_DECRYPT 0x02 14a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_OP_AUTH_GEN 0x04 15a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_OP_AUTH_VERIFY 0x08 166356c286STejasree Kondoj #define BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED 0x10 17a9de470cSBruce Richardson 18a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_FEATURE_OOP 0x01 19a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_FEATURE_SESSIONLESS 0x02 20a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_FEATURE_STOPPER 0x04 /* stop upon failing */ 21a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_FEATURE_SG 0x08 /* Scatter Gather */ 226356c286STejasree Kondoj #define BLOCKCIPHER_TEST_FEATURE_DIGEST_ENCRYPTED 0x10 23a9de470cSBruce Richardson 24a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_OP_CIPHER (BLOCKCIPHER_TEST_OP_ENCRYPT | \ 25a9de470cSBruce Richardson BLOCKCIPHER_TEST_OP_DECRYPT) 26a9de470cSBruce Richardson 27a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_OP_AUTH (BLOCKCIPHER_TEST_OP_AUTH_GEN | \ 28a9de470cSBruce Richardson BLOCKCIPHER_TEST_OP_AUTH_VERIFY) 29a9de470cSBruce Richardson 30a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN (BLOCKCIPHER_TEST_OP_ENCRYPT | \ 31a9de470cSBruce Richardson BLOCKCIPHER_TEST_OP_AUTH_GEN) 32a9de470cSBruce Richardson 33a9de470cSBruce Richardson #define BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC (BLOCKCIPHER_TEST_OP_DECRYPT | \ 34a9de470cSBruce Richardson BLOCKCIPHER_TEST_OP_AUTH_VERIFY) 35a9de470cSBruce Richardson 366356c286STejasree Kondoj #define BLOCKCIPHER_TEST_OP_AUTH_GEN_ENC (BLOCKCIPHER_TEST_OP_ENCRYPT | \ 376356c286STejasree Kondoj BLOCKCIPHER_TEST_OP_AUTH_GEN | \ 386356c286STejasree Kondoj BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED) 396356c286STejasree Kondoj 406356c286STejasree Kondoj #define BLOCKCIPHER_TEST_OP_DEC_AUTH_VERIFY (BLOCKCIPHER_TEST_OP_DECRYPT | \ 416356c286STejasree Kondoj BLOCKCIPHER_TEST_OP_AUTH_VERIFY | \ 426356c286STejasree Kondoj BLOCKCIPHER_TEST_OP_DIGEST_ENCRYPTED) 436356c286STejasree Kondoj 44a9de470cSBruce Richardson enum blockcipher_test_type { 45a9de470cSBruce Richardson BLKCIPHER_AES_CHAIN_TYPE, /* use aes_chain_test_cases[] */ 46a9de470cSBruce Richardson BLKCIPHER_AES_CIPHERONLY_TYPE, /* use aes_cipheronly_test_cases[] */ 47a9de470cSBruce Richardson BLKCIPHER_AES_DOCSIS_TYPE, /* use aes_docsis_test_cases[] */ 48a9de470cSBruce Richardson BLKCIPHER_3DES_CHAIN_TYPE, /* use triple_des_chain_test_cases[] */ 49a9de470cSBruce Richardson BLKCIPHER_3DES_CIPHERONLY_TYPE, /* triple_des_cipheronly_test_cases[] */ 50a9de470cSBruce Richardson BLKCIPHER_AUTHONLY_TYPE, /* use hash_test_cases[] */ 51a9de470cSBruce Richardson BLKCIPHER_DES_CIPHERONLY_TYPE, /* use des_cipheronly_test_cases[] */ 521daecf63SSunyang Wu BLKCIPHER_DES_DOCSIS_TYPE, /* use des_docsis_test_cases[] */ 531daecf63SSunyang Wu BLKCIPHER_SM4_CHAIN_TYPE, /* use sm4_chain_test_cases[] */ 541daecf63SSunyang Wu BLKCIPHER_SM4_CIPHERONLY_TYPE /* use sm4_cipheronly_test_cases[] */ 55a9de470cSBruce Richardson }; 56a9de470cSBruce Richardson 57a9de470cSBruce Richardson struct blockcipher_test_case { 58a9de470cSBruce Richardson const char *test_descr; /* test description */ 59a9de470cSBruce Richardson const struct blockcipher_test_data *test_data; 60a9de470cSBruce Richardson uint8_t op_mask; /* operation mask */ 61a9de470cSBruce Richardson uint8_t feature_mask; 6263e1fbc3SCiara Power uint64_t sgl_flag; 6363e1fbc3SCiara Power uint8_t sgl_segs; 64a9de470cSBruce Richardson }; 65a9de470cSBruce Richardson 66a9de470cSBruce Richardson struct blockcipher_test_data { 67a9de470cSBruce Richardson enum rte_crypto_cipher_algorithm crypto_algo; 68a9de470cSBruce Richardson 69a9de470cSBruce Richardson struct { 70a9de470cSBruce Richardson uint8_t data[64]; 71a9de470cSBruce Richardson unsigned int len; 72a9de470cSBruce Richardson } cipher_key; 73a9de470cSBruce Richardson 74a9de470cSBruce Richardson struct { 75*0efea35aSTyler Retzlaff alignas(16) uint8_t data[64]; 76a9de470cSBruce Richardson unsigned int len; 77a9de470cSBruce Richardson } iv; 78a9de470cSBruce Richardson 79a9de470cSBruce Richardson struct { 80a9de470cSBruce Richardson const uint8_t *data; 81a9de470cSBruce Richardson unsigned int len; 82a9de470cSBruce Richardson } plaintext; 83a9de470cSBruce Richardson 84a9de470cSBruce Richardson struct { 85a9de470cSBruce Richardson const uint8_t *data; 86a9de470cSBruce Richardson unsigned int len; 87a9de470cSBruce Richardson } ciphertext; 88a9de470cSBruce Richardson 89a9de470cSBruce Richardson enum rte_crypto_auth_algorithm auth_algo; 90a9de470cSBruce Richardson 91a9de470cSBruce Richardson struct { 92a9de470cSBruce Richardson uint8_t data[128]; 93a9de470cSBruce Richardson unsigned int len; 94a9de470cSBruce Richardson } auth_key; 95a9de470cSBruce Richardson 96a9de470cSBruce Richardson struct { 97a9de470cSBruce Richardson uint8_t data[128]; 98a9de470cSBruce Richardson unsigned int len; /* for qat */ 99a9de470cSBruce Richardson unsigned int truncated_len; /* for mb */ 100a9de470cSBruce Richardson } digest; 1015e73a1f8SFan Zhang 1025e73a1f8SFan Zhang unsigned int cipher_offset; 1035e73a1f8SFan Zhang unsigned int auth_offset; 104cab0c8f3SMatan Azrad uint32_t xts_dataunit_len; 105d5728a5aSShiri Kuzin bool wrapped_key; 106a9de470cSBruce Richardson }; 107a9de470cSBruce Richardson 108e65da89cSCiara Power struct unit_test_suite * 109e65da89cSCiara Power build_blockcipher_test_suite(enum blockcipher_test_type test_type); 110e65da89cSCiara Power 111e65da89cSCiara Power void 112e65da89cSCiara Power free_blockcipher_test_suite(struct unit_test_suite *ts); 113a9de470cSBruce Richardson 114a9de470cSBruce Richardson #endif /* TEST_CRYPTODEV_BLOCKCIPHER_H_ */ 115