summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2016-08-05 10:42:24 +0200
committerNiels Möller <nisse@lysator.liu.se>2016-08-05 10:42:24 +0200
commit748e2c549b93834c0fb03f9f8d11ec45a3459e31 (patch)
treee66d4063b655dc3e4a41df6d4f74706903fe1445 /examples
parent544b4047de689519ab3e6ec55b776b95b3e264a9 (diff)
downloadnettle-748e2c549b93834c0fb03f9f8d11ec45a3459e31.tar.gz
Helper read_file: Use size_t for sizes, and uint8_t for the contents.
Diffstat (limited to 'examples')
-rw-r--r--examples/io.c12
-rw-r--r--examples/io.h4
-rw-r--r--examples/read_rsa_key.c2
-rw-r--r--examples/rsa-verify.c4
4 files changed, 11 insertions, 11 deletions
diff --git a/examples/io.c b/examples/io.c
index 52fc54e2..7651cedc 100644
--- a/examples/io.c
+++ b/examples/io.c
@@ -74,11 +74,11 @@ werror(const char *format, ...)
}
}
-unsigned
-read_file(const char *name, unsigned max_size, char **contents)
+size_t
+read_file(const char *name, size_t max_size, uint8_t **contents)
{
- unsigned size, done;
- char *buffer;
+ size_t size, done;
+ uint8_t *buffer;
FILE *f;
f = fopen(name, "rb");
@@ -92,7 +92,7 @@ read_file(const char *name, unsigned max_size, char **contents)
for (buffer = NULL, done = 0;; size *= 2)
{
- char *p;
+ uint8_t *p;
if (max_size && size > max_size)
size = max_size;
@@ -167,7 +167,7 @@ int
simple_random(struct yarrow256_ctx *ctx, const char *name)
{
unsigned length;
- char *buffer;
+ uint8_t *buffer;
if (name)
length = read_file(name, 0, &buffer);
diff --git a/examples/io.h b/examples/io.h
index 6d4e4611..e4bb1cf7 100644
--- a/examples/io.h
+++ b/examples/io.h
@@ -52,8 +52,8 @@ werror(const char *format, ...) PRINTF_STYLE(1, 2);
* treated as an error; return value is zero, and no space is
* allocated. The returned data is NUL-terminated, for convenience. */
-unsigned
-read_file(const char *name, unsigned size, char **buffer);
+size_t
+read_file(const char *name, size_t size, uint8_t **buffer);
int
write_file(const char *name, unsigned size, const char *buffer);
diff --git a/examples/read_rsa_key.c b/examples/read_rsa_key.c
index 4647d686..f225666b 100644
--- a/examples/read_rsa_key.c
+++ b/examples/read_rsa_key.c
@@ -47,7 +47,7 @@ read_rsa_key(const char *name,
struct rsa_private_key *priv)
{
unsigned length;
- char *buffer;
+ uint8_t *buffer;
int res;
length = read_file(name, 0, &buffer);
diff --git a/examples/rsa-verify.c b/examples/rsa-verify.c
index f612c6de..297903e2 100644
--- a/examples/rsa-verify.c
+++ b/examples/rsa-verify.c
@@ -44,7 +44,7 @@
static int
read_signature(const char *name, mpz_t s)
{
- char *buffer;
+ uint8_t *buffer;
unsigned length;
int res;
@@ -52,7 +52,7 @@ read_signature(const char *name, mpz_t s)
if (!length)
return 0;
- res = (mpz_set_str(s, buffer, 16) == 0);
+ res = (mpz_set_str(s, (const char *) buffer, 16) == 0);
free(buffer);
return res;