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[] */ 52a9de470cSBruce Richardson BLKCIPHER_DES_DOCSIS_TYPE /* use des_docsis_test_cases[] */ 53a9de470cSBruce Richardson }; 54a9de470cSBruce Richardson 55a9de470cSBruce Richardson struct blockcipher_test_case { 56a9de470cSBruce Richardson const char *test_descr; /* test description */ 57a9de470cSBruce Richardson const struct blockcipher_test_data *test_data; 58a9de470cSBruce Richardson uint8_t op_mask; /* operation mask */ 59a9de470cSBruce Richardson uint8_t feature_mask; 60a9de470cSBruce Richardson }; 61a9de470cSBruce Richardson 62a9de470cSBruce Richardson struct blockcipher_test_data { 63a9de470cSBruce Richardson enum rte_crypto_cipher_algorithm crypto_algo; 64a9de470cSBruce Richardson 65a9de470cSBruce Richardson struct { 66a9de470cSBruce Richardson uint8_t data[64]; 67a9de470cSBruce Richardson unsigned int len; 68a9de470cSBruce Richardson } cipher_key; 69a9de470cSBruce Richardson 70a9de470cSBruce Richardson struct { 71a9de470cSBruce Richardson uint8_t data[64] __rte_aligned(16); 72a9de470cSBruce Richardson unsigned int len; 73a9de470cSBruce Richardson } iv; 74a9de470cSBruce Richardson 75a9de470cSBruce Richardson struct { 76a9de470cSBruce Richardson const uint8_t *data; 77a9de470cSBruce Richardson unsigned int len; 78a9de470cSBruce Richardson } plaintext; 79a9de470cSBruce Richardson 80a9de470cSBruce Richardson struct { 81a9de470cSBruce Richardson const uint8_t *data; 82a9de470cSBruce Richardson unsigned int len; 83a9de470cSBruce Richardson } ciphertext; 84a9de470cSBruce Richardson 85a9de470cSBruce Richardson enum rte_crypto_auth_algorithm auth_algo; 86a9de470cSBruce Richardson 87a9de470cSBruce Richardson struct { 88a9de470cSBruce Richardson uint8_t data[128]; 89a9de470cSBruce Richardson unsigned int len; 90a9de470cSBruce Richardson } auth_key; 91a9de470cSBruce Richardson 92a9de470cSBruce Richardson struct { 93a9de470cSBruce Richardson uint8_t data[128]; 94a9de470cSBruce Richardson unsigned int len; /* for qat */ 95a9de470cSBruce Richardson unsigned int truncated_len; /* for mb */ 96a9de470cSBruce Richardson } digest; 975e73a1f8SFan Zhang 985e73a1f8SFan Zhang unsigned int cipher_offset; 995e73a1f8SFan Zhang unsigned int auth_offset; 100*cab0c8f3SMatan Azrad uint32_t xts_dataunit_len; 101d5728a5aSShiri Kuzin bool wrapped_key; 102a9de470cSBruce Richardson }; 103a9de470cSBruce Richardson 104e65da89cSCiara Power struct unit_test_suite * 105e65da89cSCiara Power build_blockcipher_test_suite(enum blockcipher_test_type test_type); 106e65da89cSCiara Power 107e65da89cSCiara Power void 108e65da89cSCiara Power free_blockcipher_test_suite(struct unit_test_suite *ts); 109a9de470cSBruce Richardson 110a9de470cSBruce Richardson #endif /* TEST_CRYPTODEV_BLOCKCIPHER_H_ */ 111