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.
/** AES block size in bytes. */
#define AES_CRT128_BLOCK_SIZE 16
/** 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);
size_t *decoded_size);
int check_private_key_file(const char *file);
*
* \sa \ref uudecode().
*/
*
* \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;
size_t *decoded_size)
{
int ret, ret2;
/** Private keys end with this footer. */
#define PRIVATE_KEY_FOOTER "-----END RSA PRIVATE KEY-----"
/** 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;
size_t *blob_size)
{
int ret, ret2, i, j;
struct asymmetric_key *key;
*result = NULL;
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;
if (ret < 0)
return ret;
end = blob + blob_size;
struct asymmetric_key *key;
unsigned bits;
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;
if (ret < 0)
return ret;
p = blob + ret;
int ret;
struct asymmetric_key *key = para_malloc(sizeof(*key));
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);
if (ret < 0)
goto out;
ret = read_rsa_bignums(blob + ret, decoded_size - ret, &key->rsa);