*
* @param buf the buffer where the private key data is stored
* @param len the length of the data in 'buffer'
+ * @return NULL on error
*/
struct GNUNET_CRYPTO_RsaPrivateKey *
GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len);
* @param cfg_name name of the configuration file to use
*/
void
-GNUNET_CRYPTO_setup_hostkey (const char *cfg_name);
+GNUNET_CRYPTO_rsa_setup_hostkey (const char *cfg_name);
/**
* @return some private key purely dependent on input
*/
struct GNUNET_CRYPTO_RsaPrivateKey *
-GNUNET_CRYPTO_rsa_key_create_from_hash (const struct GNUNET_HashCode * hc);
+GNUNET_CRYPTO_rsa_key_create_from_hash (const struct GNUNET_HashCode *hc);
/**
* Free memory occupied by the private key.
- * @param hostkey pointer to the memory to free
+ *
+ * @param key pointer to the memory to free
*/
void
-GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey);
+GNUNET_CRYPTO_rsa_key_free (struct GNUNET_CRYPTO_RsaPrivateKey *key);
/**
"Change $PATH ('.' in $PATH before $GNUNET_PREFIX/bin is problematic) or permissions (run 'make install' as root) to fix this!\n");
return 0;
}
- GNUNET_CRYPTO_setup_hostkey ("test_gnunet_vpn.conf");
+ GNUNET_CRYPTO_rsa_setup_hostkey ("test_gnunet_vpn.conf");
bin = argv[0];
if (NULL != strstr (bin, "lt-"))
bin = strstr (bin, "lt-") + 4;
*
* @param buf the buffer where the private key data is stored
* @param len the length of the data in 'buffer'
+ * @return NULL on error
*/
struct GNUNET_CRYPTO_RsaPrivateKey *
GNUNET_CRYPTO_rsa_decode_key (const char *buf, uint16_t len)
gcry_mpi_t u;
int rc;
size_t size;
- int pos;
+ size_t pos;
uint16_t enc_len;
+ size_t erroff;
enc_len = ntohs (encoding->len);
if (len != enc_len)
if ((NULL != p) && (NULL != q) && (NULL != u))
{
- rc = gcry_sexp_build (&res, &size, /* erroff */
+ rc = gcry_sexp_build (&res, &erroff,
"(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)(u %m)))",
n, e, d, p, q, u);
}
{
if ((NULL != p) && (NULL != q))
{
- rc = gcry_sexp_build (&res, &size, /* erroff */
+ rc = gcry_sexp_build (&res, &erroff,
"(private-key(rsa(n %m)(e %m)(d %m)(p %m)(q %m)))",
n, e, d, p, q);
}
else
{
- rc = gcry_sexp_build (&res, &size, /* erroff */
+ rc = gcry_sexp_build (&res, &erroff,
"(private-key(rsa(n %m)(e %m)(d %m)))", n, e, d);
}
}
if (0 != rc)
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_sexp_build", rc);
#if EXTRA_CHECKS
- if (gcry_pk_testkey (res))
+ if (0 != (rc = gcry_pk_testkey (res)))
{
LOG_GCRY (GNUNET_ERROR_TYPE_ERROR, "gcry_pk_testkey", rc);
return NULL;
* @param cfg_name name of the configuration file to use
*/
void
-GNUNET_CRYPTO_setup_hostkey (const char *cfg_name)
+GNUNET_CRYPTO_rsa_setup_hostkey (const char *cfg_name)
{
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_CRYPTO_RsaPrivateKey *pk;