mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-30 11:28:21 +00:00
test_check: Add Base32 lowercase RFC4648 tests
This commit is contained in:
parent
a07a89a421
commit
3806c6fcd3
28
test_check.c
28
test_check.c
@ -504,23 +504,25 @@ END_TEST
|
|||||||
START_TEST(test_base32_rfc4648)
|
START_TEST(test_base32_rfc4648)
|
||||||
{
|
{
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *input;
|
const char *decoded;
|
||||||
const char *output;
|
const char *encoded;
|
||||||
|
const char *encoded_lowercase;
|
||||||
} tests[] = {
|
} tests[] = {
|
||||||
{ "", "" },
|
{ "", "", ""},
|
||||||
{ "f", "MY" },
|
{ "f", "MY", "my" },
|
||||||
{ "fo", "MZXQ" },
|
{ "fo", "MZXQ", "mzxq" },
|
||||||
{ "foo", "MZXW6" },
|
{ "foo", "MZXW6", "mzxw6" },
|
||||||
{ "foob", "MZXW6YQ" },
|
{ "foob", "MZXW6YQ", "mzxw6yq" },
|
||||||
{ "fooba", "MZXW6YTB" },
|
{ "fooba", "MZXW6YTB", "mzxw6ytb" },
|
||||||
{ "foobar", "MZXW6YTBOI" },
|
{ "foobar", "MZXW6YTBOI", "mzxw6ytboi" },
|
||||||
};
|
};
|
||||||
|
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
|
|
||||||
for (size_t i = 0; i < (sizeof(tests) / sizeof(*tests)); i++) {
|
for (size_t i = 0; i < (sizeof(tests) / sizeof(*tests)); i++) {
|
||||||
const char *in = tests[i].input;
|
const char *in = tests[i].decoded;
|
||||||
const char *out = tests[i].output;
|
const char *out = tests[i].encoded;
|
||||||
|
const char *out_lowercase = tests[i].encoded_lowercase;
|
||||||
|
|
||||||
size_t inlen = strlen(in);
|
size_t inlen = strlen(in);
|
||||||
size_t outlen = strlen(out);
|
size_t outlen = strlen(out);
|
||||||
@ -533,7 +535,11 @@ START_TEST(test_base32_rfc4648)
|
|||||||
|
|
||||||
char *ret = (char *) base32_decode(out, outlen, (uint8_t *) buffer, sizeof(buffer), BASE32_ALPHABET_RFC4648);
|
char *ret = (char *) base32_decode(out, outlen, (uint8_t *) buffer, sizeof(buffer), BASE32_ALPHABET_RFC4648);
|
||||||
ck_assert(ret != NULL);
|
ck_assert(ret != NULL);
|
||||||
|
*ret = '\0';
|
||||||
|
ck_assert_str_eq(buffer, in);
|
||||||
|
|
||||||
|
ret = (char *) base32_decode(out_lowercase, outlen, (uint8_t *) buffer, sizeof(buffer), BASE32_ALPHABET_RFC4648);
|
||||||
|
ck_assert(ret != NULL);
|
||||||
*ret = '\0';
|
*ret = '\0';
|
||||||
ck_assert_str_eq(buffer, in);
|
ck_assert_str_eq(buffer, in);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user