+2016-08-05 Niels Möller <nisse@lysator.liu.se>
+
+ * examples/io.c (read_file): Use size_t for sizes, and uint8_t for
+ the contents.
+
2016-08-04 Niels Möller <nisse@lysator.liu.se>
* dsa-sign.c (dsa_sign): Return failure if p is even, so that an
}
}
-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");
for (buffer = NULL, done = 0;; size *= 2)
{
- char *p;
+ uint8_t *p;
if (max_size && size > max_size)
size = max_size;
simple_random(struct yarrow256_ctx *ctx, const char *name)
{
unsigned length;
- char *buffer;
+ uint8_t *buffer;
if (name)
length = read_file(name, 0, &buffer);
* 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);
struct rsa_private_key *priv)
{
unsigned length;
- char *buffer;
+ uint8_t *buffer;
int res;
length = read_file(name, 0, &buffer);
static int
read_signature(const char *name, mpz_t s)
{
- char *buffer;
+ uint8_t *buffer;
unsigned length;
int res;
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;