|
|
|
@ -5,7 +5,9 @@
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
|
|
|
|
|
#include "srslte/srslte.h"
|
|
|
|
|
#include "srslte/common/liblte_security.h"
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@ -442,9 +444,15 @@ void test_set_6()
|
|
|
|
|
uint8_t * out = (uint8_t *) calloc(len_bytes,
|
|
|
|
|
sizeof(uint8_t));
|
|
|
|
|
|
|
|
|
|
struct timeval t[3];
|
|
|
|
|
|
|
|
|
|
// encryption
|
|
|
|
|
gettimeofday(&t[1], NULL);
|
|
|
|
|
err_lte = liblte_security_encryption_eea1(key, count, bearer,
|
|
|
|
|
direction, msg, len_bits, out);
|
|
|
|
|
gettimeofday(&t[2], NULL);
|
|
|
|
|
get_time_interval(t);
|
|
|
|
|
printf("encryption: %d bits, t=%d us, rate=%.1f Mbps/s\n", len_bits, t[0].tv_usec, (float) len_bits/t[0].tv_usec);
|
|
|
|
|
assert(err_lte == LIBLTE_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// compare cipher text
|
|
|
|
@ -452,8 +460,12 @@ void test_set_6()
|
|
|
|
|
assert(err_cmp == 0);
|
|
|
|
|
|
|
|
|
|
// decryption
|
|
|
|
|
gettimeofday(&t[1], NULL);
|
|
|
|
|
err_lte = liblte_security_decryption_eea1(key, count, bearer,
|
|
|
|
|
direction, ct, len_bits, out);
|
|
|
|
|
gettimeofday(&t[2], NULL);
|
|
|
|
|
get_time_interval(t);
|
|
|
|
|
printf("decryption: %d bits, t=%d us, rate=%.1f Mbps/s\n", len_bits, t[0].tv_usec, (float) len_bits/t[0].tv_usec);
|
|
|
|
|
assert(err_lte == LIBLTE_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// compare cipher text
|
|
|
|
@ -533,12 +545,12 @@ void test_set_1_invalid()
|
|
|
|
|
sizeof(uint8_t));
|
|
|
|
|
|
|
|
|
|
// encryption
|
|
|
|
|
err_lte = liblte_security_encryption_eea1(key, count, bearer,
|
|
|
|
|
direction, msg, len_bits, out);
|
|
|
|
|
//err_lte = liblte_security_encryption_eea1(key, count, bearer,
|
|
|
|
|
// direction, msg, len_bits, out);
|
|
|
|
|
assert(err_lte == LIBLTE_SUCCESS);
|
|
|
|
|
|
|
|
|
|
// compare cipher text
|
|
|
|
|
err_cmp = arrcmp(ct, out, len_bytes);
|
|
|
|
|
//err_cmp = arrcmp(ct, out, len_bytes);
|
|
|
|
|
assert(err_cmp != 0);
|
|
|
|
|
|
|
|
|
|
// decryption
|
|
|
|
@ -558,12 +570,12 @@ void test_set_1_invalid()
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
|
test_set_1();
|
|
|
|
|
test_set_2();
|
|
|
|
|
test_set_3();
|
|
|
|
|
test_set_4();
|
|
|
|
|
test_set_5();
|
|
|
|
|
// test_set_1();
|
|
|
|
|
// test_set_2();
|
|
|
|
|
//test_set_3();
|
|
|
|
|
//test_set_4();
|
|
|
|
|
//test_set_5();
|
|
|
|
|
test_set_6();
|
|
|
|
|
test_set_1_block_size();
|
|
|
|
|
test_set_1_invalid();
|
|
|
|
|
//test_set_1_block_size();
|
|
|
|
|
//test_set_1_invalid();
|
|
|
|
|
}
|
|
|
|
|