diff options
author | Björn Esser <besser82@fedoraproject.org> | 2019-05-04 21:48:49 +0200 |
---|---|---|
committer | Björn Esser <besser82@fedoraproject.org> | 2019-05-04 21:48:49 +0200 |
commit | 398943774c5ff38baf1bc5ee088855fd8983bb05 (patch) | |
tree | b4348e64df3d5c174c0580b5b2e7b70a76b41a71 | |
parent | 0ef346147f8a6b35eca164341ce64e7dc7f5ac99 (diff) | |
download | libxcrypt-398943774c5ff38baf1bc5ee088855fd8983bb05.tar.gz libxcrypt-398943774c5ff38baf1bc5ee088855fd8983bb05.tar.bz2 libxcrypt-398943774c5ff38baf1bc5ee088855fd8983bb05.zip |
Apply proper GNU-style code formatting.
-rw-r--r-- | lib/crypt-des.c | 30 | ||||
-rw-r--r-- | lib/crypt-md5.c | 10 | ||||
-rw-r--r-- | lib/crypt-pbkdf1-sha1.c | 10 | ||||
-rw-r--r-- | lib/crypt-port.h | 6 | ||||
-rw-r--r-- | lib/crypt-sha256.c | 10 | ||||
-rw-r--r-- | lib/crypt-sha512.c | 10 | ||||
-rw-r--r-- | lib/crypt.c | 4 | ||||
-rw-r--r-- | test/alg-pbkdf-hmac-sha256.c | 53 | ||||
-rw-r--r-- | test/crypt-kat.c | 57 | ||||
-rw-r--r-- | test/gensalt.c | 58 |
10 files changed, 137 insertions, 111 deletions
diff --git a/lib/crypt-des.c b/lib/crypt-des.c index b21f3f8..402f99c 100644 --- a/lib/crypt-des.c +++ b/lib/crypt-des.c @@ -144,9 +144,9 @@ des_gen_hash (struct des_ctx *ctx, uint32_t count, uint8_t *output, /* The original UNIX DES-based password hash, no extensions. */ void crypt_descrypt_rn (const char *phrase, size_t ARG_UNUSED (phr_size), - const char *setting, size_t ARG_UNUSED (set_size), - uint8_t *output, size_t out_size, - void *scratch, size_t scr_size) + const char *setting, size_t ARG_UNUSED (set_size), + uint8_t *output, size_t out_size, + void *scratch, size_t scr_size) { /* This shouldn't ever happen, but... */ if (out_size < DES_TRD_OUTPUT_LEN || scr_size < sizeof (struct des_buffer)) @@ -222,9 +222,9 @@ crypt_descrypt_rn (const char *phrase, size_t ARG_UNUSED (phr_size), Andy Phillips <atp@mssl.ucl.ac.uk> */ void crypt_bigcrypt_rn (const char *phrase, size_t phr_size, - const char *setting, size_t set_size, - uint8_t *output, size_t out_size, - void *scratch, size_t scr_size) + const char *setting, size_t set_size, + uint8_t *output, size_t out_size, + void *scratch, size_t scr_size) { /* descrypt and bigcrypt generate identical hashes when the phrase contains no more than 8 characters. When the phrase is longer @@ -311,9 +311,9 @@ crypt_bigcrypt_rn (const char *phrase, size_t phr_size, count, but are still unacceptably weak by modern standards. */ void crypt_bsdicrypt_rn (const char *phrase, size_t ARG_UNUSED (phr_size), - const char *setting, size_t set_size, - uint8_t *output, size_t out_size, - void *scratch, size_t scr_size) + const char *setting, size_t set_size, + uint8_t *output, size_t out_size, + void *scratch, size_t scr_size) { /* This shouldn't ever happen, but... */ if (out_size < DES_EXT_OUTPUT_LEN || scr_size < sizeof (struct des_buffer)) @@ -397,8 +397,8 @@ crypt_bsdicrypt_rn (const char *phrase, size_t ARG_UNUSED (phr_size), #if INCLUDE_descrypt || INCLUDE_bigcrypt void gensalt_descrypt_rn (unsigned long count, - const uint8_t *rbytes, size_t nrbytes, - uint8_t *output, size_t output_size) + const uint8_t *rbytes, size_t nrbytes, + uint8_t *output, size_t output_size) { if (output_size < 3) { @@ -419,8 +419,8 @@ gensalt_descrypt_rn (unsigned long count, #if INCLUDE_bigcrypt void gensalt_bigcrypt_rn (unsigned long count, - const uint8_t *rbytes, size_t nrbytes, - uint8_t *output, size_t output_size) + const uint8_t *rbytes, size_t nrbytes, + uint8_t *output, size_t output_size) { #if !INCLUDE_descrypt /* We need descrypt + 12 bytes. */ @@ -445,8 +445,8 @@ gensalt_bigcrypt_rn (unsigned long count, #if INCLUDE_bsdicrypt void gensalt_bsdicrypt_rn (unsigned long count, - const uint8_t *rbytes, size_t nrbytes, - uint8_t *output, size_t output_size) + const uint8_t *rbytes, size_t nrbytes, + uint8_t *output, size_t output_size) { if (output_size < 1 + 4 + 4 + 1) { diff --git a/lib/crypt-md5.c b/lib/crypt-md5.c index f33d173..b656de9 100644 --- a/lib/crypt-md5.c +++ b/lib/crypt-md5.c @@ -57,9 +57,9 @@ static_assert (sizeof (struct md5_buffer) <= ALG_SPECIFIC_SIZE, libcs. */ void crypt_md5crypt_rn (const char *phrase, size_t phr_size, - const char *setting, size_t ARG_UNUSED (set_size), - uint8_t *output, size_t out_size, - void *scratch, size_t scr_size) + const char *setting, size_t ARG_UNUSED (set_size), + uint8_t *output, size_t out_size, + void *scratch, size_t scr_size) { /* This shouldn't ever happen, but... */ if (out_size < MD5_HASH_LENGTH || scr_size < sizeof (struct md5_buffer)) @@ -209,8 +209,8 @@ crypt_md5crypt_rn (const char *phrase, size_t phr_size, void gensalt_md5crypt_rn (unsigned long count, - const uint8_t *rbytes, size_t nrbytes, - uint8_t *output, size_t output_size) + const uint8_t *rbytes, size_t nrbytes, + uint8_t *output, size_t output_size) { if (count != 0) { diff --git a/lib/crypt-pbkdf1-sha1.c b/lib/crypt-pbkdf1-sha1.c index ef2be00..c9b2cd4 100644 --- a/lib/crypt-pbkdf1-sha1.c +++ b/lib/crypt-pbkdf1-sha1.c @@ -90,9 +90,9 @@ to64 (uint8_t *s, unsigned long v, int n) */ void crypt_sha1crypt_rn (const char *phrase, size_t phr_size, - const char *setting, size_t ARG_UNUSED (set_size), - uint8_t *output, size_t out_size, - void *scratch, size_t scr_size) + const char *setting, size_t ARG_UNUSED (set_size), + uint8_t *output, size_t out_size, + void *scratch, size_t scr_size) { static const char *magic = "$sha1$"; @@ -194,8 +194,8 @@ crypt_sha1crypt_rn (const char *phrase, size_t phr_size, http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/lib/libcrypt/pw_gensalt.c */ void gensalt_sha1crypt_rn (unsigned long count, - const uint8_t *rbytes, size_t nrbytes, - uint8_t *output, size_t o_size) + const uint8_t *rbytes, size_t nrbytes, + uint8_t *output, size_t o_size) { static_assert (sizeof (uint32_t) == 4, "space calculations below assume 8-bit bytes"); diff --git a/lib/crypt-port.h b/lib/crypt-port.h index 44d278f..1e4d4b6 100644 --- a/lib/crypt-port.h +++ b/lib/crypt-port.h @@ -363,7 +363,7 @@ _crypt_strcpy_or_abort (void *, const size_t, const void *); #if !INCLUDE_yescrypt #define gensalt_yescrypt_rn _crypt_gensalt_yescrypt_rn extern void gensalt_yescrypt_rn - (unsigned long, const uint8_t *, size_t, uint8_t *, size_t); +(unsigned long, const uint8_t *, size_t, uint8_t *, size_t); #endif #endif @@ -371,14 +371,14 @@ extern void gensalt_yescrypt_rn #if INCLUDE_bigcrypt && !INCLUDE_descrypt #define gensalt_descrypt_rn _crypt_gensalt_descrypt_rn extern void gensalt_descrypt_rn - (unsigned long, const uint8_t *, size_t, uint8_t *, size_t); +(unsigned long, const uint8_t *, size_t, uint8_t *, size_t); #endif /* Those are not present, if scrypt is selected, but yescrypt is not. */ #if INCLUDE_scrypt && !INCLUDE_yescrypt #define crypt_yescrypt_rn _crypt_crypt_yescrypt_rn extern void crypt_yescrypt_rn (const char *, size_t, const char *, - size_t, uint8_t *, size_t, void *, size_t); + size_t, uint8_t *, size_t, void *, size_t); #endif /* We need a prototype for fcrypt for some tests. */ diff --git a/lib/crypt-sha256.c b/lib/crypt-sha256.c index 447fe11..5a55de1 100644 --- a/lib/crypt-sha256.c +++ b/lib/crypt-sha256.c @@ -81,9 +81,9 @@ SHA256_Update_recycled (SHA256_CTX *ctx, void crypt_sha256crypt_rn (const char *phrase, size_t phr_size, - const char *setting, size_t ARG_UNUSED (set_size), - uint8_t *output, size_t out_size, - void *scratch, size_t scr_size) + const char *setting, size_t ARG_UNUSED (set_size), + uint8_t *output, size_t out_size, + void *scratch, size_t scr_size) { /* This shouldn't ever happen, but... */ if (out_size < SHA256_HASH_LENGTH @@ -291,8 +291,8 @@ crypt_sha256crypt_rn (const char *phrase, size_t phr_size, void gensalt_sha256crypt_rn (unsigned long count, - const uint8_t *rbytes, size_t nrbytes, - uint8_t *output, size_t output_size) + const uint8_t *rbytes, size_t nrbytes, + uint8_t *output, size_t output_size) { gensalt_sha_rn ('5', SALT_LEN_MAX, ROUNDS_DEFAULT, ROUNDS_MIN, ROUNDS_MAX, count, rbytes, nrbytes, output, output_size); diff --git a/lib/crypt-sha512.c b/lib/crypt-sha512.c index d4a5993..a1f9138 100644 --- a/lib/crypt-sha512.c +++ b/lib/crypt-sha512.c @@ -82,9 +82,9 @@ sha512_process_recycled_bytes (unsigned char block[64], size_t len, void crypt_sha512crypt_rn (const char *phrase, size_t phr_size, - const char *setting, size_t ARG_UNUSED (set_size), - uint8_t *output, size_t out_size, - void *scratch, size_t scr_size) + const char *setting, size_t ARG_UNUSED (set_size), + uint8_t *output, size_t out_size, + void *scratch, size_t scr_size) { /* This shouldn't ever happen, but... */ if (out_size < SHA512_HASH_LENGTH @@ -307,8 +307,8 @@ crypt_sha512crypt_rn (const char *phrase, size_t phr_size, void gensalt_sha512crypt_rn (unsigned long count, - const uint8_t *rbytes, size_t nrbytes, - uint8_t *output, size_t output_size) + const uint8_t *rbytes, size_t nrbytes, + uint8_t *output, size_t output_size) { gensalt_sha_rn ('6', SALT_LEN_MAX, ROUNDS_DEFAULT, ROUNDS_MIN, ROUNDS_MAX, count, rbytes, nrbytes, output, output_size); diff --git a/lib/crypt.c b/lib/crypt.c index 12892ff..929fb48 100644 --- a/lib/crypt.c +++ b/lib/crypt.c @@ -333,9 +333,9 @@ const char * crypt_preferred_method (void) { #if defined HASH_ALGORITHM_DEFAULT - return HASH_ALGORITHM_DEFAULT; + return HASH_ALGORITHM_DEFAULT; #else - return NULL; + return NULL; #endif } SYMVER_crypt_preferred_method; diff --git a/test/alg-pbkdf-hmac-sha256.c b/test/alg-pbkdf-hmac-sha256.c index df22979..9f73496 100644 --- a/test/alg-pbkdf-hmac-sha256.c +++ b/test/alg-pbkdf-hmac-sha256.c @@ -24,19 +24,23 @@ struct hmac_sha256_test }; /* HMAC-SHA256 test vectors from RFC 4231. */ -static const struct hmac_sha256_test hmac_sha256_tests[] = { - { "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" +static const struct hmac_sha256_test hmac_sha256_tests[] = +{ + { + "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b" "\x0b\x0b\x0b\x0b", "Hi There", "\xb0\x34\x4c\x61\xd8\xdb\x38\x53\x5c\xa8\xaf\xce\xaf\x0b\xf1\x2b" "\x88\x1d\xc2\x00\xc9\x83\x3d\xa7\x26\xe9\x37\x6c\x2e\x32\xcf\xf7" }, - { "Jefe", + { + "Jefe", "what do ya want for nothing?", "\x5b\xdc\xc1\x46\xbf\x60\x75\x4e\x6a\x04\x24\x26\x08\x95\x75\xc7" "\x5a\x00\x3f\x08\x9d\x27\x39\x83\x9d\xec\x58\xb9\x64\xec\x38\x43" }, - { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + { + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa", "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd" @@ -45,7 +49,8 @@ static const struct hmac_sha256_test hmac_sha256_tests[] = { "\x77\x3e\xa9\x1e\x36\x80\x0e\x46\x85\x4d\xb8\xeb\xd0\x91\x81\xa7" "\x29\x59\x09\x8b\x3e\xf8\xc1\x22\xd9\x63\x55\x14\xce\xd5\x65\xfe" }, - { "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10" + { + "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10" "\x11\x12\x13\x14\x15\x16\x17\x18\x19", "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd" @@ -54,15 +59,17 @@ static const struct hmac_sha256_test hmac_sha256_tests[] = { "\x82\x55\x8a\x38\x9a\x44\x3c\x0e\xa4\xcc\x81\x98\x99\xf2\x08\x3a" "\x85\xf0\xfa\xa3\xe5\x78\xf8\x07\x7a\x2e\x3f\xf4\x67\x29\x66\x5b" }, - { "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" + { + "\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c\x0c" "\x0c\x0c\x0c\x0c", "Test With Truncation", /* N.B. the RFC only supplies the high 16 bytes of this vector; the rest were filled in with the current implementation's output. */ "\xa3\xb6\x16\x74\x73\x10\x0e\xe0\x6e\x0c\x79\x6c\x29\x55\x55\x2b" "\xfa\x6f\x7c\x0a\x6a\x8a\xef\x8b\x93\xf8\x60\xaa\xb0\xcd\x20\xc5" - }, - { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + }, + { + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -75,7 +82,8 @@ static const struct hmac_sha256_test hmac_sha256_tests[] = { "\x60\xe4\x31\x59\x1e\xe0\xb6\x7f\x0d\x8a\x26\xaa\xcb\xf5\xb7\x7f" "\x8e\x0b\xc6\x21\x37\x28\xc5\x14\x05\x46\x04\x0f\x0e\xe3\x7f\x54" }, - { "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + { + "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" @@ -103,15 +111,18 @@ struct pbkdf2_hmac_sha256_test const char *dk; /* [dklen] */ }; -struct pbkdf2_hmac_sha256_test pbkdf2_hmac_sha256_tests[] = { +struct pbkdf2_hmac_sha256_test pbkdf2_hmac_sha256_tests[] = +{ /* PBKDF2-HMAC-SHA256 test vectors from RFC 7914. */ - { "passwd", "salt", 6, 4, 1, 64, + { + "passwd", "salt", 6, 4, 1, 64, "\x55\xac\x04\x6e\x56\xe3\x08\x9f\xec\x16\x91\xc2\x25\x44\xb6\x05" "\xf9\x41\x85\x21\x6d\xde\x04\x65\xe6\x8b\x9d\x57\xc2\x0d\xac\xbc" "\x49\xca\x9c\xcc\xf1\x79\xb6\x45\x99\x16\x64\xb3\x9d\x77\xef\x31" "\x7c\x71\xb8\x45\xb1\xe3\x0b\xd5\x09\x11\x20\x41\xd3\xa1\x97\x83" }, - { "Password", "NaCl", 8, 4, 80000, 64, + { + "Password", "NaCl", 8, 4, 80000, 64, "\x4d\xdc\xd8\xf6\x0b\x98\xbe\x21\x83\x0c\xee\x5e\xf2\x27\x01\xf9" "\x64\x1a\x44\x18\xd0\x4c\x04\x14\xae\xff\x08\x87\x6b\x34\xab\x56" "\xa1\xd4\x25\xa1\x22\x58\x33\x54\x9a\xdb\x84\x1b\x51\xc9\xb3\x17" @@ -120,33 +131,39 @@ struct pbkdf2_hmac_sha256_test pbkdf2_hmac_sha256_tests[] = { /* Test vectors from RFC 6070 (which defines PBKDF2-HMAC-SHA1) recalculated with SHA256 instead of SHA1 and a larger dklen by 'aaz' at <https://stackoverflow.com/a/5136918/388520>. */ - { "password", "salt", 8, 4, 1, 32, + { + "password", "salt", 8, 4, 1, 32, "\x12\x0f\xb6\xcf\xfc\xf8\xb3\x2c\x43\xe7\x22\x52\x56\xc4\xf8\x37" "\xa8\x65\x48\xc9\x2c\xcc\x35\x48\x08\x05\x98\x7c\xb7\x0b\xe1\x7b" }, - { "password", "salt", 8, 4, 2, 32, + { + "password", "salt", 8, 4, 2, 32, "\xae\x4d\x0c\x95\xaf\x6b\x46\xd3\x2d\x0a\xdf\xf9\x28\xf0\x6d\xd0" "\x2a\x30\x3f\x8e\xf3\xc2\x51\xdf\xd6\xe2\xd8\x5a\x95\x47\x4c\x43" }, - { "password", "salt", 8, 4, 4096, 32, + { + "password", "salt", 8, 4, 4096, 32, "\xc5\xe4\x78\xd5\x92\x88\xc8\x41\xaa\x53\x0d\xb6\x84\x5c\x4c\x8d" "\x96\x28\x93\xa0\x01\xce\x4e\x11\xa4\x96\x38\x73\xaa\x98\x13\x4a" }, #ifdef SLOW_TESTS /* With this test vector included, the program takes 40 seconds to run to completion on a 2017-generation x86. Without, half a second. */ - { "password", "salt", 8, 4, 16777216, 32, + { + "password", "salt", 8, 4, 16777216, 32, "\xcf\x81\xc6\x6f\xe8\xcf\xc0\x4d\x1f\x31\xec\xb6\x5d\xab\x40\x89" "\xf7\xf1\x79\xe8\x9b\x3b\x0b\xcb\x17\xad\x10\xe3\xac\x6e\xba\x46" }, #endif - { "passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", + { + "passwordPASSWORDpassword", "saltSALTsaltSALTsaltSALTsaltSALTsalt", 24, 36, 4096, 40, "\x34\x8c\x89\xdb\xcb\xd3\x2b\x2f\x32\xd8\x14\xb8\x11\x6e\x84\xcf" "\x2b\x17\x34\x7e\xbc\x18\x00\x18\x1c\x4e\x2a\x1f\xb8\xdd\x53\xe1" "\xc6\x35\x51\x8c\x7d\xac\x47\xe9" }, - { "pass\0word", "sa\0lt", 9, 5, 4096, 16, + { + "pass\0word", "sa\0lt", 9, 5, 4096, 16, "\x89\xb6\x9d\x05\x16\xf8\x29\x89\x3c\x69\x62\x26\x65\x0a\x86\x87" } }; diff --git a/test/crypt-kat.c b/test/crypt-kat.c index 19a79b1..66a1fa2 100644 --- a/test/crypt-kat.c +++ b/test/crypt-kat.c @@ -152,7 +152,7 @@ report_result (const char *tag, const char *hash, int errnm, printf (", errno not set"); /* Should the API used have generated a NULL or a failure token? */ - if (hash == 0 && expect_failure_tokens) + if (hash == 0 && expect_failure_tokens) printf (", failure token not generated"); if (hash != 0 && !expect_failure_tokens) printf (", failure token wrongly generated"); @@ -200,9 +200,10 @@ static void * calc_hashes_crypt_r_rn (ARG_UNUSED (void *unused)) { char *hash; - union { - char pass[CRYPT_MAX_PASSPHRASE_SIZE + 1]; - int aligned; + union + { + char pass[CRYPT_MAX_PASSPHRASE_SIZE + 1]; + int aligned; } u; size_t i; struct crypt_data data; @@ -270,32 +271,40 @@ main (void) int err; void *xstatus; err = pthread_create (&t1, 0, calc_hashes_crypt_r_rn, 0); - if (err) { - fprintf (stderr, "pthread_create (crypt_r): %s\n", strerror (err)); - return 1; - } + if (err) + { + fprintf (stderr, "pthread_create (crypt_r): %s\n", strerror (err)); + return 1; + } err = pthread_create (&t2, 0, calc_hashes_crypt_ra_recrypt, 0); - if (err) { - fprintf (stderr, "pthread_create (crypt_ra): %s\n", strerror (err)); - return 1; - } + if (err) + { + fprintf (stderr, "pthread_create (crypt_ra): %s\n", strerror (err)); + return 1; + } status |= !!calc_hashes_crypt_fcrypt (0); err = pthread_join (t1, &xstatus); - if (err) { - fprintf (stderr, "pthread_join (crypt_r): %s\n", strerror (err)); - status = 1; - } else { - status |= !!xstatus; - } + if (err) + { + fprintf (stderr, "pthread_join (crypt_r): %s\n", strerror (err)); + status = 1; + } + else + { + status |= !!xstatus; + } err = pthread_join (t2, &xstatus); - if (err) { - fprintf (stderr, "pthread_join (crypt_rn): %s\n", strerror (err)); - status = 1; - } else { - status |= !!xstatus; - } + if (err) + { + fprintf (stderr, "pthread_join (crypt_rn): %s\n", strerror (err)); + status = 1; + } + else + { + status |= !!xstatus; + } } #else status |= !!calc_hashes_crypt_fcrypt (results); diff --git a/test/gensalt.c b/test/gensalt.c index 5494f4b..2d590a9 100644 --- a/test/gensalt.c +++ b/test/gensalt.c @@ -469,36 +469,36 @@ main (void) XCRYPT_STRCPY_OR_ABORT (prev_output, CRYPT_GENSALT_OUTPUT_SIZE, salt); - /* Test if crypt works with this salt. */ - if (!tcase->rounds) - { + /* Test if crypt works with this salt. */ + if (!tcase->rounds) + { #define PASSW "alexander" - static struct crypt_data a, b; - if (!crypt_rn (PASSW, salt, &a, sizeof(a))) - { - fprintf (stderr, "ERROR: %s/%u -> crypt(gensalt) fail\n", - tcase->prefix, ent); - status = 1; - } - else if (!crypt_rn (PASSW, a.output, &b, sizeof(b))) - { - fprintf (stderr, "ERROR: %s/%u -> crypt(crypt(gensalt)) fail\n", - tcase->prefix, ent); - status = 1; - } - else if (strcmp (a.output, b.output)) - { - fprintf (stderr, "ERROR: %s/%u -> crypt(gensalt) != crypt(crypt(gensalt))\n", - tcase->prefix, ent); - status = 1; - } - else - { - fprintf (stderr, " ok: %s/%u -> crypt works with this salt\n", - tcase->prefix, ent); - } - } - } + static struct crypt_data a, b; + if (!crypt_rn (PASSW, salt, &a, sizeof(a))) + { + fprintf (stderr, "ERROR: %s/%u -> crypt(gensalt) fail\n", + tcase->prefix, ent); + status = 1; + } + else if (!crypt_rn (PASSW, a.output, &b, sizeof(b))) + { + fprintf (stderr, "ERROR: %s/%u -> crypt(crypt(gensalt)) fail\n", + tcase->prefix, ent); + status = 1; + } + else if (strcmp (a.output, b.output)) + { + fprintf (stderr, "ERROR: %s/%u -> crypt(gensalt) != crypt(crypt(gensalt))\n", + tcase->prefix, ent); + status = 1; + } + else + { + fprintf (stderr, " ok: %s/%u -> crypt works with this salt\n", + tcase->prefix, ent); + } + } + } } #if CRYPT_GENSALT_IMPLEMENTS_DEFAULT_PREFIX /* Passing a null pointer as the prefix argument to crypt_gensalt is |