From 3e0533843c8d4add881a6c2d383bd2c80129e27b Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 28 Aug 2018 21:38:33 +0200 Subject: [PATCH] crypt: Rename decoding functions. decode_ssh_key() and decode_key() operate on public and private keys respectively. This should be obvious from the naming. Also, the two functions will soon be grouped together in the same file. The inconsistent naming would even increase the possible confusion, so it's better to rename the functions now. --- crypt_backend.h | 2 +- crypt_common.c | 2 +- gcrypt.c | 6 +++--- openssl.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crypt_backend.h b/crypt_backend.h index 175a6881..6f800875 100644 --- a/crypt_backend.h +++ b/crypt_backend.h @@ -7,6 +7,6 @@ /** AES block size in bytes. */ #define AES_CRT128_BLOCK_SIZE 16 -int decode_ssh_key(const char *filename, unsigned char **blob, +int decode_public_key(const char *filename, unsigned char **blob, size_t *decoded_size); int check_private_key_file(const char *file); diff --git a/crypt_common.c b/crypt_common.c index 235b8b8d..2b2e06c1 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -85,7 +85,7 @@ static int check_ssh_key_header(const unsigned char *blob, int blen) * * \sa \ref uudecode(). */ -int decode_ssh_key(const char *filename, unsigned char **blob, +int decode_public_key(const char *filename, unsigned char **blob, size_t *decoded_size) { int ret, ret2; diff --git a/gcrypt.c b/gcrypt.c index 5d151a3c..8431cc24 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -111,7 +111,7 @@ static const char *gcrypt_strerror(gcry_error_t gret) /** Private keys end with this footer. */ #define PRIVATE_KEY_FOOTER "-----END RSA PRIVATE KEY-----" -static int decode_key(const char *key_file, unsigned char **result, +static int decode_private_key(const char *key_file, unsigned char **result, size_t *blob_size) { int ret, ret2, i, j; @@ -368,7 +368,7 @@ static int get_private_key(const char *key_file, struct asymmetric_key **result) struct asymmetric_key *key; *result = NULL; - ret = decode_key(key_file, &blob, &blob_size); + ret = decode_private_key(key_file, &blob, &blob_size); if (ret < 0) return ret; end = blob + blob_size; @@ -426,7 +426,7 @@ int apc_get_pubkey(const char *key_file, struct asymmetric_key **result) struct asymmetric_key *key; unsigned bits; - ret = decode_ssh_key(key_file, &blob, &decoded_size); + ret = decode_public_key(key_file, &blob, &decoded_size); if (ret < 0) return ret; p = blob + ret; diff --git a/openssl.c b/openssl.c index 4895e176..a27e0ca3 100644 --- a/openssl.c +++ b/openssl.c @@ -151,7 +151,7 @@ int apc_get_pubkey(const char *key_file, struct asymmetric_key **result) int ret; struct asymmetric_key *key = para_malloc(sizeof(*key)); - ret = decode_ssh_key(key_file, &blob, &decoded_size); + ret = decode_public_key(key_file, &blob, &decoded_size); if (ret < 0) goto out; ret = read_rsa_bignums(blob + ret, decoded_size - ret, &key->rsa); -- 2.39.2