From 6875d0092cf642ecd5c3c2bb6c8c5a456e37bbe6 Mon Sep 17 00:00:00 2001 From: Michael Rash Date: Tue, 18 Mar 2014 20:37:47 -0400 Subject: [PATCH] [test suite] exercise fko_base64_encode() and fko_base64_decode() in fko-wrapper --- test/fko-wrapper/fko_wrapper.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/test/fko-wrapper/fko_wrapper.c b/test/fko-wrapper/fko_wrapper.c index c33d039a..b8d96729 100644 --- a/test/fko-wrapper/fko_wrapper.c +++ b/test/fko-wrapper/fko_wrapper.c @@ -49,18 +49,12 @@ static void spa_func_getset_short(fko_ctx_t *ctx, char *set_name, int spa_calls = 0; int main(void) { - int i; test_loop(NO_NEW_CTX, NO_CTX_DESTROY); test_loop(NEW_CTX, CTX_DESTROY); test_loop(NEW_CTX, NO_CTX_DESTROY); test_loop(NO_NEW_CTX, CTX_DESTROY); - /* call fko_errstr() across valid and invalid values - */ - for (i=-5; i < FKO_LAST_ERROR+5; i++) - printf("libfko error (%d): %s\n", i, fko_errstr(i)); - printf("\n[+] Total libfko function calls: %d\n\n", spa_calls); return 0; @@ -71,7 +65,7 @@ test_loop(int new_ctx_flag, int destroy_ctx_flag) { fko_ctx_t ctx = NULL, decrypt_ctx = NULL; int i, j; - char *spa_data = NULL; + char *spa_data = NULL, encode_buf[100], decode_buf[100]; printf("[+] test_loop(): %s, %s\n", new_ctx_flag == NEW_CTX ? "NEW_CTX" : "NO_NEW_CTX", @@ -249,6 +243,18 @@ test_loop(int new_ctx_flag, int destroy_ctx_flag) decrypt_ctx = NULL; } + /* exercise the base64 encode/decode wrapper + */ + fko_base64_encode((unsigned char *)ENC_KEY, encode_buf, 16); + fko_base64_decode(encode_buf, (unsigned char *)decode_buf); + + /* call fko_errstr() across valid and invalid values + */ + for (i=-5; i < FKO_LAST_ERROR+5; i++) { + printf("libfko error (%d): %s\n", i, fko_errstr(i)); + spa_calls++; + } + return; }