phys_addr_t phys_addr;
};
+char supported_auth_algo[RTE_CRYPTO_AUTH_LIST_END][MAX_STR_LEN];
+char supported_cipher_algo[RTE_CRYPTO_CIPHER_LIST_END][MAX_STR_LEN];
+
/** l2fwd crypto application command line options */
struct l2fwd_crypto_options {
unsigned portmask;
int digest_size;
uint16_t block_size;
- char string_auth_algo[MAX_STR_LEN];
- char string_cipher_algo[MAX_STR_LEN];
char string_type[MAX_STR_LEN];
};
printf("\n====================================================\n");
}
+static void
+fill_supported_algorithm_tables(void)
+{
+ unsigned i;
+
+ for (i = 0; i < RTE_CRYPTO_AUTH_LIST_END; i++)
+ strcpy(supported_auth_algo[i], "NOT_SUPPORTED");
+
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_AES_GCM], "AES_GCM");
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_MD5_HMAC], "MD5_HMAC");
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_NULL], "NULL");
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA1_HMAC], "SHA1_HMAC");
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA224_HMAC], "SHA224_HMAC");
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA256_HMAC], "SHA256_HMAC");
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA384_HMAC], "SHA384_HMAC");
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SHA512_HMAC], "SHA512_HMAC");
+ strcpy(supported_auth_algo[RTE_CRYPTO_AUTH_SNOW3G_UIA2], "SNOW3G_UIA2");
+
+ for (i = 0; i < RTE_CRYPTO_CIPHER_LIST_END; i++)
+ strcpy(supported_cipher_algo[i], "NOT_SUPPORTED");
+
+ strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_AES_CBC], "AES_CBC");
+ strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_AES_GCM], "AES_GCM");
+ strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_NULL], "NULL");
+ strcpy(supported_cipher_algo[RTE_CRYPTO_CIPHER_SNOW3G_UEA2], "SNOW3G_UEA2");
+}
static int
static int
parse_cipher_algo(enum rte_crypto_cipher_algorithm *algo, char *optarg)
{
- if (strcmp("AES_CBC", optarg) == 0) {
- *algo = RTE_CRYPTO_CIPHER_AES_CBC;
- return 0;
- } else if (strcmp("AES_GCM", optarg) == 0) {
- *algo = RTE_CRYPTO_CIPHER_AES_GCM;
- return 0;
- } else if (strcmp("NULL", optarg) == 0) {
- *algo = RTE_CRYPTO_CIPHER_NULL;
- return 0;
- } else if (strcmp("SNOW3G_UEA2", optarg) == 0) {
- *algo = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
- return 0;
+ unsigned i;
+
+ for (i = 0; i < RTE_CRYPTO_CIPHER_LIST_END; i++) {
+ if (!strcmp(supported_cipher_algo[i], optarg)) {
+ *algo = i;
+ return 0;
+ }
}
printf("Cipher algorithm not supported!\n");
static int
parse_auth_algo(enum rte_crypto_auth_algorithm *algo, char *optarg)
{
- if (strcmp("AES_GCM", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_AES_GCM;
- return 0;
- } else if (strcmp("MD5_HMAC", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_MD5_HMAC;
- return 0;
- } else if (strcmp("NULL", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_NULL;
- return 0;
- } else if (strcmp("SHA1_HMAC", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
- return 0;
- } else if (strcmp("SHA224_HMAC", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_SHA224_HMAC;
- return 0;
- } else if (strcmp("SHA256_HMAC", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
- return 0;
- } else if (strcmp("SHA384_HMAC", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_SHA384_HMAC;
- return 0;
- } else if (strcmp("SHA512_HMAC", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
- return 0;
- } else if (strcmp("SNOW3G_UIA2", optarg) == 0) {
- *algo = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
- return 0;
+ unsigned i;
+
+ for (i = 0; i < RTE_CRYPTO_AUTH_LIST_END; i++) {
+ if (!strcmp(supported_auth_algo[i], optarg)) {
+ *algo = i;
+ return 0;
+ }
}
printf("Authentication algorithm specified not supported!\n");
return parse_crypto_opt_chain(options, optarg);
/* Cipher options */
- else if (strcmp(lgopts[option_index].name, "cipher_algo") == 0) {
- retval = parse_cipher_algo(&options->cipher_xform.cipher.algo,
+ else if (strcmp(lgopts[option_index].name, "cipher_algo") == 0)
+ return parse_cipher_algo(&options->cipher_xform.cipher.algo,
optarg);
- if (retval == 0)
- strcpy(options->string_cipher_algo, optarg);
- return retval;
- }
else if (strcmp(lgopts[option_index].name, "cipher_op") == 0)
return parse_cipher_op(&options->cipher_xform.cipher.op,
/* Authentication options */
else if (strcmp(lgopts[option_index].name, "auth_algo") == 0) {
- retval = parse_auth_algo(&options->auth_xform.auth.algo,
+ return parse_auth_algo(&options->auth_xform.auth.algo,
optarg);
- if (retval == 0)
- strcpy(options->string_auth_algo, optarg);
- return retval;
}
else if (strcmp(lgopts[option_index].name, "auth_op") == 0)
if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) {
printf("Algorithm %s not supported by cryptodev %u"
" or device not of preferred type (%s)\n",
- options->string_cipher_algo, cdev_id,
+ supported_cipher_algo[opt_cipher_algo],
+ cdev_id,
options->string_type);
continue;
}
if (cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED) {
printf("Algorithm %s not supported by cryptodev %u"
" or device not of preferred type (%s)\n",
- options->string_auth_algo, cdev_id,
+ supported_auth_algo[opt_auth_algo],
+ cdev_id,
options->string_type);
continue;
}
/* reserve memory for Cipher/Auth key and IV */
reserve_key_memory(&options);
+ /* fill out the supported algorithm tables */
+ fill_supported_algorithm_tables();
+
/* parse application arguments (after the EAL ones) */
ret = l2fwd_crypto_parse_args(&options, argc, argv);
if (ret < 0)