diff options
| author | Mattias Andrée <m@maandree.se> | 2026-09-24 22:05:24 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-09-24 22:05:24 +0200 |
| commit | c3e107fe175a147e8f0108453650c1ba3735c9fe (patch) | |
| tree | 9d4bceb9e262c4fdc03e86d6581ed6f75d3a0746 /librecrypt_base64_len_to_raw_len_.c | |
| parent | Internal documentation (diff) | |
| download | librecrypt-c3e107fe175a147e8f0108453650c1ba3735c9fe.tar.gz librecrypt-c3e107fe175a147e8f0108453650c1ba3735c9fe.tar.bz2 librecrypt-c3e107fe175a147e8f0108453650c1ba3735c9fe.tar.xz | |
Code simplification and removal of random number salt generation where only resulting crypt string size was intended to be measured
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'librecrypt_base64_len_to_raw_len_.c')
| -rw-r--r-- | librecrypt_base64_len_to_raw_len_.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/librecrypt_base64_len_to_raw_len_.c b/librecrypt_base64_len_to_raw_len_.c new file mode 100644 index 0000000..a540278 --- /dev/null +++ b/librecrypt_base64_len_to_raw_len_.c @@ -0,0 +1,49 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" +#ifndef TEST + + +extern inline int librecrypt_base64_len_to_raw_len_(size_t ascii_len, size_t *raw_len_out); + + +#else + + +#define CHECK_GOOD(IN, OUT)\ + do {\ + size_t out = SIZE_MAX;\ + assert(librecrypt_base64_len_to_raw_len_((IN), &out) == 1);\ + assert(out == (OUT));\ + } while (0) + + +#define CHECK_BAD(IN)\ + do {\ + size_t out;\ + assert(librecrypt_base64_len_to_raw_len_((IN), &out) == 0);\ + } while (0) + + +int +main(void) +{ + size_t i, in_off = 0u, out_off = 0u; + + SET_UP_ALARM(); + INIT_RESOURCE_TEST(); + + for (i = 0u; i < 8u; i++) { + CHECK_GOOD(in_off + 0u, out_off + 0u); + CHECK_BAD(in_off + 1u); + CHECK_GOOD(in_off + 2u, out_off + 1u); + CHECK_GOOD(in_off + 3u, out_off + 2u); + in_off += 4u; + out_off += 3u; + } + + STOP_RESOURCE_TEST(); + return 0; +} + + +#endif |
