diff options
author | Niels Möller <nisse@lysator.liu.se> | 2016-08-16 06:45:51 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2016-08-16 06:45:51 +0200 |
commit | 96f1348e81408eb140935778245ee6688497247e (patch) | |
tree | 414b9b4e5d81471a9c073c362e6f8de5f72fef6e /examples | |
parent | 3f4c531829284b0ac37b7645217f65d6994824bf (diff) | |
download | nettle-96f1348e81408eb140935778245ee6688497247e.tar.gz |
Rename write_string --> write_date.
Change type of input data to const void *, for this function and
write_file.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/base16dec.c | 2 | ||||
-rw-r--r-- | examples/base16enc.c | 4 | ||||
-rw-r--r-- | examples/base64dec.c | 2 | ||||
-rw-r--r-- | examples/base64enc.c | 4 | ||||
-rw-r--r-- | examples/io.c | 6 | ||||
-rw-r--r-- | examples/io.h | 4 | ||||
-rw-r--r-- | examples/rsa-decrypt.c | 4 | ||||
-rw-r--r-- | examples/rsa-encrypt.c | 8 |
8 files changed, 17 insertions, 17 deletions
diff --git a/examples/base16dec.c b/examples/base16dec.c index 8ab73740..70714567 100644 --- a/examples/base16dec.c +++ b/examples/base16dec.c @@ -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; diff --git a/examples/base16enc.c b/examples/base16enc.c index 3752df9e..02e4f280 100644 --- a/examples/base16enc.c +++ b/examples/base16enc.c @@ -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; diff --git a/examples/base64dec.c b/examples/base64dec.c index 1d339a16..624de628 100644 --- a/examples/base64dec.c +++ b/examples/base64dec.c @@ -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; diff --git a/examples/base64enc.c b/examples/base64enc.c index 6be5ad45..f8ba829b 100644 --- a/examples/base64enc.c +++ b/examples/base64enc.c @@ -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; diff --git a/examples/io.c b/examples/io.c index 7651cedc..408869e1 100644 --- a/examples/io.c +++ b/examples/io.c @@ -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; } diff --git a/examples/io.h b/examples/io.h index e4bb1cf7..426cb30c 100644 --- a/examples/io.h +++ b/examples/io.h @@ -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); diff --git a/examples/rsa-decrypt.c b/examples/rsa-decrypt.c index 8a14161a..01688218 100644 --- a/examples/rsa-decrypt.c +++ b/examples/rsa-decrypt.c @@ -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; diff --git a/examples/rsa-encrypt.c b/examples/rsa-encrypt.c index 665a7676..91061255 100644 --- a/examples/rsa-encrypt.c +++ b/examples/rsa-encrypt.c @@ -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; |