1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(C) 2023 Marvell. 3 */ 4 5 #ifndef _TEST_SECURITY_PROTO_H_ 6 #define _TEST_SECURITY_PROTO_H_ 7 8 #include <rte_cryptodev.h> 9 #include <rte_security.h> 10 11 #define TEST_SEC_PKTS_MAX 32 12 13 struct crypto_param { 14 enum rte_crypto_sym_xform_type type; 15 union { 16 enum rte_crypto_cipher_algorithm cipher; 17 enum rte_crypto_auth_algorithm auth; 18 enum rte_crypto_aead_algorithm aead; 19 } alg; 20 uint16_t key_length; 21 uint16_t iv_length; 22 uint16_t digest_length; 23 }; 24 25 static const struct crypto_param aead_list[] = { 26 { 27 .type = RTE_CRYPTO_SYM_XFORM_AEAD, 28 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM, 29 .key_length = 16, 30 }, 31 { 32 .type = RTE_CRYPTO_SYM_XFORM_AEAD, 33 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM, 34 .key_length = 24, 35 }, 36 { 37 .type = RTE_CRYPTO_SYM_XFORM_AEAD, 38 .alg.aead = RTE_CRYPTO_AEAD_AES_GCM, 39 .key_length = 32, 40 }, 41 { 42 .type = RTE_CRYPTO_SYM_XFORM_AEAD, 43 .alg.aead = RTE_CRYPTO_AEAD_AES_CCM, 44 .key_length = 32 45 }, 46 }; 47 48 static const struct crypto_param cipher_list[] = { 49 { 50 .type = RTE_CRYPTO_SYM_XFORM_CIPHER, 51 .alg.cipher = RTE_CRYPTO_CIPHER_NULL, 52 .key_length = 0, 53 .iv_length = 0, 54 }, 55 { 56 .type = RTE_CRYPTO_SYM_XFORM_CIPHER, 57 .alg.cipher = RTE_CRYPTO_CIPHER_DES_CBC, 58 .key_length = 8, 59 .iv_length = 8, 60 }, 61 { 62 .type = RTE_CRYPTO_SYM_XFORM_CIPHER, 63 .alg.cipher = RTE_CRYPTO_CIPHER_3DES_CBC, 64 .key_length = 24, 65 .iv_length = 8, 66 }, 67 { 68 .type = RTE_CRYPTO_SYM_XFORM_CIPHER, 69 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CBC, 70 .key_length = 16, 71 .iv_length = 16, 72 }, 73 { 74 .type = RTE_CRYPTO_SYM_XFORM_CIPHER, 75 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CBC, 76 .key_length = 32, 77 .iv_length = 16, 78 }, 79 { 80 .type = RTE_CRYPTO_SYM_XFORM_CIPHER, 81 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CTR, 82 .key_length = 16, 83 .iv_length = 16, 84 }, 85 { 86 .type = RTE_CRYPTO_SYM_XFORM_CIPHER, 87 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CTR, 88 .key_length = 24, 89 .iv_length = 16, 90 }, 91 { 92 .type = RTE_CRYPTO_SYM_XFORM_CIPHER, 93 .alg.cipher = RTE_CRYPTO_CIPHER_AES_CTR, 94 .key_length = 32, 95 .iv_length = 16, 96 }, 97 }; 98 99 static const struct crypto_param auth_list[] = { 100 { 101 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 102 .alg.auth = RTE_CRYPTO_AUTH_NULL, 103 }, 104 { 105 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 106 .alg.auth = RTE_CRYPTO_AUTH_MD5_HMAC, 107 .key_length = 16, 108 .digest_length = 12, 109 }, 110 { 111 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 112 .alg.auth = RTE_CRYPTO_AUTH_SHA1_HMAC, 113 .key_length = 20, 114 .digest_length = 12, 115 }, 116 { 117 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 118 .alg.auth = RTE_CRYPTO_AUTH_SHA1_HMAC, 119 .key_length = 20, 120 .digest_length = 20, 121 }, 122 { 123 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 124 .alg.auth = RTE_CRYPTO_AUTH_SHA256_HMAC, 125 .key_length = 32, 126 .digest_length = 16, 127 }, 128 { 129 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 130 .alg.auth = RTE_CRYPTO_AUTH_SHA256_HMAC, 131 .key_length = 32, 132 .digest_length = 32, 133 }, 134 { 135 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 136 .alg.auth = RTE_CRYPTO_AUTH_SHA384_HMAC, 137 .key_length = 48, 138 .digest_length = 24, 139 }, 140 { 141 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 142 .alg.auth = RTE_CRYPTO_AUTH_SHA512_HMAC, 143 .key_length = 64, 144 .digest_length = 32, 145 }, 146 { 147 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 148 .alg.auth = RTE_CRYPTO_AUTH_AES_XCBC_MAC, 149 .key_length = 16, 150 .digest_length = 12, 151 }, 152 { 153 .type = RTE_CRYPTO_SYM_XFORM_AUTH, 154 .alg.auth = RTE_CRYPTO_AUTH_AES_GMAC, 155 .key_length = 16, 156 .digest_length = 16, 157 .iv_length = 12, 158 }, 159 }; 160 161 struct crypto_param_comb { 162 const struct crypto_param *param1; 163 const struct crypto_param *param2; 164 }; 165 166 extern struct crypto_param_comb sec_alg_list[RTE_DIM(aead_list) + 167 (RTE_DIM(cipher_list) * RTE_DIM(auth_list))]; 168 169 extern struct crypto_param_comb sec_auth_only_alg_list[2 * (RTE_DIM(auth_list) - 1)]; 170 171 void test_sec_alg_list_populate(void); 172 173 void test_sec_auth_only_alg_list_populate(void); 174 175 int test_sec_crypto_caps_aead_verify(const struct rte_security_capability *sec_cap, 176 struct rte_crypto_sym_xform *aead); 177 178 int test_sec_crypto_caps_cipher_verify(const struct rte_security_capability *sec_cap, 179 struct rte_crypto_sym_xform *cipher); 180 181 int test_sec_crypto_caps_auth_verify(const struct rte_security_capability *sec_cap, 182 struct rte_crypto_sym_xform *auth); 183 184 void test_sec_alg_display(const struct crypto_param *param1, const struct crypto_param *param2); 185 186 #endif 187