1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-20 18:45:32 -07:00
libsodium/test/default/sodium_utils.c
2013-04-25 22:38:06 -07:00

25 lines
631 B
C

#include <stdio.h>
#include <string.h>
#define TEST_NAME "sodium_utils"
#include "cmptest.h"
int main(void)
{
char buf1[1000];
char buf2[1000];
randombytes(buf1, sizeof buf1);
memcpy(buf2, buf1, sizeof buf2);
printf ("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1));
sodium_memzero(buf1, 0U);
printf ("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1));
sodium_memzero(buf1, sizeof buf1 / 2);
printf ("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1));
printf ("%d\n", sodium_memcmp(buf1, buf2, 0U));
sodium_memzero(buf2, sizeof buf2 / 2);
printf ("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1));
return 0;
}