[test suite] exercise fko_base64_encode() and fko_base64_decode() in fko-wrapper

This commit is contained in:
Michael Rash
2014-03-18 20:37:47 -04:00
parent 00f878c5ed
commit 6875d0092c
+13 -7
View File
@@ -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;
}