Commit 9724eaee authored by Niels Möller's avatar Niels Möller

* rsa2sexp.c (rsa_keypair_to_sexp): New argument ALGORITHM_NAME.

* rsa2sexp.c (rsa_keypair_to_sexp): Use literals with sexp_format.

Rev: src/nettle/rsa.h:1.21
Rev: src/nettle/rsa2sexp.c:1.6
parent 2039f20a
......@@ -235,6 +235,7 @@ struct nettle_buffer;
/* Generates a public-key expression if PRIV is NULL .*/
int
rsa_keypair_to_sexp(struct nettle_buffer *buffer,
const char *algorithm_name, /* NULL means "rsa" */
const struct rsa_public_key *pub,
const struct rsa_private_key *priv);
......
......@@ -34,19 +34,23 @@
int
rsa_keypair_to_sexp(struct nettle_buffer *buffer,
const char *algorithm_name,
const struct rsa_public_key *pub,
const struct rsa_private_key *priv)
{
if (!algorithm_name)
algorithm_name = "rsa";
if (priv)
return sexp_format(buffer,
"(private-key(%0s(n%b)(e%b)"
"(d%b)(p%b)(q%b)(a%b)(b%b)(c%b)))",
"rsa", pub->n, pub->e,
algorithm_name, pub->n, pub->e,
priv->d, priv->p, priv->q,
priv->a, priv->b, priv->c);
else
return sexp_format(buffer, "(public-key(%0s(n%b)(e%b)))",
"rsa", pub->n, pub->e);
algorithm_name, pub->n, pub->e);
}
#endif /* WITH_PUBLIC_KEY */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment