crypt: Rename decoding functions.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 28 Aug 2018 19:38:33 +0000 (21:38 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 25 Dec 2018 16:45:24 +0000 (17:45 +0100)
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
crypt_common.c
gcrypt.c
openssl.c

index 175a688..6f80087 100644 (file)
@@ -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);
index 235b8b8..2b2e06c 100644 (file)
@@ -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;
index 5d151a3..8431cc2 100644 (file)
--- 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;
index 4895e17..a27e0ca 100644 (file)
--- 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);