[EXT] [PATCH 2/2] test/crypto: add negative test cases for cipher buffer alignment

Sivaramakrishnan, VenkatX venkatx.sivaramakrishnan at intel.com
Fri Nov 17 10:38:51 CET 2023


Hi Akhil,


> -----Original Message-----
> From: Akhil Goyal <gakhil at marvell.com>
> Sent: Monday, November 13, 2023 12:31 PM
> To: Sivaramakrishnan, VenkatX <venkatx.sivaramakrishnan at intel.com>; Fan
> Zhang <fanzhang.oss at gmail.com>
> Cc: dev at dpdk.org; stable at dpdk.org
> Subject: RE: [EXT] [PATCH 2/2] test/crypto: add negative test cases for cipher
> buffer alignment
> 
> > add negative test cases for 3DES CBC and AES CBC cipher algorithms for
> > buffer misalignment
> >
> > Signed-off-by: Sivaramakrishnan Venkat
> > <venkatx.sivaramakrishnan at intel.com>
> > ---
> >  app/test/test_cryptodev.c                  | 321 ++++++++++++++++++++-
> >  app/test/test_cryptodev_aes_test_vectors.h | 119 ++++++++
> >  app/test/test_cryptodev_blockcipher.c      |  20 +-
> >  app/test/test_cryptodev_blockcipher.h      |   1 +
> >  app/test/test_cryptodev_des_test_vectors.h |  38 +++
> >  5 files changed, 491 insertions(+), 8 deletions(-)
> >
> > diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
> > index d2c4c6f8b5..12e0cf8044 100644
> > --- a/app/test/test_cryptodev.c
> > +++ b/app/test/test_cryptodev.c
> > @@ -1371,6 +1371,42 @@ negative_hmac_sha1_testsuite_setup(void)
> >  	return 0;
> >  }
> >
> > +static int
> > +negative_input_buffer_misalignment_testsuite_setup(void)
> > +{
> > +	struct crypto_testsuite_params *ts_params = &testsuite_params;
> > +	uint8_t dev_id = ts_params->valid_devs[0];
> > +	struct rte_cryptodev_info dev_info;
> > +	const enum rte_crypto_cipher_algorithm ciphers[] = {
> > +		RTE_CRYPTO_CIPHER_3DES_CBC,
> > +		RTE_CRYPTO_CIPHER_AES_CBC
> > +	};
> > +	const enum rte_crypto_auth_algorithm auths[] = {
> > +		RTE_CRYPTO_AUTH_SHA256,
> > +		RTE_CRYPTO_AUTH_SHA256,
> > +	};
> > +
> > +	rte_cryptodev_info_get(dev_id, &dev_info);
> > +
> > +	if (!(dev_info.feature_flags &
> > RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
> > +			((global_api_test_type ==
> CRYPTODEV_RAW_API_TEST)
> > &&
> > +			!(dev_info.feature_flags &
> > RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
> > +		RTE_LOG(INFO, USER1, "Feature flag requirements for
> Negative
> > "
> > +				"Input Buffer misalignment testsuite not
> > met\n");
> > +		return TEST_SKIPPED;
> > +	}
> > +
> > +	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers))
> != 0
> > +			&& check_auth_capabilities_supported(auths,
> > +			RTE_DIM(auths)) != 0) {
> > +		RTE_LOG(INFO, USER1, "Capability requirements for Negative
> "
> > +				"Input Buffer misalignment testsuite not
> > met\n");
> > +		return TEST_SKIPPED;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  static int
> >  dev_configure_and_start(uint64_t ff_disable)  { @@ -14469,6
> > +14505,192 @@ aes128cbc_hmac_sha1_test_vector = {
> >  	}
> >  };
> >
> > +static const struct test_crypto_vector
> > +aes128cbc_sha256_misalign_test_vector = {
> > +	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
> > +	.cipher_offset = 0,
> > +	.cipher_len = 511,
> > +	.cipher_key = {
> > +		.data = {
> > +			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
> > +			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
> > +		},
> > +		.len = 16
> > +	},
> > +	.iv = {
> > +		.data = {
> > +			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
> > +			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
> > +		},
> > +		.len = 16
> > +	},
> > +	.plaintext = {
> > +		.data = plaintext_aes_common,
> > +		.len = 511
> > +	},
> > +	.ciphertext = {
> > +		.data = ciphertext512_aes128cbc,
> > +		.len = 511
> > +	},
> > +	.auth_algo = RTE_CRYPTO_AUTH_SHA256,
> > +	.auth_offset = 0,
> > +	.auth_key = {
> > +		.data = {
> > +			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
> > +			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
> > +			0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
> > +			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60
> > +		},
> > +		.len = 32
> > +	},
> > +	.digest = {
> > +		.data = {
> > +			0xA8, 0xBC, 0xDB, 0x99, 0xAA, 0x45, 0x91, 0xA3,
> > +			0x2D, 0x75, 0x41, 0x92, 0x28, 0x01, 0x87, 0x5D,
> > +			0x45, 0xED, 0x49, 0x05, 0xD3, 0xAE, 0x32, 0x57,
> > +			0xB7, 0x79, 0x65, 0xFC, 0xFA, 0x6C, 0xFA, 0xDF
> > +		},
> > +		.len = 32
> > +	}
> > +};
> 
> Why are the vectors added in .c file?
> 
We will move the tests to blockcipher test vectors and put in test vector header files with others.
> 

<snip>
> > +
> >  static const struct test_crypto_vector
> > aes128cbc_hmac_sha1_aad_test_vector = {
> >  	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC, @@ -15058,7
> +15280,7 @@
> > test_authenticated_decryption_fail_when_corruption(
> >  }
> >
> >  static int
> > -test_authenticated_encrypt_with_esn(
> > +test_authenticated_encrypt(
> 
> Any specific reason of changing the name of this function in this patch.
>  


Renamed so that we could reuse with these tests and not just the ESN tests.
For the next version, as tests are moved to blockcipher test functions, this change is no longer needed.

> 
> >  		struct crypto_testsuite_params *ts_params,
> >  		struct crypto_unittest_params *ut_params,
> >  		const struct test_crypto_vector *reference) @@ -15159,7
> +15381,7 @@

<snip>

more work is needed on the tests so will drop this patch for 23.11.
Will send a new version of QAT patch Today.

Thanks,
Venkat.


More information about the stable mailing list