summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2017-10-23 22:25:58 +0200
committerNiels Möller <nisse@lysator.liu.se>2017-10-23 22:25:58 +0200
commit61460b2e8edda447a40fb1264cb1327114ea61d3 (patch)
tree206ba0138631e83f9cfdeab9f5458c286a71801d /tools
parent54e1450a0ebdd24cdf6234741e5275bb3d83ebda (diff)
parentf1366bc97b8cd93f4797ee42fcfafd5584d038df (diff)
downloadnettle-61460b2e8edda447a40fb1264cb1327114ea61d3.tar.gz
Merge remote-tracking branch 'origin/master' into api-opaque
Diffstat (limited to 'tools')
-rw-r--r--tools/input.c2
-rw-r--r--tools/nettle-hash.c6
-rw-r--r--tools/nettle-pbkdf2.c8
-rw-r--r--tools/output.c6
-rw-r--r--tools/pkcs1-conv.c13
5 files changed, 21 insertions, 14 deletions
diff --git a/tools/input.c b/tools/input.c
index 18a9dff5..90e41a29 100644
--- a/tools/input.c
+++ b/tools/input.c
@@ -90,7 +90,7 @@ sexp_get_char(struct sexp_input *input)
* character at a time. */
if (!input->coding->decode_update(&input->state,
&done, &input->c,
- 1, &input->c))
+ 1, (const char*) &input->c))
die("Invalid coded data.\n");
if (done)
diff --git a/tools/nettle-hash.c b/tools/nettle-hash.c
index d7d4ce2e..24199921 100644
--- a/tools/nettle-hash.c
+++ b/tools/nettle-hash.c
@@ -53,11 +53,11 @@ list_algorithms (void)
{
unsigned i;
const struct nettle_hash *alg;
- printf ("%10s digestsize (internal block size), in units of octets\n", "name");
+ printf ("%10s digestsize (internal block size, context size), in units of octets\n", "name");
for (i = 0; (alg = nettle_hashes[i]); i++)
- printf ("%10s %d (%d)\n",
- alg->name, alg->digest_size, alg->block_size);
+ printf ("%10s %d (%d, %d)\n",
+ alg->name, alg->digest_size, alg->block_size, alg->context_size);
};
/* Also in examples/io.c */
diff --git a/tools/nettle-pbkdf2.c b/tools/nettle-pbkdf2.c
index c9e4d11c..1f0a3015 100644
--- a/tools/nettle-pbkdf2.c
+++ b/tools/nettle-pbkdf2.c
@@ -73,7 +73,7 @@ main (int argc, char **argv)
size_t password_length;
uint8_t *output;
size_t salt_length;
- uint8_t *salt;
+ char *salt;
int raw = 0;
int hex_salt = 0;
int c;
@@ -141,7 +141,7 @@ main (int argc, char **argv)
return EXIT_FAILURE;
}
- salt = (uint8_t *) strdup (argv[0]);
+ salt = strdup (argv[0]);
salt_length = strlen(argv[0]);
if (hex_salt)
@@ -150,7 +150,7 @@ main (int argc, char **argv)
base16_decode_init (&base16);
if (!base16_decode_update (&base16,
- &salt_length, salt,
+ &salt_length, (uint8_t *) salt,
salt_length, salt)
|| !base16_decode_final (&base16))
die ("Invalid salt (expecting hex encoding).\n");
@@ -165,7 +165,7 @@ main (int argc, char **argv)
output = xalloc (output_length);
pbkdf2_hmac_sha256 (password_length, (const uint8_t *) password,
- iterations, salt_length, salt,
+ iterations, salt_length, (const uint8_t*) salt,
output_length, output);
free (salt);
diff --git a/tools/output.c b/tools/output.c
index 02e43d58..80a44a97 100644
--- a/tools/output.c
+++ b/tools/output.c
@@ -114,7 +114,7 @@ sexp_put_char(struct sexp_output *output, uint8_t c)
if (output->coding)
{
/* Two is enough for both base16 and base64. */
- uint8_t encoded[2];
+ char encoded[2];
unsigned done;
unsigned i;
@@ -183,7 +183,7 @@ void
sexp_put_code_end(struct sexp_output *output)
{
/* Enough for both hex and base64 */
- uint8_t encoded[BASE64_ENCODE_FINAL_LENGTH];
+ char encoded[BASE64_ENCODE_FINAL_LENGTH];
unsigned done;
assert(output->coding);
@@ -194,7 +194,7 @@ sexp_put_code_end(struct sexp_output *output)
output->coding = NULL;
- sexp_put_data(output, done, encoded);
+ sexp_put_data(output, done, (const uint8_t*) encoded);
}
void
diff --git a/tools/pkcs1-conv.c b/tools/pkcs1-conv.c
index 9e346858..efd6528a 100644
--- a/tools/pkcs1-conv.c
+++ b/tools/pkcs1-conv.c
@@ -244,6 +244,14 @@ read_pem(struct nettle_buffer *buffer, FILE *f,
}
}
+static inline int
+base64_decode_in_place (struct base64_decode_ctx *ctx, size_t *dst_length,
+ size_t length, uint8_t *data)
+{
+ return base64_decode_update (ctx, dst_length,
+ data, length, (const char *) data);
+}
+
static int
decode_base64(struct nettle_buffer *buffer,
size_t start, size_t *length)
@@ -253,9 +261,8 @@ decode_base64(struct nettle_buffer *buffer,
base64_decode_init(&ctx);
/* Decode in place */
- if (base64_decode_update(&ctx,
- length, buffer->contents + start,
- *length, buffer->contents + start)
+ if (base64_decode_in_place(&ctx, length,
+ *length, buffer->contents + start)
&& base64_decode_final(&ctx))
return 1;