static int
create_snow3g_cipher_operation(const uint8_t *iv, const unsigned iv_len,
- const unsigned data_len)
+ const unsigned cipher_len,
+ const unsigned cipher_offset)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
sym_op->cipher.iv.length = iv_pad_len;
rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
- sym_op->cipher.data.length = data_len;
- sym_op->cipher.data.offset = iv_pad_len;
+ sym_op->cipher.data.length = cipher_len;
+ sym_op->cipher.data.offset = cipher_offset;
return 0;
}
create_snow3g_hash_operation(const uint8_t *auth_tag,
const unsigned auth_tag_len,
const uint8_t *aad, const unsigned aad_len,
- const unsigned data_len, unsigned data_pad_len,
- enum rte_crypto_auth_operation op)
+ unsigned data_pad_len,
+ enum rte_crypto_auth_operation op,
+ const unsigned auth_len, const unsigned auth_offset)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
sym_op->auth.digest.length);
#endif
- sym_op->auth.data.length = data_len;
- sym_op->auth.data.offset = aad_buffer_len;
+ sym_op->auth.data.length = auth_len;
+ sym_op->auth.data.offset = auth_offset;
return 0;
}
create_snow3g_cipher_hash_operation(const uint8_t *auth_tag,
const unsigned auth_tag_len,
const uint8_t *aad, const unsigned aad_len,
- const unsigned data_len, unsigned data_pad_len,
+ unsigned data_pad_len,
enum rte_crypto_auth_operation op,
- const uint8_t *iv, const unsigned iv_len)
+ const uint8_t *iv, const unsigned iv_len,
+ const unsigned cipher_len, const unsigned cipher_offset,
+ const unsigned auth_len, const unsigned auth_offset)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
- sym_op->cipher.data.length = data_len;
- sym_op->cipher.data.offset = iv_pad_len;
+ sym_op->cipher.data.length = cipher_len;
+ sym_op->cipher.data.offset = cipher_offset;
/* aad */
/*
sym_op->auth.digest.length);
#endif
- sym_op->auth.data.length = data_len;
- sym_op->auth.data.offset = aad_buffer_len;
+ sym_op->auth.data.length = auth_len;
+ sym_op->auth.data.offset = auth_offset;
return 0;
}
create_snow3g_auth_cipher_operation(const unsigned auth_tag_len,
const uint8_t *iv, const unsigned iv_len,
const uint8_t *aad, const unsigned aad_len,
- const unsigned data_len, unsigned data_pad_len)
+ unsigned data_pad_len,
+ const unsigned cipher_len, const unsigned cipher_offset,
+ const unsigned auth_len, const unsigned auth_offset)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
sym_op->auth.aad.data, aad_len);
#endif
- sym_op->cipher.data.length = data_len;
- sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
+ sym_op->cipher.data.length = cipher_len;
+ sym_op->cipher.data.offset = auth_offset + cipher_offset;
- sym_op->auth.data.length = data_len;
- sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
+ sym_op->auth.data.length = auth_len;
+ sym_op->auth.data.offset = auth_offset + cipher_offset;
return 0;
}
/* Append data which is padded to a multiple of */
/* the algorithms block size */
- plaintext_pad_len = tdata->plaintext.len;
+ plaintext_pad_len = tdata->plaintext.len >> 3;
plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
plaintext_pad_len);
- memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
+ memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
/* Create SNOW3G opertaion */
retval = create_snow3g_hash_operation(NULL, tdata->digest.len,
- tdata->aad.data, tdata->aad.len, tdata->plaintext.len,
- plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE);
+ tdata->aad.data, tdata->aad.len,
+ plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+ tdata->validAuthLenInBits.len,
+ tdata->validAuthOffsetLenInBits.len);
if (retval < 0)
return retval;
/* Append data which is padded to a multiple */
/* of the algorithms block size */
- plaintext_pad_len = tdata->plaintext.len;
+ plaintext_pad_len = tdata->plaintext.len >> 3;
plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
plaintext_pad_len);
- memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
+ memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
/* Create SNOW3G operation */
retval = create_snow3g_hash_operation(tdata->digest.data,
tdata->digest.len,
tdata->aad.data, tdata->aad.len,
- tdata->plaintext.len, plaintext_pad_len,
- RTE_CRYPTO_AUTH_OP_VERIFY);
+ plaintext_pad_len,
+ RTE_CRYPTO_AUTH_OP_VERIFY,
+ tdata->validAuthLenInBits.len,
+ tdata->validAuthOffsetLenInBits.len);
if (retval < 0)
return retval;
* Append data which is padded to a
* multiple of the algorithms block size
*/
- plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
+ /*tdata->plaintext.len = tdata->plaintext.len >> 3;*/
+ plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 16);
plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
plaintext_pad_len);
- memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
+ memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
#ifdef RTE_APP_TEST_DEBUG
rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
#endif
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
- tdata->plaintext.len);
+ tdata->validCipherLenInBits.len,
+ tdata->validCipherOffsetLenInBits.len);
if (retval < 0)
return retval;
if (lastByteValidBits == 0)
lastByteValidBits = 8;
lastByteMask = lastByteMask << (8 - lastByteValidBits);
- (*(ciphertext + tdata->ciphertext.len - 1)) &= lastByteMask;
+ (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
#ifdef RTE_APP_TEST_DEBUG
rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
tdata->ciphertext.data,
- tdata->ciphertext.len,
+ tdata->ciphertext.len >> 3,
"Snow3G Ciphertext data not as expected");
return 0;
}
* Append data which is padded to a
* multiple of the algorithms block size
*/
- ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
+ ciphertext_pad_len = RTE_ALIGN_CEIL((tdata->ciphertext.len >> 3), 16);
ciphertext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
ciphertext_pad_len);
- memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
+ memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len >> 3);
#ifdef RTE_APP_TEST_DEBUG
rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
#endif
/* Create SNOW3G operation */
retval = create_snow3g_cipher_operation(tdata->iv.data, tdata->iv.len,
- tdata->ciphertext.len);
+ tdata->validCipherLenInBits.len,
+ tdata->validCipherOffsetLenInBits.len);
if (retval < 0)
return retval;
+ tdata->iv.len;
else
plaintext = ciphertext;
- lastByteValidBits = (tdata->validDataLenInBits.len % 8);
+ lastByteValidBits = (tdata->validDataLenInBits.len % 8);
if (lastByteValidBits == 0)
lastByteValidBits = 8;
lastByteMask = lastByteMask << (8 - lastByteValidBits);
- (*(ciphertext + tdata->ciphertext.len - 1)) &= lastByteMask;
+ (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
#ifdef RTE_APP_TEST_DEBUG
rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
/* Validate obuf */
TEST_ASSERT_BUFFERS_ARE_EQUAL(plaintext,
tdata->plaintext.data,
- tdata->plaintext.len,
+ tdata->plaintext.len >> 3,
"Snow3G Plaintext data not as expected");
return 0;
}
/* Append data which is padded to a multiple */
/* of the algorithms block size */
- plaintext_pad_len = tdata->plaintext.len;
+ plaintext_pad_len = tdata->plaintext.len >> 3;
plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
plaintext_pad_len);
- memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
+ memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
#ifdef RTE_APP_TEST_DEBUG
rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
/* Create SNOW3G operation */
retval = create_snow3g_cipher_hash_operation(tdata->digest.data,
tdata->digest.len, tdata->aad.data,
- tdata->aad.len, tdata->plaintext.len,
+ tdata->aad.len, /*tdata->plaintext.len,*/
plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
- tdata->iv.data, tdata->iv.len);
+ tdata->iv.data, tdata->iv.len,
+ tdata->validCipherLenInBits.len,
+ tdata->validCipherOffsetLenInBits.len,
+ tdata->validAuthLenInBits.len,
+ tdata->validAuthOffsetLenInBits.len);
if (retval < 0)
return retval;
if (lastByteValidBits == 0)
lastByteValidBits = 8;
lastByteMask = lastByteMask << (8-lastByteValidBits);
- (*(ciphertext + tdata->ciphertext.len - 1)) &= lastByteMask;
+ (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
#ifdef RTE_APP_TEST_DEBUG
rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
tdata->ciphertext.data,
- tdata->ciphertext.len,
+ tdata->ciphertext.len >> 3,
"Snow3G Ciphertext data not as expected");
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
/* Append data which is padded to a multiple */
/* of the algorithms block size */
- plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 8);
+ plaintext_pad_len = RTE_ALIGN_CEIL((tdata->plaintext.len >> 3), 8);
plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
plaintext_pad_len);
- memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
+ memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len >> 3);
#ifdef RTE_APP_TEST_DEBUG
rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
tdata->digest.len,
tdata->iv.data, tdata->iv.len,
tdata->aad.data, tdata->aad.len,
- tdata->plaintext.len, plaintext_pad_len
+ plaintext_pad_len,
+ tdata->validCipherLenInBits.len,
+ tdata->validCipherOffsetLenInBits.len,
+ tdata->validAuthLenInBits.len,
+ tdata->validAuthOffsetLenInBits.len
);
if (retval < 0)
if (lastByteValidBits == 0)
lastByteValidBits = 8;
lastByteMask = lastByteMask << (8-lastByteValidBits);
- (*(ciphertext + tdata->ciphertext.len - 1)) &= lastByteMask;
+ (*(ciphertext + (tdata->ciphertext.len >> 3) - 1)) &= lastByteMask;
ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
-
#ifdef RTE_APP_TEST_DEBUG
rte_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
#endif
TEST_ASSERT_BUFFERS_ARE_EQUAL(
ciphertext,
tdata->ciphertext.data,
- tdata->ciphertext.len,
+ tdata->ciphertext.len >> 3,
"Snow3G Ciphertext data not as expected");
/* Validate obuf */
struct {
uint8_t data[1024];
- unsigned len;
+ unsigned len; /* length must be in Bits */
} plaintext;
struct {
uint8_t data[1024];
- unsigned len;
+ unsigned len; /* length must be in Bits */
} ciphertext;
struct {
unsigned len;
} validDataLenInBits;
+ struct {
+ unsigned len;
+ } validCipherLenInBits;
+
+ struct {
+ unsigned len;
+ } validCipherOffsetLenInBits;
+
+ struct {
+ unsigned len;
+ } validAuthLenInBits;
+
+ struct {
+ unsigned len;
+ } validAuthOffsetLenInBits;
+
struct {
uint8_t data[64];
unsigned len;
0x39, 0x01, 0xA0, 0x8F, 0x4A, 0xB4, 0x1A, 0xAB,
0x9B, 0x13, 0x48, 0x80
},
- .len = 100
+ .len = 800
},
.ciphertext = {
.data = {
0x05, 0x3D, 0xB5, 0x5A, 0x88, 0xC4, 0xC4, 0xF9,
0x60, 0x5E, 0x41, 0x40
},
- .len = 100
+ .len = 800
},
.validDataLenInBits = {
.len = 798
},
+ .validCipherLenInBits = {
+ .len = 800
+ },
+ .validCipherOffsetLenInBits = {
+ .len = 128
+ },
.aad = {
.data = {
0x72, 0xA4, 0xF2, 0x0F, 0x64, 0x00, 0x00, 0x00,
0x1C, 0xF9, 0x3B, 0x15, 0x10, 0x37, 0x6B, 0x02,
0x13, 0x0F, 0x81, 0x2A, 0x9F, 0xA1, 0x69, 0xD8
},
- .len = 64
+ .len = 512
},
.ciphertext = {
.data = {
0x0D, 0xB0, 0xA9, 0xCD, 0x36, 0xC3, 0x4A, 0xE4,
0x18, 0x14, 0x90, 0xB2, 0x9F, 0x5F, 0xA2, 0xFC
},
- .len = 64
+ .len = 512
},
.validDataLenInBits = {
.len = 510
},
+ .validCipherLenInBits = {
+ .len = 512
+ },
+ .validCipherOffsetLenInBits = {
+ .len = 128
+ },
.aad = {
.data = {
0xE2, 0x8B, 0xCF, 0x7B, 0xC0, 0x00, 0x00, 0x00,
0xAD, 0x9C, 0x44, 0x1F, 0x89, 0x0B, 0x38, 0xC4,
0x57, 0xA4, 0x9D, 0x42, 0x14, 0x07, 0xE8
},
- .len = 15
+ .len = 120
},
.ciphertext = {
.data = {
0xBA, 0x0F, 0x31, 0x30, 0x03, 0x34, 0xC5, 0x6B,
0x52, 0xA7, 0x49, 0x7C, 0xBA, 0xC0, 0x46
},
- .len = 15
+ .len = 120
},
.validDataLenInBits = {
.len = 120
},
+ .validCipherLenInBits = {
+ .len = 120
+ },
+ .validCipherOffsetLenInBits = {
+ .len = 128
+ },
.aad = {
.data = {
0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00,
.digest = {
.data = {0xE8, 0x60, 0x5A, 0x3E},
.len = 4
+ },
+ .validAuthLenInBits = {
+ .len = 120
+ },
+ .validAuthOffsetLenInBits = {
+ .len = 128
}
};
0x8C, 0xE3, 0x3E, 0x2C, 0xC3, 0xC0, 0xB5, 0xFC,
0x1F, 0x3D, 0xE8, 0xA6, 0xDC, 0x66, 0xB1, 0xF0
},
- .len = 32
+ .len = 256
},
.ciphertext = {
.data = {
0xA5, 0x6C, 0x40, 0xC0, 0xAB, 0x9D, 0x81, 0xF7,
0xA2, 0xA9, 0xBA, 0xC6, 0x0E, 0x11, 0xC4, 0xB0
},
- .len = 32
+ .len = 256
},
.validDataLenInBits = {
.len = 253
+ },
+ .validCipherLenInBits = {
+ .len = 256
+ },
+ .validCipherOffsetLenInBits = {
+ .len = 128
}
};
0x98, 0x76, 0x45, 0x98, 0x7A, 0x98, 0x6F, 0x2C,
0xB0
},
- .len = 105
+ .len = 840
},
.ciphertext = {
.data = {
0x43, 0x24, 0x85, 0x50, 0x92, 0x2A, 0xC1, 0x28,
0x18
},
- .len = 105
+ .len = 840
},
.validDataLenInBits = {
.len = 837
+ },
+ .validCipherLenInBits = {
+ .len = 840
+ },
+ .validCipherOffsetLenInBits = {
+ .len = 128
}
};
struct snow3g_test_data snow3g_test_case_6 = {
0xB2, 0x4A, 0x03, 0x86, 0x65, 0x42, 0x2B, 0x20,
0xA4, 0x99, 0x27, 0x6A, 0x50, 0x42, 0x70, 0x09
},
- .len = 48
+ .len = 384
},
.ciphertext = {
.data = {
0xBD, 0x91, 0xAA, 0xB6, 0xA4, 0xDC, 0x64, 0xB4,
0xCB, 0xEB, 0x97, 0x06, 0x4C, 0xF7, 0x02, 0x3D
},
- .len = 48
+ .len = 384
},
.digest = {
.data = {0x38, 0xB5, 0x54, 0xC0 },
},
.validDataLenInBits = {
.len = 384
+ },
+ .validCipherLenInBits = {
+ .len = 384
+ },
+ .validCipherOffsetLenInBits = {
+ .len = 128
+ },
+ .validAuthLenInBits = {
+ .len = 384
+ },
+ .validAuthOffsetLenInBits = {
+ .len = 128
}
};