mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-20 02:25:14 -07:00
Indent
This commit is contained in:
parent
cadee98e13
commit
cac2dde218
@ -2,7 +2,8 @@
|
||||
#define TEST_NAME "sodium_core"
|
||||
#include "cmptest.h"
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("%d\n", sodium_init());
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#define TEST_NAME "sodium_utils"
|
||||
#include "cmptest.h"
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
unsigned char buf_add[1000];
|
||||
unsigned char buf1[1000];
|
||||
@ -32,7 +33,8 @@ int main(void)
|
||||
sodium_bin2hex(buf3, 33U, (const unsigned char *) "0123456789ABCDEF",
|
||||
16U));
|
||||
hex = "Cafe : 6942";
|
||||
sodium_hex2bin(buf4, sizeof buf4, hex, strlen(hex), ": ", &bin_len, &hex_end);
|
||||
sodium_hex2bin(buf4, sizeof buf4, hex, strlen(hex), ": ", &bin_len,
|
||||
&hex_end);
|
||||
printf("%lu:%02x%02x%02x%02x\n", (unsigned long) bin_len, buf4[0], buf4[1],
|
||||
buf4[2], buf4[3]);
|
||||
printf("dt1: %ld\n", (long) (hex_end - hex));
|
||||
@ -50,43 +52,47 @@ int main(void)
|
||||
|
||||
hex = "de:ad:be:eff";
|
||||
if (sodium_hex2bin(buf1, 4U, hex, 12U, ":", &bin_len, &hex_end) != -1) {
|
||||
printf("sodium_hex2bin() with an odd input length and a short output buffer\n");
|
||||
printf(
|
||||
"sodium_hex2bin() with an odd input length and a short output "
|
||||
"buffer\n");
|
||||
}
|
||||
printf("dt3: %ld\n", (long) (hex_end - hex));
|
||||
|
||||
hex = "de:ad:be:eff";
|
||||
if (sodium_hex2bin(buf1, sizeof buf1, hex, 12U, ":", &bin_len, &hex_end) != 0) {
|
||||
if (sodium_hex2bin(buf1, sizeof buf1, hex, 12U, ":", &bin_len, &hex_end) !=
|
||||
0) {
|
||||
printf("sodium_hex2bin() with an odd input length\n");
|
||||
}
|
||||
printf("dt4: %ld\n", (long) (hex_end - hex));
|
||||
|
||||
hex = "de:ad:be:eff";
|
||||
if (sodium_hex2bin(buf1, sizeof buf1, hex, 13U, ":", &bin_len, &hex_end) != 0) {
|
||||
if (sodium_hex2bin(buf1, sizeof buf1, hex, 13U, ":", &bin_len, &hex_end) !=
|
||||
0) {
|
||||
printf("sodium_hex2bin() with an odd input length\n");
|
||||
}
|
||||
printf("dt5: %ld\n", (long) (hex_end - hex));
|
||||
|
||||
memset(nonce, 0, sizeof nonce);
|
||||
sodium_increment(nonce, sizeof nonce);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
memset(nonce, 255, sizeof nonce);
|
||||
sodium_increment(nonce, sizeof nonce);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
nonce[1] = 1U;
|
||||
sodium_increment(nonce, sizeof nonce);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
nonce[1] = 0U;
|
||||
sodium_increment(nonce, sizeof nonce);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
nonce[0] = 255U;
|
||||
nonce[2] = 255U;
|
||||
sodium_increment(nonce, sizeof nonce);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
for (i = 0U; i < 1000U; i++) {
|
||||
bin_len = (size_t) randombytes_uniform(sizeof buf1);
|
||||
randombytes_buf(buf1, bin_len);
|
||||
@ -96,7 +102,8 @@ int main(void)
|
||||
buf2_rev[bin_len - 1 - j] = buf2[j];
|
||||
}
|
||||
if (memcmp(buf1_rev, buf2_rev, bin_len) *
|
||||
sodium_compare(buf1, buf2, bin_len) < 0) {
|
||||
sodium_compare(buf1, buf2, bin_len) <
|
||||
0) {
|
||||
printf("sodium_compare() failure with length=%u\n",
|
||||
(unsigned int) bin_len);
|
||||
}
|
||||
@ -146,37 +153,36 @@ int main(void)
|
||||
memset(nonce, 0xfe, 24U);
|
||||
memset(nonce, 0xff, 6U);
|
||||
sodium_increment(nonce, 8U);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
memset(nonce, 0xfe, 24U);
|
||||
memset(nonce, 0xff, 10U);
|
||||
sodium_increment(nonce, 12U);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
memset(nonce, 0xff, 22U);
|
||||
sodium_increment(nonce, 24U);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
|
||||
assert(sizeof nonce >= 24U);
|
||||
memset(nonce, 0xfe, 24U);
|
||||
memset(nonce, 0xff, 6U);
|
||||
sodium_add(nonce, nonce, 7U);
|
||||
sodium_add(nonce, nonce, 8U);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
memset(nonce, 0xfe, 24U);
|
||||
memset(nonce, 0xff, 10U);
|
||||
sodium_add(nonce, nonce, 11U);
|
||||
sodium_add(nonce, nonce, 12U);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
memset(nonce, 0xff, 22U);
|
||||
sodium_add(nonce, nonce, 23U);
|
||||
sodium_add(nonce, nonce, 24U);
|
||||
printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex,
|
||||
nonce, sizeof nonce));
|
||||
printf("%s\n",
|
||||
sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -12,7 +12,8 @@
|
||||
#warning The sodium_utils2 test is expected to fail with address sanitizer
|
||||
#endif
|
||||
|
||||
__attribute__ ((noreturn)) static void segv_handler(int sig)
|
||||
__attribute__((noreturn)) static void
|
||||
segv_handler(int sig)
|
||||
{
|
||||
(void) sig;
|
||||
|
||||
@ -30,7 +31,8 @@ __attribute__ ((noreturn)) static void segv_handler(int sig)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
void * buf;
|
||||
size_t size;
|
||||
|
@ -12,7 +12,8 @@
|
||||
#warning The sodium_utils3 test is expected to fail with address sanitizer
|
||||
#endif
|
||||
|
||||
__attribute__ ((noreturn)) static void segv_handler(int sig)
|
||||
__attribute__((noreturn)) static void
|
||||
segv_handler(int sig)
|
||||
{
|
||||
(void) sig;
|
||||
|
||||
@ -30,7 +31,8 @@ __attribute__ ((noreturn)) static void segv_handler(int sig)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
void * buf;
|
||||
size_t size;
|
||||
|
@ -2,7 +2,8 @@
|
||||
#define TEST_NAME "sodium_version"
|
||||
#include "cmptest.h"
|
||||
|
||||
int main(void)
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
printf("%d\n", sodium_version_string() != NULL);
|
||||
printf("%d\n", sodium_library_version_major() > 0);
|
||||
|
Loading…
Reference in New Issue
Block a user