test/crypto: add scatter-gather tests for IP and OOP
This patch adds test cases for wireless in-place and out-of-place auth-cipher operations with scatter-gather lists as input and output mbufs. Test cases include buffer appended digest generation with encryption and buffer decryption with appended digest verification. It also adds cases where digest is encrypted only partially. Signed-off-by: Damian Nowak <damianx.nowak@intel.com> Acked-by: Fiona Trahe <fiona.trahe@intel.com>
This commit is contained in:
parent
72cd8f68e1
commit
11c5485bb2
@ -2878,7 +2878,7 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
|
|||||||
unsigned int data_pad_len,
|
unsigned int data_pad_len,
|
||||||
unsigned int cipher_len, unsigned int cipher_offset,
|
unsigned int cipher_len, unsigned int cipher_offset,
|
||||||
unsigned int auth_len, unsigned int auth_offset,
|
unsigned int auth_len, unsigned int auth_offset,
|
||||||
uint8_t op_mode)
|
uint8_t op_mode, uint8_t do_sgl)
|
||||||
{
|
{
|
||||||
struct crypto_testsuite_params *ts_params = &testsuite_params;
|
struct crypto_testsuite_params *ts_params = &testsuite_params;
|
||||||
struct crypto_unittest_params *ut_params = &unittest_params;
|
struct crypto_unittest_params *ut_params = &unittest_params;
|
||||||
@ -2900,20 +2900,39 @@ create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
|
|||||||
sym_op->m_dst = ut_params->obuf;
|
sym_op->m_dst = ut_params->obuf;
|
||||||
|
|
||||||
/* digest */
|
/* digest */
|
||||||
sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
|
if (!do_sgl) {
|
||||||
(op_mode == IN_PLACE ?
|
sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
|
||||||
ut_params->ibuf : ut_params->obuf),
|
(op_mode == IN_PLACE ?
|
||||||
uint8_t *, data_pad_len);
|
ut_params->ibuf : ut_params->obuf),
|
||||||
|
uint8_t *, data_pad_len);
|
||||||
TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
|
sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
|
||||||
|
(op_mode == IN_PLACE ?
|
||||||
|
ut_params->ibuf : ut_params->obuf),
|
||||||
|
data_pad_len);
|
||||||
|
TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
|
||||||
"no room to append auth tag");
|
"no room to append auth tag");
|
||||||
|
memset(sym_op->auth.digest.data, 0, auth_tag_len);
|
||||||
sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
|
} else {
|
||||||
(op_mode == IN_PLACE ?
|
uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
|
||||||
ut_params->ibuf : ut_params->obuf),
|
struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
|
||||||
data_pad_len);
|
sym_op->m_src : sym_op->m_dst);
|
||||||
|
while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
|
||||||
memset(sym_op->auth.digest.data, 0, auth_tag_len);
|
remaining_off -= rte_pktmbuf_data_len(sgl_buf);
|
||||||
|
sgl_buf = sgl_buf->next;
|
||||||
|
}
|
||||||
|
sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
|
||||||
|
uint8_t *, remaining_off);
|
||||||
|
sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
|
||||||
|
remaining_off);
|
||||||
|
TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
|
||||||
|
"no room to append auth tag");
|
||||||
|
memset(sym_op->auth.digest.data, 0, remaining_off);
|
||||||
|
while (sgl_buf->next != NULL) {
|
||||||
|
memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
|
||||||
|
0, rte_pktmbuf_data_len(sgl_buf));
|
||||||
|
sgl_buf = sgl_buf->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy cipher and auth IVs at the end of the crypto operation */
|
/* Copy cipher and auth IVs at the end of the crypto operation */
|
||||||
uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
|
uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
|
||||||
@ -4473,7 +4492,7 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
|
|||||||
tdata->cipher.offset_bits,
|
tdata->cipher.offset_bits,
|
||||||
tdata->validAuthLenInBits.len,
|
tdata->validAuthLenInBits.len,
|
||||||
tdata->auth.offset_bits,
|
tdata->auth.offset_bits,
|
||||||
op_mode);
|
op_mode, 0);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return retval;
|
return retval;
|
||||||
@ -4544,6 +4563,190 @@ test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
|
||||||
|
uint8_t op_mode, uint8_t verify)
|
||||||
|
{
|
||||||
|
struct crypto_testsuite_params *ts_params = &testsuite_params;
|
||||||
|
struct crypto_unittest_params *ut_params = &unittest_params;
|
||||||
|
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
const uint8_t *plaintext = NULL;
|
||||||
|
const uint8_t *ciphertext = NULL;
|
||||||
|
const uint8_t *digest = NULL;
|
||||||
|
unsigned int plaintext_pad_len;
|
||||||
|
unsigned int plaintext_len;
|
||||||
|
unsigned int ciphertext_pad_len;
|
||||||
|
unsigned int ciphertext_len;
|
||||||
|
uint8_t buffer[10000];
|
||||||
|
uint8_t digest_buffer[10000];
|
||||||
|
|
||||||
|
struct rte_cryptodev_info dev_info;
|
||||||
|
|
||||||
|
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
|
||||||
|
|
||||||
|
uint64_t feat_flags = dev_info.feature_flags;
|
||||||
|
|
||||||
|
if (op_mode == IN_PLACE) {
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
|
||||||
|
printf("Device doesn't support in-place scatter-gather "
|
||||||
|
"in both input and output mbufs.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
|
||||||
|
printf("Device doesn't support out-of-place scatter-gather "
|
||||||
|
"in both input and output mbufs.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
|
||||||
|
printf("Device doesn't support digest encrypted.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create SNOW 3G session */
|
||||||
|
retval = create_wireless_algo_auth_cipher_session(
|
||||||
|
ts_params->valid_devs[0],
|
||||||
|
(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
|
||||||
|
: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
|
||||||
|
(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
|
||||||
|
: RTE_CRYPTO_AUTH_OP_GENERATE),
|
||||||
|
RTE_CRYPTO_AUTH_SNOW3G_UIA2,
|
||||||
|
RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
|
||||||
|
tdata->key.data, tdata->key.len,
|
||||||
|
tdata->auth_iv.len, tdata->digest.len,
|
||||||
|
tdata->cipher_iv.len);
|
||||||
|
|
||||||
|
if (retval < 0)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
|
||||||
|
plaintext_len = ceil_byte_length(tdata->plaintext.len);
|
||||||
|
ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
|
||||||
|
plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
|
||||||
|
|
||||||
|
ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
|
||||||
|
plaintext_pad_len, 15, 0);
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->ibuf,
|
||||||
|
"Failed to allocate input buffer in mempool");
|
||||||
|
|
||||||
|
if (op_mode == OUT_OF_PLACE) {
|
||||||
|
ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
|
||||||
|
plaintext_pad_len, 15, 0);
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->obuf,
|
||||||
|
"Failed to allocate output buffer in mempool");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verify) {
|
||||||
|
pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
|
||||||
|
tdata->ciphertext.data);
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
debug_hexdump(stdout, "ciphertext:", ciphertext,
|
||||||
|
ciphertext_len);
|
||||||
|
} else {
|
||||||
|
pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
|
||||||
|
tdata->plaintext.data);
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
debug_hexdump(stdout, "plaintext:", plaintext,
|
||||||
|
plaintext_len);
|
||||||
|
}
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
|
||||||
|
/* Create SNOW 3G operation */
|
||||||
|
retval = create_wireless_algo_auth_cipher_operation(
|
||||||
|
tdata->digest.len,
|
||||||
|
tdata->cipher_iv.data, tdata->cipher_iv.len,
|
||||||
|
tdata->auth_iv.data, tdata->auth_iv.len,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
(verify ? ciphertext_pad_len : plaintext_pad_len)
|
||||||
|
: tdata->digest.offset_bytes),
|
||||||
|
tdata->validCipherLenInBits.len,
|
||||||
|
tdata->cipher.offset_bits,
|
||||||
|
tdata->validAuthLenInBits.len,
|
||||||
|
tdata->auth.offset_bits,
|
||||||
|
op_mode, 1);
|
||||||
|
|
||||||
|
if (retval < 0)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
ut_params->op = process_crypto_request(ts_params->valid_devs[0],
|
||||||
|
ut_params->op);
|
||||||
|
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
|
||||||
|
|
||||||
|
ut_params->obuf = (op_mode == IN_PLACE ?
|
||||||
|
ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
|
||||||
|
|
||||||
|
if (verify) {
|
||||||
|
if (ut_params->obuf)
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
else
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "plaintext:", plaintext,
|
||||||
|
(tdata->plaintext.len >> 3) - tdata->digest.len);
|
||||||
|
debug_hexdump(stdout, "plaintext expected:",
|
||||||
|
tdata->plaintext.data,
|
||||||
|
(tdata->plaintext.len >> 3) - tdata->digest.len);
|
||||||
|
} else {
|
||||||
|
if (ut_params->obuf)
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
else
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "ciphertext:", ciphertext,
|
||||||
|
ciphertext_len);
|
||||||
|
debug_hexdump(stdout, "ciphertext expected:",
|
||||||
|
tdata->ciphertext.data, tdata->ciphertext.len >> 3);
|
||||||
|
|
||||||
|
if (ut_params->obuf)
|
||||||
|
digest = rte_pktmbuf_read(ut_params->obuf,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
plaintext_pad_len : tdata->digest.offset_bytes),
|
||||||
|
tdata->digest.len, digest_buffer);
|
||||||
|
else
|
||||||
|
digest = rte_pktmbuf_read(ut_params->ibuf,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
plaintext_pad_len : tdata->digest.offset_bytes),
|
||||||
|
tdata->digest.len, digest_buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "digest:", digest,
|
||||||
|
tdata->digest.len);
|
||||||
|
debug_hexdump(stdout, "digest expected:",
|
||||||
|
tdata->digest.data, tdata->digest.len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate obuf */
|
||||||
|
if (verify) {
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
|
||||||
|
plaintext,
|
||||||
|
tdata->plaintext.data,
|
||||||
|
tdata->plaintext.len >> 3,
|
||||||
|
"SNOW 3G Plaintext data not as expected");
|
||||||
|
} else {
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
|
||||||
|
ciphertext,
|
||||||
|
tdata->ciphertext.data,
|
||||||
|
tdata->validDataLenInBits.len,
|
||||||
|
"SNOW 3G Ciphertext data not as expected");
|
||||||
|
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL(
|
||||||
|
digest,
|
||||||
|
tdata->digest.data,
|
||||||
|
DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
|
||||||
|
"SNOW 3G Generated auth tag not as expected");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
|
test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
|
||||||
uint8_t op_mode, uint8_t verify)
|
uint8_t op_mode, uint8_t verify)
|
||||||
@ -4634,7 +4837,7 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
|
|||||||
tdata->validCipherOffsetInBits.len,
|
tdata->validCipherOffsetInBits.len,
|
||||||
tdata->validAuthLenInBits.len,
|
tdata->validAuthLenInBits.len,
|
||||||
0,
|
0,
|
||||||
op_mode);
|
op_mode, 0);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return retval;
|
return retval;
|
||||||
@ -4706,6 +4909,190 @@ test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
|
||||||
|
uint8_t op_mode, uint8_t verify)
|
||||||
|
{
|
||||||
|
struct crypto_testsuite_params *ts_params = &testsuite_params;
|
||||||
|
struct crypto_unittest_params *ut_params = &unittest_params;
|
||||||
|
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
const uint8_t *plaintext = NULL;
|
||||||
|
const uint8_t *ciphertext = NULL;
|
||||||
|
const uint8_t *digest = NULL;
|
||||||
|
unsigned int plaintext_pad_len;
|
||||||
|
unsigned int plaintext_len;
|
||||||
|
unsigned int ciphertext_pad_len;
|
||||||
|
unsigned int ciphertext_len;
|
||||||
|
uint8_t buffer[10000];
|
||||||
|
uint8_t digest_buffer[10000];
|
||||||
|
|
||||||
|
struct rte_cryptodev_info dev_info;
|
||||||
|
|
||||||
|
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
|
||||||
|
|
||||||
|
uint64_t feat_flags = dev_info.feature_flags;
|
||||||
|
|
||||||
|
if (op_mode == IN_PLACE) {
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
|
||||||
|
printf("Device doesn't support in-place scatter-gather "
|
||||||
|
"in both input and output mbufs.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
|
||||||
|
printf("Device doesn't support out-of-place scatter-gather "
|
||||||
|
"in both input and output mbufs.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
|
||||||
|
printf("Device doesn't support digest encrypted.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create KASUMI session */
|
||||||
|
retval = create_wireless_algo_auth_cipher_session(
|
||||||
|
ts_params->valid_devs[0],
|
||||||
|
(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
|
||||||
|
: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
|
||||||
|
(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
|
||||||
|
: RTE_CRYPTO_AUTH_OP_GENERATE),
|
||||||
|
RTE_CRYPTO_AUTH_KASUMI_F9,
|
||||||
|
RTE_CRYPTO_CIPHER_KASUMI_F8,
|
||||||
|
tdata->key.data, tdata->key.len,
|
||||||
|
0, tdata->digest.len,
|
||||||
|
tdata->cipher_iv.len);
|
||||||
|
|
||||||
|
if (retval < 0)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
|
||||||
|
plaintext_len = ceil_byte_length(tdata->plaintext.len);
|
||||||
|
ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
|
||||||
|
plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
|
||||||
|
|
||||||
|
ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
|
||||||
|
plaintext_pad_len, 15, 0);
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->ibuf,
|
||||||
|
"Failed to allocate input buffer in mempool");
|
||||||
|
|
||||||
|
if (op_mode == OUT_OF_PLACE) {
|
||||||
|
ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
|
||||||
|
plaintext_pad_len, 15, 0);
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->obuf,
|
||||||
|
"Failed to allocate output buffer in mempool");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verify) {
|
||||||
|
pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
|
||||||
|
tdata->ciphertext.data);
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
debug_hexdump(stdout, "ciphertext:", ciphertext,
|
||||||
|
ciphertext_len);
|
||||||
|
} else {
|
||||||
|
pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
|
||||||
|
tdata->plaintext.data);
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
debug_hexdump(stdout, "plaintext:", plaintext,
|
||||||
|
plaintext_len);
|
||||||
|
}
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
|
||||||
|
/* Create SNOW 3G operation */
|
||||||
|
retval = create_wireless_algo_auth_cipher_operation(
|
||||||
|
tdata->digest.len,
|
||||||
|
tdata->cipher_iv.data, tdata->cipher_iv.len,
|
||||||
|
NULL, 0,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
(verify ? ciphertext_pad_len : plaintext_pad_len)
|
||||||
|
: tdata->digest.offset_bytes),
|
||||||
|
tdata->validCipherLenInBits.len,
|
||||||
|
tdata->validCipherOffsetInBits.len,
|
||||||
|
tdata->validAuthLenInBits.len,
|
||||||
|
0,
|
||||||
|
op_mode, 1);
|
||||||
|
|
||||||
|
if (retval < 0)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
ut_params->op = process_crypto_request(ts_params->valid_devs[0],
|
||||||
|
ut_params->op);
|
||||||
|
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
|
||||||
|
|
||||||
|
ut_params->obuf = (op_mode == IN_PLACE ?
|
||||||
|
ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
|
||||||
|
|
||||||
|
if (verify) {
|
||||||
|
if (ut_params->obuf)
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
else
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "plaintext:", plaintext,
|
||||||
|
(tdata->plaintext.len >> 3) - tdata->digest.len);
|
||||||
|
debug_hexdump(stdout, "plaintext expected:",
|
||||||
|
tdata->plaintext.data,
|
||||||
|
(tdata->plaintext.len >> 3) - tdata->digest.len);
|
||||||
|
} else {
|
||||||
|
if (ut_params->obuf)
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
else
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "ciphertext:", ciphertext,
|
||||||
|
ciphertext_len);
|
||||||
|
debug_hexdump(stdout, "ciphertext expected:",
|
||||||
|
tdata->ciphertext.data, tdata->ciphertext.len >> 3);
|
||||||
|
|
||||||
|
if (ut_params->obuf)
|
||||||
|
digest = rte_pktmbuf_read(ut_params->obuf,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
plaintext_pad_len : tdata->digest.offset_bytes),
|
||||||
|
tdata->digest.len, digest_buffer);
|
||||||
|
else
|
||||||
|
digest = rte_pktmbuf_read(ut_params->ibuf,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
plaintext_pad_len : tdata->digest.offset_bytes),
|
||||||
|
tdata->digest.len, digest_buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "digest:", digest,
|
||||||
|
tdata->digest.len);
|
||||||
|
debug_hexdump(stdout, "digest expected:",
|
||||||
|
tdata->digest.data, tdata->digest.len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate obuf */
|
||||||
|
if (verify) {
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
|
||||||
|
plaintext,
|
||||||
|
tdata->plaintext.data,
|
||||||
|
tdata->plaintext.len >> 3,
|
||||||
|
"KASUMI Plaintext data not as expected");
|
||||||
|
} else {
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
|
||||||
|
ciphertext,
|
||||||
|
tdata->ciphertext.data,
|
||||||
|
tdata->validDataLenInBits.len,
|
||||||
|
"KASUMI Ciphertext data not as expected");
|
||||||
|
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL(
|
||||||
|
digest,
|
||||||
|
tdata->digest.data,
|
||||||
|
DIGEST_BYTE_LENGTH_KASUMI_F9,
|
||||||
|
"KASUMI Generated auth tag not as expected");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
|
test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
|
||||||
{
|
{
|
||||||
@ -5121,7 +5508,7 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
|
|||||||
tdata->validCipherOffsetInBits.len,
|
tdata->validCipherOffsetInBits.len,
|
||||||
tdata->validAuthLenInBits.len,
|
tdata->validAuthLenInBits.len,
|
||||||
0,
|
0,
|
||||||
op_mode);
|
op_mode, 0);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
return retval;
|
return retval;
|
||||||
@ -5193,6 +5580,190 @@ test_zuc_auth_cipher(const struct wireless_test_data *tdata,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
|
||||||
|
uint8_t op_mode, uint8_t verify)
|
||||||
|
{
|
||||||
|
struct crypto_testsuite_params *ts_params = &testsuite_params;
|
||||||
|
struct crypto_unittest_params *ut_params = &unittest_params;
|
||||||
|
|
||||||
|
int retval;
|
||||||
|
|
||||||
|
const uint8_t *plaintext = NULL;
|
||||||
|
const uint8_t *ciphertext = NULL;
|
||||||
|
const uint8_t *digest = NULL;
|
||||||
|
unsigned int plaintext_pad_len;
|
||||||
|
unsigned int plaintext_len;
|
||||||
|
unsigned int ciphertext_pad_len;
|
||||||
|
unsigned int ciphertext_len;
|
||||||
|
uint8_t buffer[10000];
|
||||||
|
uint8_t digest_buffer[10000];
|
||||||
|
|
||||||
|
struct rte_cryptodev_info dev_info;
|
||||||
|
|
||||||
|
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
|
||||||
|
|
||||||
|
uint64_t feat_flags = dev_info.feature_flags;
|
||||||
|
|
||||||
|
if (op_mode == IN_PLACE) {
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
|
||||||
|
printf("Device doesn't support in-place scatter-gather "
|
||||||
|
"in both input and output mbufs.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
|
||||||
|
printf("Device doesn't support out-of-place scatter-gather "
|
||||||
|
"in both input and output mbufs.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
|
||||||
|
printf("Device doesn't support digest encrypted.\n");
|
||||||
|
return -ENOTSUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create ZUC session */
|
||||||
|
retval = create_wireless_algo_auth_cipher_session(
|
||||||
|
ts_params->valid_devs[0],
|
||||||
|
(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
|
||||||
|
: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
|
||||||
|
(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
|
||||||
|
: RTE_CRYPTO_AUTH_OP_GENERATE),
|
||||||
|
RTE_CRYPTO_AUTH_ZUC_EIA3,
|
||||||
|
RTE_CRYPTO_CIPHER_ZUC_EEA3,
|
||||||
|
tdata->key.data, tdata->key.len,
|
||||||
|
tdata->auth_iv.len, tdata->digest.len,
|
||||||
|
tdata->cipher_iv.len);
|
||||||
|
|
||||||
|
if (retval < 0)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
|
||||||
|
plaintext_len = ceil_byte_length(tdata->plaintext.len);
|
||||||
|
ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
|
||||||
|
plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
|
||||||
|
|
||||||
|
ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
|
||||||
|
plaintext_pad_len, 15, 0);
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->ibuf,
|
||||||
|
"Failed to allocate input buffer in mempool");
|
||||||
|
|
||||||
|
if (op_mode == OUT_OF_PLACE) {
|
||||||
|
ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
|
||||||
|
plaintext_pad_len, 15, 0);
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->obuf,
|
||||||
|
"Failed to allocate output buffer in mempool");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verify) {
|
||||||
|
pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
|
||||||
|
tdata->ciphertext.data);
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
debug_hexdump(stdout, "ciphertext:", ciphertext,
|
||||||
|
ciphertext_len);
|
||||||
|
} else {
|
||||||
|
pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
|
||||||
|
tdata->plaintext.data);
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
debug_hexdump(stdout, "plaintext:", plaintext,
|
||||||
|
plaintext_len);
|
||||||
|
}
|
||||||
|
memset(buffer, 0, sizeof(buffer));
|
||||||
|
|
||||||
|
/* Create ZUC operation */
|
||||||
|
retval = create_wireless_algo_auth_cipher_operation(
|
||||||
|
tdata->digest.len,
|
||||||
|
tdata->cipher_iv.data, tdata->cipher_iv.len,
|
||||||
|
NULL, 0,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
(verify ? ciphertext_pad_len : plaintext_pad_len)
|
||||||
|
: tdata->digest.offset_bytes),
|
||||||
|
tdata->validCipherLenInBits.len,
|
||||||
|
tdata->validCipherOffsetInBits.len,
|
||||||
|
tdata->validAuthLenInBits.len,
|
||||||
|
0,
|
||||||
|
op_mode, 1);
|
||||||
|
|
||||||
|
if (retval < 0)
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
ut_params->op = process_crypto_request(ts_params->valid_devs[0],
|
||||||
|
ut_params->op);
|
||||||
|
|
||||||
|
TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
|
||||||
|
|
||||||
|
ut_params->obuf = (op_mode == IN_PLACE ?
|
||||||
|
ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
|
||||||
|
|
||||||
|
if (verify) {
|
||||||
|
if (ut_params->obuf)
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
else
|
||||||
|
plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
plaintext_len, buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "plaintext:", plaintext,
|
||||||
|
(tdata->plaintext.len >> 3) - tdata->digest.len);
|
||||||
|
debug_hexdump(stdout, "plaintext expected:",
|
||||||
|
tdata->plaintext.data,
|
||||||
|
(tdata->plaintext.len >> 3) - tdata->digest.len);
|
||||||
|
} else {
|
||||||
|
if (ut_params->obuf)
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
else
|
||||||
|
ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
|
||||||
|
ciphertext_len, buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "ciphertext:", ciphertext,
|
||||||
|
ciphertext_len);
|
||||||
|
debug_hexdump(stdout, "ciphertext expected:",
|
||||||
|
tdata->ciphertext.data, tdata->ciphertext.len >> 3);
|
||||||
|
|
||||||
|
if (ut_params->obuf)
|
||||||
|
digest = rte_pktmbuf_read(ut_params->obuf,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
plaintext_pad_len : tdata->digest.offset_bytes),
|
||||||
|
tdata->digest.len, digest_buffer);
|
||||||
|
else
|
||||||
|
digest = rte_pktmbuf_read(ut_params->ibuf,
|
||||||
|
(tdata->digest.offset_bytes == 0 ?
|
||||||
|
plaintext_pad_len : tdata->digest.offset_bytes),
|
||||||
|
tdata->digest.len, digest_buffer);
|
||||||
|
|
||||||
|
debug_hexdump(stdout, "digest:", digest,
|
||||||
|
tdata->digest.len);
|
||||||
|
debug_hexdump(stdout, "digest expected:",
|
||||||
|
tdata->digest.data, tdata->digest.len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate obuf */
|
||||||
|
if (verify) {
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
|
||||||
|
plaintext,
|
||||||
|
tdata->plaintext.data,
|
||||||
|
tdata->plaintext.len >> 3,
|
||||||
|
"ZUC Plaintext data not as expected");
|
||||||
|
} else {
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
|
||||||
|
ciphertext,
|
||||||
|
tdata->ciphertext.data,
|
||||||
|
tdata->validDataLenInBits.len,
|
||||||
|
"ZUC Ciphertext data not as expected");
|
||||||
|
|
||||||
|
TEST_ASSERT_BUFFERS_ARE_EQUAL(
|
||||||
|
digest,
|
||||||
|
tdata->digest.data,
|
||||||
|
DIGEST_BYTE_LENGTH_KASUMI_F9,
|
||||||
|
"ZUC Generated auth tag not as expected");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_kasumi_encryption_test_case_1(void)
|
test_kasumi_encryption_test_case_1(void)
|
||||||
{
|
{
|
||||||
@ -5458,6 +6029,36 @@ test_snow3g_auth_cipher_part_digest_enc_oop(void)
|
|||||||
OUT_OF_PLACE, 0);
|
OUT_OF_PLACE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_test_case_3_sgl(void)
|
||||||
|
{
|
||||||
|
return test_snow3g_auth_cipher_sgl(
|
||||||
|
&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
|
||||||
|
{
|
||||||
|
return test_snow3g_auth_cipher_sgl(
|
||||||
|
&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_part_digest_enc_sgl(void)
|
||||||
|
{
|
||||||
|
return test_snow3g_auth_cipher_sgl(
|
||||||
|
&snow3g_auth_cipher_partial_digest_encryption,
|
||||||
|
IN_PLACE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
|
||||||
|
{
|
||||||
|
return test_snow3g_auth_cipher_sgl(
|
||||||
|
&snow3g_auth_cipher_partial_digest_encryption,
|
||||||
|
OUT_OF_PLACE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_snow3g_auth_cipher_verify_test_case_1(void)
|
test_snow3g_auth_cipher_verify_test_case_1(void)
|
||||||
{
|
{
|
||||||
@ -5495,6 +6096,36 @@ test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
|
|||||||
OUT_OF_PLACE, 1);
|
OUT_OF_PLACE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
|
||||||
|
{
|
||||||
|
return test_snow3g_auth_cipher_sgl(
|
||||||
|
&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
|
||||||
|
{
|
||||||
|
return test_snow3g_auth_cipher_sgl(
|
||||||
|
&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
|
||||||
|
{
|
||||||
|
return test_snow3g_auth_cipher_sgl(
|
||||||
|
&snow3g_auth_cipher_partial_digest_encryption,
|
||||||
|
IN_PLACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
|
||||||
|
{
|
||||||
|
return test_snow3g_auth_cipher_sgl(
|
||||||
|
&snow3g_auth_cipher_partial_digest_encryption,
|
||||||
|
OUT_OF_PLACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_snow3g_auth_cipher_with_digest_test_case_1(void)
|
test_snow3g_auth_cipher_with_digest_test_case_1(void)
|
||||||
{
|
{
|
||||||
@ -5523,6 +6154,20 @@ test_kasumi_auth_cipher_test_case_2_oop(void)
|
|||||||
&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
|
&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_kasumi_auth_cipher_test_case_2_sgl(void)
|
||||||
|
{
|
||||||
|
return test_kasumi_auth_cipher_sgl(
|
||||||
|
&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
|
||||||
|
{
|
||||||
|
return test_kasumi_auth_cipher_sgl(
|
||||||
|
&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_kasumi_auth_cipher_verify_test_case_1(void)
|
test_kasumi_auth_cipher_verify_test_case_1(void)
|
||||||
{
|
{
|
||||||
@ -5544,6 +6189,20 @@ test_kasumi_auth_cipher_verify_test_case_2_oop(void)
|
|||||||
&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
|
&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
|
||||||
|
{
|
||||||
|
return test_kasumi_auth_cipher_sgl(
|
||||||
|
&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
|
||||||
|
{
|
||||||
|
return test_kasumi_auth_cipher_sgl(
|
||||||
|
&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_kasumi_cipher_auth_test_case_1(void)
|
test_kasumi_cipher_auth_test_case_1(void)
|
||||||
{
|
{
|
||||||
@ -5660,6 +6319,20 @@ test_zuc_auth_cipher_test_case_1_oop(void)
|
|||||||
&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
|
&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_zuc_auth_cipher_test_case_1_sgl(void)
|
||||||
|
{
|
||||||
|
return test_zuc_auth_cipher_sgl(
|
||||||
|
&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_zuc_auth_cipher_test_case_1_oop_sgl(void)
|
||||||
|
{
|
||||||
|
return test_zuc_auth_cipher_sgl(
|
||||||
|
&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_zuc_auth_cipher_verify_test_case_1(void)
|
test_zuc_auth_cipher_verify_test_case_1(void)
|
||||||
{
|
{
|
||||||
@ -5674,6 +6347,20 @@ test_zuc_auth_cipher_verify_test_case_1_oop(void)
|
|||||||
&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
|
&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_zuc_auth_cipher_verify_test_case_1_sgl(void)
|
||||||
|
{
|
||||||
|
return test_zuc_auth_cipher_sgl(
|
||||||
|
&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
|
||||||
|
{
|
||||||
|
return test_zuc_auth_cipher_sgl(
|
||||||
|
&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
test_3DES_chain_qat_all(void)
|
test_3DES_chain_qat_all(void)
|
||||||
{
|
{
|
||||||
@ -9716,6 +10403,14 @@ static struct unit_test_suite cryptodev_qat_testsuite = {
|
|||||||
test_snow3g_auth_cipher_part_digest_enc),
|
test_snow3g_auth_cipher_part_digest_enc),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_snow3g_auth_cipher_part_digest_enc_oop),
|
test_snow3g_auth_cipher_part_digest_enc_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_test_case_3_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_test_case_3_oop_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_part_digest_enc_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
|
||||||
|
|
||||||
/** SNOW 3G decrypt (UEA2), then verify auth */
|
/** SNOW 3G decrypt (UEA2), then verify auth */
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
@ -9728,6 +10423,14 @@ static struct unit_test_suite cryptodev_qat_testsuite = {
|
|||||||
test_snow3g_auth_cipher_verify_part_digest_enc),
|
test_snow3g_auth_cipher_verify_part_digest_enc),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_snow3g_auth_cipher_verify_part_digest_enc_oop),
|
test_snow3g_auth_cipher_verify_part_digest_enc_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_verify_test_case_3_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
|
||||||
|
|
||||||
/** SNOW 3G decrypt only (UEA2) */
|
/** SNOW 3G decrypt only (UEA2) */
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
@ -9790,12 +10493,20 @@ static struct unit_test_suite cryptodev_qat_testsuite = {
|
|||||||
test_zuc_auth_cipher_test_case_1),
|
test_zuc_auth_cipher_test_case_1),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_zuc_auth_cipher_test_case_1_oop),
|
test_zuc_auth_cipher_test_case_1_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_zuc_auth_cipher_test_case_1_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_zuc_auth_cipher_test_case_1_oop_sgl),
|
||||||
|
|
||||||
/** ZUC decrypt (EEA3), then verify auth */
|
/** ZUC decrypt (EEA3), then verify auth */
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_zuc_auth_cipher_verify_test_case_1),
|
test_zuc_auth_cipher_verify_test_case_1),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_zuc_auth_cipher_verify_test_case_1_oop),
|
test_zuc_auth_cipher_verify_test_case_1_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_zuc_auth_cipher_verify_test_case_1_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
|
||||||
|
|
||||||
/** HMAC_MD5 Authentication */
|
/** HMAC_MD5 Authentication */
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
@ -9850,6 +10561,10 @@ static struct unit_test_suite cryptodev_qat_testsuite = {
|
|||||||
test_kasumi_auth_cipher_test_case_2),
|
test_kasumi_auth_cipher_test_case_2),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_kasumi_auth_cipher_test_case_2_oop),
|
test_kasumi_auth_cipher_test_case_2_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_kasumi_auth_cipher_test_case_2_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_kasumi_auth_cipher_test_case_2_oop_sgl),
|
||||||
|
|
||||||
/** KASUMI decrypt (F8), then verify auth */
|
/** KASUMI decrypt (F8), then verify auth */
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
@ -9858,6 +10573,10 @@ static struct unit_test_suite cryptodev_qat_testsuite = {
|
|||||||
test_kasumi_auth_cipher_verify_test_case_2),
|
test_kasumi_auth_cipher_verify_test_case_2),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_kasumi_auth_cipher_verify_test_case_2_oop),
|
test_kasumi_auth_cipher_verify_test_case_2_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_kasumi_auth_cipher_verify_test_case_2_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
|
||||||
|
|
||||||
/** Negative tests */
|
/** Negative tests */
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
@ -10483,6 +11202,10 @@ static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
|
|||||||
test_kasumi_auth_cipher_test_case_2),
|
test_kasumi_auth_cipher_test_case_2),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_kasumi_auth_cipher_test_case_2_oop),
|
test_kasumi_auth_cipher_test_case_2_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_kasumi_auth_cipher_test_case_2_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_kasumi_auth_cipher_test_case_2_oop_sgl),
|
||||||
|
|
||||||
/** KASUMI decrypt (F8), then verify auth */
|
/** KASUMI decrypt (F8), then verify auth */
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
@ -10491,6 +11214,10 @@ static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
|
|||||||
test_kasumi_auth_cipher_verify_test_case_2),
|
test_kasumi_auth_cipher_verify_test_case_2),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_kasumi_auth_cipher_verify_test_case_2_oop),
|
test_kasumi_auth_cipher_verify_test_case_2_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_kasumi_auth_cipher_verify_test_case_2_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
|
||||||
TEST_CASES_END() /**< NULL terminate unit test array */
|
TEST_CASES_END() /**< NULL terminate unit test array */
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -10576,6 +11303,14 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
|
|||||||
test_snow3g_auth_cipher_part_digest_enc),
|
test_snow3g_auth_cipher_part_digest_enc),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_snow3g_auth_cipher_part_digest_enc_oop),
|
test_snow3g_auth_cipher_part_digest_enc_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_test_case_3_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_test_case_3_oop_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_part_digest_enc_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
|
||||||
|
|
||||||
/** SNOW 3G decrypt (UEA2), then verify auth */
|
/** SNOW 3G decrypt (UEA2), then verify auth */
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
@ -10588,6 +11323,14 @@ static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
|
|||||||
test_snow3g_auth_cipher_verify_part_digest_enc),
|
test_snow3g_auth_cipher_verify_part_digest_enc),
|
||||||
TEST_CASE_ST(ut_setup, ut_teardown,
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
test_snow3g_auth_cipher_verify_part_digest_enc_oop),
|
test_snow3g_auth_cipher_verify_part_digest_enc_oop),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_verify_test_case_3_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
|
||||||
|
TEST_CASE_ST(ut_setup, ut_teardown,
|
||||||
|
test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
|
||||||
|
|
||||||
TEST_CASES_END() /**< NULL terminate unit test array */
|
TEST_CASES_END() /**< NULL terminate unit test array */
|
||||||
}
|
}
|
||||||
|
@ -602,6 +602,73 @@ struct snow3g_test_data snow3g_auth_cipher_test_case_2 = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct snow3g_test_data snow3g_auth_cipher_test_case_3 = {
|
||||||
|
.key = {
|
||||||
|
.data = {
|
||||||
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||||
|
0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10
|
||||||
|
|
||||||
|
},
|
||||||
|
.len = 16
|
||||||
|
},
|
||||||
|
.cipher_iv = {
|
||||||
|
.data = {
|
||||||
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||||
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
|
||||||
|
},
|
||||||
|
.len = 16
|
||||||
|
},
|
||||||
|
.auth_iv = {
|
||||||
|
.data = {
|
||||||
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
|
},
|
||||||
|
.len = 16
|
||||||
|
},
|
||||||
|
.plaintext = {
|
||||||
|
.data = {
|
||||||
|
0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A,
|
||||||
|
0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A,
|
||||||
|
0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A,
|
||||||
|
0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A, 0x5A,
|
||||||
|
},
|
||||||
|
.len = 32 << 3
|
||||||
|
},
|
||||||
|
.ciphertext = {
|
||||||
|
.data = {
|
||||||
|
0x5A, 0x5A, 0xE4, 0xAD, 0x29, 0xA2, 0x6A, 0xA6,
|
||||||
|
0x20, 0x1D, 0xCD, 0x08, 0x50, 0xD6, 0xE6, 0x47,
|
||||||
|
0xBC, 0x88, 0x08, 0x01, 0x17, 0xFA, 0x47, 0x5B,
|
||||||
|
0x90, 0x40, 0xBA, 0x0C, 0xBA, 0x6D, 0x6A, 0x5E,
|
||||||
|
},
|
||||||
|
.len = 32 << 3
|
||||||
|
},
|
||||||
|
.cipher = {
|
||||||
|
.len_bits = 30 << 3,
|
||||||
|
.offset_bits = 2 << 3
|
||||||
|
},
|
||||||
|
.auth = {
|
||||||
|
.len_bits = 28 << 3,
|
||||||
|
.offset_bits = 0
|
||||||
|
},
|
||||||
|
.digest = {
|
||||||
|
.data = {
|
||||||
|
0xBA, 0x6D, 0x6A, 0x5E
|
||||||
|
},
|
||||||
|
.len = 4,
|
||||||
|
.offset_bytes = 28
|
||||||
|
},
|
||||||
|
.validDataLenInBits = {
|
||||||
|
.len = 32 << 3
|
||||||
|
},
|
||||||
|
.validCipherLenInBits = {
|
||||||
|
.len = 30 << 3
|
||||||
|
},
|
||||||
|
.validAuthLenInBits = {
|
||||||
|
.len = 28 << 3
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
struct snow3g_test_data snow3g_auth_cipher_partial_digest_encryption = {
|
struct snow3g_test_data snow3g_auth_cipher_partial_digest_encryption = {
|
||||||
.key = {
|
.key = {
|
||||||
.data = {
|
.data = {
|
||||||
|
Loading…
Reference in New Issue
Block a user