aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
else
aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
-
sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
ut_params->ibuf, aad_buffer_len);
TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
ut_params->ibuf);
sym_op->auth.aad.length = aad_len;
-
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
-
TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
return test_kasumi_authentication(&kasumi_hash_test_case_5);
}
+static int
+test_kasumi_hash_generate_test_case_6(void)
+{
+ return test_kasumi_authentication(&kasumi_hash_test_case_6);
+}
+
static int
test_kasumi_hash_verify_test_case_1(void)
{
return 0;
}
+static int
+test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
+{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
+ struct crypto_unittest_params *ut_params = &unittest_params;
+
+ int retval;
+
+ uint8_t *plaintext, *ciphertext;
+ unsigned plaintext_pad_len;
+ unsigned plaintext_len;
+
+ /* Create KASUMI session */
+ retval = create_snow3g_kasumi_auth_cipher_session(
+ ts_params->valid_devs[0],
+ RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+ RTE_CRYPTO_AUTH_OP_GENERATE,
+ RTE_CRYPTO_AUTH_KASUMI_F9,
+ RTE_CRYPTO_CIPHER_KASUMI_F8,
+ tdata->key.data, tdata->key.len,
+ tdata->aad.len, tdata->digest.len);
+ if (retval < 0)
+ return retval;
+ ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+ /* clear mbuf payload */
+ memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+ rte_pktmbuf_tailroom(ut_params->ibuf));
+
+ plaintext_len = ceil_byte_length(tdata->plaintext.len);
+ /* Append data which is padded to a multiple of */
+ /* the algorithms block size */
+ plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+ plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+ plaintext_pad_len);
+ memcpy(plaintext, tdata->plaintext.data, plaintext_len);
+
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
+
+ /* Create KASUMI operation */
+ retval = create_snow3g_kasumi_auth_cipher_operation(tdata->digest.len,
+ tdata->iv.data, tdata->iv.len,
+ tdata->aad.data, tdata->aad.len,
+ plaintext_pad_len,
+ tdata->validCipherLenInBits.len,
+ tdata->validCipherOffsetLenInBits.len,
+ tdata->validAuthLenInBits.len,
+ tdata->validAuthOffsetLenInBits.len,
+ RTE_CRYPTO_AUTH_KASUMI_F9,
+ RTE_CRYPTO_CIPHER_KASUMI_F8
+ );
+
+ 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 = ut_params->op->sym->m_src;
+ if (ut_params->obuf)
+ ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ + tdata->iv.len + tdata->aad.len;
+ else
+ ciphertext = plaintext;
+
+ /* Validate obuf */
+ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+ ciphertext,
+ tdata->ciphertext.data,
+ tdata->validCipherLenInBits.len,
+ "KASUMI Ciphertext data not as expected");
+ ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
+
+ /* Validate obuf */
+ TEST_ASSERT_BUFFERS_ARE_EQUAL(
+ ut_params->digest,
+ tdata->digest.data,
+ DIGEST_BYTE_LENGTH_KASUMI_F9,
+ "KASUMI Generated auth tag not as expected");
+ return 0;
+}
+
+static int
+test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
+{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
+ struct crypto_unittest_params *ut_params = &unittest_params;
+
+ int retval;
+
+ uint8_t *plaintext, *ciphertext;
+ unsigned plaintext_pad_len;
+ unsigned plaintext_len;
+
+ /* Create KASUMI session */
+ retval = create_snow3g_kasumi_cipher_auth_session(
+ ts_params->valid_devs[0],
+ RTE_CRYPTO_CIPHER_OP_ENCRYPT,
+ RTE_CRYPTO_AUTH_OP_GENERATE,
+ RTE_CRYPTO_AUTH_KASUMI_F9,
+ RTE_CRYPTO_CIPHER_KASUMI_F8,
+ tdata->key.data, tdata->key.len,
+ tdata->aad.len, tdata->digest.len);
+ if (retval < 0)
+ return retval;
+
+ ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
+
+ /* clear mbuf payload */
+ memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
+ rte_pktmbuf_tailroom(ut_params->ibuf));
+
+ plaintext_len = ceil_byte_length(tdata->plaintext.len);
+ /* Append data which is padded to a multiple of */
+ /* the algorithms block size */
+ plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+ plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
+ plaintext_pad_len);
+ memcpy(plaintext, tdata->plaintext.data, plaintext_len);
+
+ TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
+
+ /* Create KASUMI operation */
+ retval = create_snow3g_kasumi_cipher_hash_operation(tdata->digest.data,
+ tdata->digest.len, tdata->aad.data,
+ tdata->aad.len,
+ plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
+ RTE_CRYPTO_AUTH_KASUMI_F9,
+ RTE_CRYPTO_CIPHER_KASUMI_F8,
+ tdata->iv.data, tdata->iv.len,
+ tdata->validCipherLenInBits.len,
+ tdata->validCipherOffsetLenInBits.len,
+ tdata->validAuthLenInBits.len,
+ tdata->validAuthOffsetLenInBits.len
+ );
+ 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 = ut_params->op->sym->m_src;
+ if (ut_params->obuf)
+ ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ + tdata->aad.len + tdata->iv.len;
+ else
+ ciphertext = plaintext;
+
+ ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
+ + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
+
+ /* Validate obuf */
+ TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
+ ciphertext,
+ tdata->ciphertext.data,
+ tdata->validCipherLenInBits.len,
+ "KASUMI Ciphertext data not as expected");
+
+ /* Validate obuf */
+ TEST_ASSERT_BUFFERS_ARE_EQUAL(
+ ut_params->digest,
+ tdata->digest.data,
+ DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
+ "KASUMI Generated auth tag not as expected");
+ return 0;
+}
+
static int
test_kasumi_encryption_test_case_1(void)
{
return test_snow3g_auth_cipher(&snow3g_test_case_6);
}
+static int
+test_kasumi_auth_cipher_test_case_1(void)
+{
+ return test_kasumi_auth_cipher(&kasumi_test_case_3);
+}
+
+static int
+test_kasumi_cipher_auth_test_case_1(void)
+{
+ return test_kasumi_cipher_auth(&kasumi_test_case_6);
+}
+
+
/* ***** AES-GCM Tests ***** */
static int
TEST_CASE_ST(ut_setup, ut_teardown,
test_null_auth_cipher_operation),
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_kasumi_hash_generate_test_case_6),
+
+ /** KASUMI tests */
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_kasumi_encryption_test_case_1),
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_kasumi_encryption_test_case_3),
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_kasumi_auth_cipher_test_case_1),
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_kasumi_cipher_auth_test_case_1),
+
TEST_CASES_END() /**< NULL terminate unit test array */
}
};
test_kasumi_hash_generate_test_case_4),
TEST_CASE_ST(ut_setup, ut_teardown,
test_kasumi_hash_generate_test_case_5),
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_kasumi_hash_generate_test_case_6),
TEST_CASE_ST(ut_setup, ut_teardown,
test_kasumi_hash_verify_test_case_1),
TEST_CASE_ST(ut_setup, ut_teardown,
test_kasumi_hash_verify_test_case_4),
TEST_CASE_ST(ut_setup, ut_teardown,
test_kasumi_hash_verify_test_case_5),
-
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_kasumi_auth_cipher_test_case_1),
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_kasumi_cipher_auth_test_case_1),
TEST_CASES_END() /**< NULL terminate unit test array */
}
};
.len = 4
}
};
+
+struct kasumi_hash_test_data kasumi_hash_test_case_6 = {
+ .key = {
+ .data = {
+ 0x83, 0xFD, 0x23, 0xA2, 0x44, 0xA7, 0x4C, 0xF3,
+ 0x58, 0xDA, 0x30, 0x19, 0xF1, 0x72, 0x26, 0x35
+ },
+ .len = 16
+ },
+ .aad = {
+ .data = {
+ 0x36, 0xAF, 0x61, 0x44, 0x4F, 0x30, 0x2A, 0xD2
+ },
+ .len = 8
+ },
+ .plaintext = {
+ .data = {
+ 0x35, 0xC6, 0x87, 0x16, 0x63, 0x3C, 0x66, 0xFB,
+ 0x75, 0x0C, 0x26, 0x68, 0x65, 0xD5, 0x3C, 0x11,
+ 0xEA, 0x05, 0xB1, 0xE9, 0xFA, 0x49, 0xC8, 0x39,
+ 0x8D, 0x48, 0xE1, 0xEF, 0xA5, 0x90, 0x9D, 0x39,
+ 0x47, 0x90, 0x28, 0x37, 0xF5, 0xAE, 0x96, 0xD5,
+ 0xA0, 0x5B, 0xC8, 0xD6, 0x1C, 0xA8, 0xDB, 0xEF,
+ 0x1B, 0x13, 0xA4, 0xB4, 0xAB, 0xFE, 0x4F, 0xB1,
+ 0x00, 0x60, 0x45, 0xB6, 0x74, 0xBB, 0x54, 0x72,
+ 0x93, 0x04, 0xC3, 0x82, 0xBE, 0x53, 0xA5, 0xAF,
+ 0x05, 0x55, 0x61, 0x76, 0xF6, 0xEA, 0xA2, 0xEF,
+ 0x1D, 0x05, 0xE4, 0xB0, 0x83, 0x18, 0x1E, 0xE6,
+ 0x74, 0xCD, 0xA5, 0xA4, 0x85, 0xF7, 0x4D, 0x7A,
+ 0xC0
+ },
+ .len = 776
+ },
+ .validAuthLenInBits = {
+ .len = 768
+ },
+ .validAuthOffsetLenInBits = {
+ .len = 64
+ },
+ .digest = {
+ .data = {0x95, 0xAE, 0x41, 0xBA},
+ .len = 4
+ }
+};
+
+struct kasumi_hash_test_data kasumi_hash_test_case_7 = {
+ .key = {
+ .data = {
+ 0x5A, 0xCB, 0x1D, 0x64, 0x4C, 0x0D, 0x51, 0x20,
+ 0x4E, 0xA5, 0xF1, 0x45, 0x10, 0x10, 0xD8, 0x52
+ },
+ .len = 16
+ },
+ .aad = {
+ .data = {
+ 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49,
+ },
+ .len = 8
+ },
+ .plaintext = {
+ .data = {
+ 0xAD, 0x9C, 0x44, 0x1F, 0x89, 0x0B, 0x38, 0xC4,
+ 0x57, 0xA4, 0x9D, 0x42, 0x14, 0x07, 0xE8, 0xC0
+ },
+ .len = 128
+ },
+ .validAuthLenInBits = {
+ .len = 120
+ },
+ .validAuthOffsetLenInBits = {
+ .len = 64
+ },
+ .digest = {
+ .data = {0x87, 0x5F, 0xE4, 0x89},
+ .len = 4
+ }
+};
#endif /* TEST_CRYPTODEV_KASUMI_HASH_TEST_VECTORS_H_ */
unsigned len;
} iv;
+ /* Includes: COUNT (4 bytes) and FRESH (4 bytes) */
struct {
- uint8_t data[1024];
+ uint8_t data[8];
+ unsigned len;
+ } aad;
+
+ struct {
+ uint8_t data[1024]; /* Data may include direction bit */
unsigned len; /* length must be in Bits */
} plaintext;
+ struct {
+ unsigned len;
+ } validDataLenInBits;
+
struct {
uint8_t data[1024];
unsigned len; /* length must be in Bits */
struct {
unsigned len;
} validCipherOffsetLenInBits;
+
+ /* Actual length of data to be hashed */
+ struct {
+ unsigned len;
+ } validAuthLenInBits;
+
+ struct {
+ unsigned len;
+ } validAuthOffsetLenInBits;
+
+ struct {
+ uint8_t data[64];
+ unsigned len;
+ } digest;
+
};
struct kasumi_test_data kasumi_test_case_1 = {
},
.len = 8
},
+ .aad = {
+ .data = {
+ 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49
+ },
+ .len = 8
+ },
.plaintext = {
.data = {
0xAD, 0x9C, 0x44, 0x1F, 0x89, 0x0B, 0x38, 0xC4,
- 0x57, 0xA4, 0x9D, 0x42, 0x14, 0x07, 0xE8
+ 0x57, 0xA4, 0x9D, 0x42, 0x14, 0x07, 0xE8, 0xC0
},
- .len = 120
+ .len = 128
},
.ciphertext = {
.data = {
},
.len = 120
},
+ .validDataLenInBits = {
+ .len = 128
+ },
.validCipherLenInBits = {
.len = 120
},
.validCipherOffsetLenInBits = {
.len = 64
+ },
+ .validAuthLenInBits = {
+ .len = 120
+ },
+ .validAuthOffsetLenInBits = {
+ .len = 64
+ },
+ .digest = {
+ .data = {0x87, 0x5F, 0xE4, 0x89},
+ .len = 4
}
};
},
};
+struct kasumi_test_data kasumi_test_case_6 = {
+ .key = {
+ .data = {
+ 0x5A, 0xCB, 0x1D, 0x64, 0x4C, 0x0D, 0x51, 0x20,
+ 0x4E, 0xA5, 0xF1, 0x45, 0x10, 0x10, 0xD8, 0x52
+ },
+ .len = 16
+ },
+ .iv = {
+ .data = {
+ 0xFA, 0x55, 0x6B, 0x26, 0x1C, 0x00, 0x00, 0x00
+ },
+ .len = 8
+ },
+ .aad = {
+ .data = {
+ 0x38, 0xA6, 0xF0, 0x56, 0x05, 0xD2, 0xEC, 0x49
+ },
+ .len = 8
+ },
+ .plaintext = {
+ .data = {
+ 0xAD, 0x9C, 0x44, 0x1F, 0x89, 0x0B, 0x38, 0xC4,
+ 0x57, 0xA4, 0x9D, 0x42, 0x14, 0x07, 0xE8, 0xC0
+ },
+ .len = 128
+ },
+ .ciphertext = {
+ .data = {
+ 0x9B, 0xC9, 0x2C, 0xA8, 0x03, 0xC6, 0x7B, 0x28,
+ 0xA1, 0x1A, 0x4B, 0xEE, 0x5A, 0x0C, 0x25
+ },
+ .len = 120
+ },
+ .validDataLenInBits = {
+ .len = 128
+ },
+ .validCipherLenInBits = {
+ .len = 120
+ },
+ .validCipherOffsetLenInBits = {
+ .len = 64
+ },
+ .validAuthLenInBits = {
+ .len = 120
+ },
+ .validAuthOffsetLenInBits = {
+ .len = 64
+ },
+ .digest = {
+ .data = {0x0F, 0xD2, 0xAA, 0xB5},
+ .len = 4
+ }
+};
+
#endif /* TEST_CRYPTODEV_KASUMI_TEST_VECTORS_H_ */