Skip to content

Commit 00ca140

Browse files
karel-msjaeckel
authored andcommitted
Merge pull request #316 from libtom/pr/register-all
register_all_* should return CRYPT_OK on success (cherry picked from commit e4763d9)
1 parent 521d073 commit 00ca140

4 files changed

Lines changed: 19 additions & 14 deletions

File tree

src/misc/crypt/crypt_register_all_ciphers.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616
*/
1717

1818
#define REGISTER_CIPHER(h) do {\
19-
LTC_ARGCHK((err = register_cipher(h)) != -1); \
19+
LTC_ARGCHK(register_cipher(h) != -1); \
2020
} while(0)
2121

2222
int register_all_ciphers(void)
2323
{
24-
int err = CRYPT_NOP;
25-
2624
#ifdef LTC_RIJNDAEL
2725
#ifdef ENCRYPT_ONLY
2826
/* alternative would be
@@ -94,7 +92,7 @@ int register_all_ciphers(void)
9492
#ifdef LTC_CAMELLIA
9593
REGISTER_CIPHER(&camellia_desc);
9694
#endif
97-
return err;
95+
return CRYPT_OK;
9896
}
9997

10098
/* ref: $Format:%D$ */

src/misc/crypt/crypt_register_all_hashes.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
*/
1717

1818
#define REGISTER_HASH(h) do {\
19-
LTC_ARGCHK((err = register_hash(h)) != -1); \
19+
LTC_ARGCHK(register_hash(h) != -1); \
2020
} while(0)
2121

2222
int register_all_hashes(void)
2323
{
24-
int err = CRYPT_NOP;
2524
#ifdef LTC_TIGER
2625
REGISTER_HASH(&tiger_desc);
2726
#endif
@@ -90,9 +89,9 @@ int register_all_hashes(void)
9089
#endif
9190
#ifdef LTC_CHC_HASH
9291
REGISTER_HASH(&chc_desc);
93-
LTC_ARGCHK((err = chc_register(find_cipher_any("aes", 8, 16))) == CRYPT_OK);
92+
LTC_ARGCHK(chc_register(find_cipher_any("aes", 8, 16)) == CRYPT_OK);
9493
#endif
95-
return err;
94+
return CRYPT_OK;
9695
}
9796

9897
/* ref: $Format:%D$ */

src/misc/crypt/crypt_register_all_prngs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@
1616
*/
1717

1818
#define REGISTER_PRNG(h) do {\
19-
LTC_ARGCHK((err = register_prng(h)) != -1); \
19+
LTC_ARGCHK(register_prng(h) != -1); \
2020
} while(0)
2121

2222
int register_all_prngs(void)
2323
{
24-
int err = CRYPT_NOP;
2524
#ifdef LTC_YARROW
2625
REGISTER_PRNG(&yarrow_desc);
2726
#endif
@@ -41,7 +40,7 @@ int register_all_prngs(void)
4140
REGISTER_PRNG(&sprng_desc);
4241
#endif
4342

44-
return err;
43+
return CRYPT_OK;
4544
}
4645

4746
/* ref: $Format:%D$ */

tests/test.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,18 @@ static void register_algs(void)
275275
#ifndef LTC_YARROW
276276
#error This demo requires Yarrow.
277277
#endif
278-
register_all_ciphers();
279-
register_all_hashes();
280-
register_all_prngs();
278+
if ((err = register_all_ciphers()) != CRYPT_OK) {
279+
fprintf(stderr, "register_all_ciphers err=%s\n", error_to_string(err));
280+
exit(EXIT_FAILURE);
281+
}
282+
if ((err = register_all_hashes()) != CRYPT_OK) {
283+
fprintf(stderr, "register_all_hashes err=%s\n", error_to_string(err));
284+
exit(EXIT_FAILURE);
285+
}
286+
if ((err = register_all_prngs()) != CRYPT_OK) {
287+
fprintf(stderr, "register_all_prngs err=%s\n", error_to_string(err));
288+
exit(EXIT_FAILURE);
289+
}
281290

282291
if ((err = rng_make_prng(128, find_prng("yarrow"), &yarrow_prng, NULL)) != CRYPT_OK) {
283292
fprintf(stderr, "rng_make_prng failed: %s\n", error_to_string(err));

0 commit comments

Comments
 (0)