diff --git a/rsa.h b/rsa.h
index 14a4c44b45ebfc231b9ae17bd2ef28b5e9c82e10..dd5005571629bf7712f9950c9a900acb7d2f5f6e 100644
--- a/rsa.h
+++ b/rsa.h
@@ -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);
 
diff --git a/rsa2sexp.c b/rsa2sexp.c
index 8957570d325ff3057ea4b6126e82760f4ecd233b..75f5645c75e01e3dfd0915ccde537110e6f471b8 100644
--- a/rsa2sexp.c
+++ b/rsa2sexp.c
@@ -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 */