|
8 | 8 | * |
9 | 9 | */ |
10 | 10 |
|
| 11 | +#include "lib/security/ciphering_engine_generic.h" |
11 | 12 | #include "lib/security/ciphering_engine_nea2.h" |
12 | 13 | #include "nea2_test_set.h" |
13 | 14 | #include "srsran/security/ciphering_engine.h" |
@@ -106,6 +107,27 @@ TEST_P(ciphering_engine_test, ciphering_engine_nea2) |
106 | 107 | EXPECT_EQ(result.buf.value(), ciphertext); |
107 | 108 | } |
108 | 109 |
|
| 110 | +TEST_P(ciphering_engine_test, ciphering_engine_generic_nea2) |
| 111 | +{ |
| 112 | + nea_test_set param = GetParam(); |
| 113 | + |
| 114 | + // Pack hex strings into srsran types |
| 115 | + sec_128_key key = make_sec_128_key(param.key_cstr); |
| 116 | + auto dir = static_cast<security_direction>(param.direction); |
| 117 | + byte_buffer plaintext = make_byte_buffer(param.plaintext_cstr).value(); |
| 118 | + byte_buffer ciphertext = make_byte_buffer(param.ciphertext_cstr).value(); |
| 119 | + |
| 120 | + // Create ciphering engine |
| 121 | + std::unique_ptr<ciphering_engine> nea = |
| 122 | + std::make_unique<ciphering_engine_generic>(key, param.bearer, dir, ciphering_algorithm::nea2); |
| 123 | + |
| 124 | + // Apply ciphering and compare results |
| 125 | + security_result result = nea->apply_ciphering(plaintext.deep_copy().value(), 0, param.count); |
| 126 | + ASSERT_TRUE(result.buf.has_value()); |
| 127 | + ASSERT_TRUE(trim_tail_to_bitlength(result.buf.value(), param.length)); |
| 128 | + EXPECT_EQ(result.buf.value(), ciphertext); |
| 129 | +} |
| 130 | + |
109 | 131 | ////////////////////////////////////////////////////////// |
110 | 132 | // Finally, instantiate all testcases for each test set // |
111 | 133 | ////////////////////////////////////////////////////////// |
|
0 commit comments