Clean up in libzrtp tests
Modified-by: Travis Cross <tc@traviscross.com> Signed-off-by: Travis Cross <tc@traviscross.com>
This commit is contained in:
parent
cc134b8cbe
commit
95519659b9
|
@ -11,7 +11,7 @@
|
|||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "zrtp.h"
|
||||
#include "cmockery/cmockery.h"
|
||||
|
@ -109,7 +109,7 @@ void cache_init_store_empty_test() {
|
|||
* Add few entries to the empty cache, flush it and then load again. Check if
|
||||
* all the entries were restored successfully.
|
||||
*/
|
||||
void cache_add2empty_test() {
|
||||
void cache_add2empty_test() {
|
||||
zrtp_status_t status;
|
||||
int intres;
|
||||
|
||||
|
@ -146,8 +146,8 @@ void cache_save_unchanged_test() {
|
|||
|
||||
/*
|
||||
* TEST: now let's store the cache making no changes to it.
|
||||
* After opening it should include all the secrets untouched.
|
||||
*/
|
||||
* After opening it should include all the secrets untouched.
|
||||
*/
|
||||
|
||||
printf("==> And the cache again, it should contain all the stored values.\n");
|
||||
|
||||
|
|
|
@ -52,64 +52,7 @@ static void aes256_cfb_test() {
|
|||
assert_non_null(cipher);
|
||||
cipher->self_test(cipher, ZRTP_CIPHER_MODE_CFB);
|
||||
}
|
||||
/*
|
||||
static void aes256_cfb_test2() {
|
||||
rtp_aes_cfb_ctx_t *ctx = (zrtp_aes_cfb_ctx_t*)self->start( self,
|
||||
aes_cfb_test_key,
|
||||
NULL,
|
||||
ZRTP_CIPHER_MODE_CFB);
|
||||
if (NULL == ctx) {
|
||||
return zrtp_status_fail;
|
||||
}
|
||||
|
||||
ZRTP_LOG(3, (_ZTU_,"256 bit AES CFB\n"));
|
||||
ZRTP_LOG(3, (_ZTU_, "1st test...\n"));
|
||||
|
||||
zrtp_memcpy(aes_cfb_test_buf2b, aes_cfb_test_buf2a, sizeof(aes_cfb_test_buf2a));
|
||||
zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(tmp_iv));
|
||||
|
||||
ZRTP_LOG(3, (_ZTU_, "\tencryption... "));
|
||||
|
||||
self->set_iv(self, ctx, &tmp_iv);
|
||||
err = self->encrypt(self, ctx, aes_cfb_test_buf2b, sizeof(aes_cfb_test_buf2b));
|
||||
if (zrtp_status_ok != err) {
|
||||
ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB encrypt returns error %d\n", err));
|
||||
self->stop(self, ctx);
|
||||
return err;
|
||||
}
|
||||
|
||||
for (i=0; i<16; i++) {
|
||||
if (aes_cfb_test_buf2b[i] != 0x00) {
|
||||
ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB failed on encrypt test\n"));
|
||||
self->stop(self, ctx);
|
||||
return zrtp_status_fail;
|
||||
}
|
||||
}
|
||||
ZRTP_LOGC(3, ("OK\n"));
|
||||
|
||||
ZRTP_LOG(3, (_ZTU_, "\tdecryption... "));
|
||||
|
||||
zrtp_memcpy(&tmp_iv, aes_cfb_test_iv, sizeof(tmp_iv));
|
||||
self->set_iv(self, ctx, &tmp_iv);
|
||||
|
||||
err = self->decrypt(self, ctx, aes_cfb_test_buf2b, sizeof(aes_cfb_test_buf2b));
|
||||
if (zrtp_status_ok != err) {
|
||||
ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB decrypt returns error %d\n", err));
|
||||
self->stop(self, ctx);
|
||||
return err;
|
||||
}
|
||||
for (i=0; i<sizeof(aes_cfb_test_buf2b); i++) {
|
||||
if (aes_cfb_test_buf2b[i] != aes_cfb_test_buf2a[i]) {
|
||||
ZRTP_LOGC(1, ("ERROR! 256-bit AES CFB failed on decrypt test\n"));
|
||||
self->stop(self, ctx);
|
||||
return zrtp_status_fail;
|
||||
}
|
||||
}
|
||||
self->stop(self, ctx);
|
||||
ZRTP_LOGC(3, ("OK\n"));
|
||||
|
||||
}
|
||||
*/
|
||||
int main(void) {
|
||||
const UnitTest tests[] = {
|
||||
unit_test_setup_teardown(aes128_ctr_test, setup, teardown),
|
||||
|
|
|
@ -132,7 +132,6 @@ static int on_send_packet(const zrtp_stream_t* ctx, char* message, unsigned int
|
|||
zrtp_test_id_t *stream_id = zrtp_stream_get_userdata(ctx);
|
||||
zrtp_test_stream_t *stream = zrtp_test_stream_by_id(*stream_id);
|
||||
if (stream) {
|
||||
printf("trace>>> PUSH from stream ID=%u\n", stream->id);
|
||||
zrtp_test_queue_push(stream->output, elem);
|
||||
return zrtp_status_ok;
|
||||
} else {
|
||||
|
@ -168,24 +167,8 @@ static zrtp_test_stream_t *get_stream_to_process_(zrtp_endpoint_t *endpoint) {
|
|||
j = (unsigned)i;
|
||||
j = j % streams_count;
|
||||
|
||||
printf("trace>>> CHOOSE stream Endpoint=%u IDX=%u ID=%u\n", endpoint->id, j, all_streams[j]);
|
||||
//printf("trace>>> CHOOSE stream Endpoint=%u IDX=%u ID=%u\n", endpoint->id, j, all_streams[j]);
|
||||
return zrtp_test_stream_by_id(all_streams[j]);
|
||||
|
||||
|
||||
// unsigned is_found = 0;
|
||||
// zrtp_test_id_t result, left;
|
||||
// for (i=0; i<streams_count; i++) {
|
||||
// result = all_streams[i];
|
||||
// if (result > stream_id) {
|
||||
// is_found = 1;
|
||||
// break;
|
||||
// } else {
|
||||
// left = result;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// printf("TRACE>>> choose stream ID=%u\n", is_found ? result : left);
|
||||
// return zrtp_test_stream_by_id(is_found ? result : left);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue