Commit 96f1348e authored by Niels Möller's avatar Niels Möller

Rename write_string --> write_date.

Change type of input data to const void *, for this function and
write_file.
parent 3f4c5318
2016-08-16 Niels Möller <nisse@lysator.liu.se>
* examples/io.c (write_data): Renamed, and use const void * for
the input data. Updated all callers.
(write_string): ... old name.
(write_file): Use const void * for the input data.
2016-08-05 Niels Möller <nisse@lysator.liu.se>
* examples/hogweed-benchmark.c: Use uint8_t for curve25519 values.
......
......@@ -93,7 +93,7 @@ main(int argc UNUSED, char **argv UNUSED)
return EXIT_FAILURE;
}
if (!write_string (stdout, decoded_bytes, result))
if (!write_data (stdout, decoded_bytes, result))
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
......
......@@ -88,7 +88,7 @@ main(int argc UNUSED, char **argv UNUSED)
werror ("Error reading file: %s\n", strerror(errno));
return EXIT_FAILURE;
}
if (!write_string (stdout, encoded_bytes, result)
if (!write_data (stdout, encoded_bytes, result)
|| fflush (stdout) != 0)
{
werror ("Error writing file: %s\n", strerror(errno));
......@@ -97,7 +97,7 @@ main(int argc UNUSED, char **argv UNUSED)
return EXIT_SUCCESS;
}
/* The result vector is printed */
if (!write_string(stdout,encoded_bytes, result))
if (!write_data(stdout, encoded_bytes, result))
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
......
......@@ -93,7 +93,7 @@ main(int argc UNUSED, char **argv UNUSED)
return EXIT_FAILURE;
}
if (!write_string (stdout, decoded_bytes, result))
if (!write_data (stdout, decoded_bytes, result))
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
......
......@@ -90,7 +90,7 @@ main(int argc UNUSED, char **argv UNUSED)
encoded_bytes += base64_encode_final(&b64_ctx,result + encoded_bytes);
result[encoded_bytes++] = '\n';
if (!write_string (stdout, encoded_bytes, result)
if (!write_data (stdout, encoded_bytes, result)
|| fflush (stdout) != 0)
{
werror ("Error writing file: %s\n", strerror(errno));
......@@ -101,7 +101,7 @@ main(int argc UNUSED, char **argv UNUSED)
/* The result vector is written */
result[encoded_bytes++] = '\n';
if (!write_string (stdout, encoded_bytes, result))
if (!write_data (stdout, encoded_bytes, result))
{
werror ("Error writing file: %s\n", strerror(errno));
return EXIT_FAILURE;
......
......@@ -143,7 +143,7 @@ read_file(const char *name, size_t max_size, uint8_t **contents)
}
int
write_string(FILE *f, unsigned size, const char *buffer)
write_data(FILE *f, size_t size, const void *buffer)
{
size_t res = fwrite(buffer, 1, size, f);
......@@ -151,7 +151,7 @@ write_string(FILE *f, unsigned size, const char *buffer)
}
int
write_file(const char *name, unsigned size, const char *buffer)
write_file(const char *name, size_t size, const void *buffer)
{
FILE *f = fopen(name, "wb");
int res;
......@@ -159,7 +159,7 @@ write_file(const char *name, unsigned size, const char *buffer)
if (!f)
return 0;
res = write_string(f, size, buffer);
res = write_data(f, size, buffer);
return fclose(f) == 0 && res;
}
......
......@@ -56,10 +56,10 @@ size_t
read_file(const char *name, size_t size, uint8_t **buffer);
int
write_file(const char *name, unsigned size, const char *buffer);
write_file(const char *name, size_t size, const void *data);
int
write_string(FILE *f, unsigned size, const char *buffer);
write_data(FILE *f, size_t size, const void *data);
int
simple_random(struct yarrow256_ctx *ctx, const char *name);
......
......@@ -159,7 +159,7 @@ process_file(struct rsa_session *ctx,
{
CBC_DECRYPT(&ctx->aes, aes_decrypt, size, buffer, buffer);
hmac_sha1_update(&ctx->hmac, size, buffer);
if (!write_string(out, size, buffer))
if (!write_data(out, size, buffer))
{
werror("Writing output failed: %s\n", strerror(errno));
return 0;
......@@ -182,7 +182,7 @@ process_file(struct rsa_session *ctx,
{
unsigned leftover = AES_BLOCK_SIZE - padding;
hmac_sha1_update(&ctx->hmac, leftover, buffer);
if (!write_string(out, leftover, buffer))
if (!write_data(out, leftover, buffer))
{
werror("Writing output failed: %s\n", strerror(errno));
return 0;
......
......@@ -74,7 +74,7 @@ write_uint32(FILE *f, uint32_t n)
uint8_t buffer[4];
WRITE_UINT32(buffer, n);
return write_string(f, sizeof(buffer), buffer);
return write_data(f, sizeof(buffer), buffer);
}
static int
......@@ -96,7 +96,7 @@ write_bignum(FILE *f, mpz_t x)
p = xalloc(size);
nettle_mpz_get_str_256(size, p, x);
res = write_string(f, size, p);
res = write_data(f, size, p);
free(p);
return res;
}
......@@ -143,7 +143,7 @@ process_file(struct rsa_session *ctx,
hmac_sha1_digest(&ctx->hmac, SHA1_DIGEST_SIZE, buffer + size);
size += SHA1_DIGEST_SIZE;
if (!write_string(out, size, buffer))
if (!write_data(out, size, buffer))
{
werror("Writing output failed: %s\n", strerror(errno));
return 0;
......@@ -152,7 +152,7 @@ process_file(struct rsa_session *ctx,
}
CBC_ENCRYPT(&ctx->aes, aes_encrypt, size, buffer, buffer);
if (!write_string(out, size, buffer))
if (!write_data(out, size, buffer))
{
werror("Writing output failed: %s\n", strerror(errno));
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment