Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Marcus Hoffmann
nettle
Commits
fe1e5101
Commit
fe1e5101
authored
Oct 30, 2001
by
Niels Möller
Browse files
New file.
Rev: src/nettle/testsuite/bignum-test.m4:1.1
parent
823a4558
Changes
1
Hide whitespace changes
Inline
Side-by-side
testsuite/bignum-test.m4
0 → 100644
View file @
fe1e5101
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if HAVE_LIBGMP
#include "bignum.h"
#include <stdlib.h>
#include <string.h>
static void
test_bignum(const char *hex, unsigned length, const uint8_t *base256)
{
mpz_t a;
mpz_t b;
uint8_t *buf;
mpz_init_set_str(a, hex, 16);
nettle_mpz_init_set_str_256(b, length, base256);
if (mpz_cmp(a, b))
FAIL;
buf = alloca(length + 1);
memset(buf, 17, length + 1);
nettle_mpz_get_str_256(length, buf, a);
if (!MEMEQ(length, buf, base256))
FAIL;
if (buf[length] != 17)
FAIL;
mpz_clear(a); mpz_clear(b);
}
#endif /* HAVE_LIBGMP */
BEGIN_TEST
#if HAVE_LIBGMP
test_bignum("0", 0, "");
test_bignum("010203040506", 7, H("00010203040506"));
#else /* !HAVE_LIBGMP */
SKIP
#endif /* !HAVE_LIBGMP */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment