return bnsize + 4;
}
-static int read_public_key(const unsigned char *blob, int blen, RSA **result)
+static int read_public_key(const unsigned char *blob, int blen,
+ struct asymmetric_key *result)
{
int ret;
RSA *rsa;
rsa->n = n;
rsa->e = e;
#endif
- *result = rsa;
+ result->rsa = rsa;
return 1;
free_e:
BN_free(e);
return ret;
}
-static int read_pem_private_key(const char *path, RSA **rsa)
+static int read_pem_private_key(const char *path, struct asymmetric_key *priv)
{
EVP_PKEY *pkey;
BIO *bio = BIO_new(BIO_s_file());
- *rsa = NULL;
+ priv->rsa = NULL;
if (!bio)
return -E_PRIVATE_KEY;
if (BIO_read_filename(bio, path) <= 0)
pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, NULL);
if (!pkey)
goto bio_free;
- *rsa = EVP_PKEY_get1_RSA(pkey);
+ priv->rsa = EVP_PKEY_get1_RSA(pkey);
EVP_PKEY_free(pkey);
bio_free:
BIO_free(bio);
- return *rsa? RSA_size(*rsa) : -E_PRIVATE_KEY;
+ return priv->rsa? RSA_size(priv->rsa) : -E_PRIVATE_KEY;
}
static int read_openssh_private_key(const unsigned char *blob,
- const unsigned char *end, RSA **result)
+ const unsigned char *end, struct asymmetric_key *priv)
{
int ret;
RSA *rsa;
rsa->p = p;
rsa->q = q;
#endif
- *result = rsa;
+ priv->rsa = rsa;
return 1;
free_p:
BN_clear_free(p);
return ret;
}
-static int get_private_key(const char *path, RSA **rsa)
+static int get_private_key(const char *path, struct asymmetric_key *priv)
{
int ret;
unsigned char *blob, *end;
size_t blob_size;
- *rsa = NULL;
+ priv->rsa = NULL;
ret = decode_private_key(path, &blob, &blob_size);
if (ret < 0)
return ret;
if (ret < 0)
goto free_blob;
PARA_INFO_LOG("reading RSA params at offset %d\n", ret);
- ret = read_openssh_private_key(blob + ret, end, rsa);
+ ret = read_openssh_private_key(blob + ret, end, priv);
} else
- ret = read_pem_private_key(path, rsa);
+ ret = read_pem_private_key(path, priv);
free_blob:
free(blob);
return ret;
ret = decode_public_key(key_file, &blob, &decoded_size);
if (ret < 0)
goto out;
- ret = read_public_key(blob + ret, decoded_size - ret, &pub->rsa);
+ ret = read_public_key(blob + ret, decoded_size - ret, pub);
if (ret < 0)
goto free_blob;
ret = RSA_size(pub->rsa);
if (inlen < 0)
return -E_RSA;
priv = alloc(sizeof(*priv));
- ret = get_private_key(key_file, &priv->rsa);
+ ret = get_private_key(key_file, priv);
if (ret < 0) {
free(priv);
return ret;