Add an ecdsa_genkey() function
diff --git a/include/polarssl/ecdsa.h b/include/polarssl/ecdsa.h
index 6dcb283..cd1987e 100644
--- a/include/polarssl/ecdsa.h
+++ b/include/polarssl/ecdsa.h
@@ -126,6 +126,20 @@
                           const unsigned char *sig, size_t slen );
 
 /**
+ * \brief           Generate an ECDSA keypair on the given curve
+ *
+ * \param ctx       ECDSA context in which the keypair should be stored
+ * \param grp       Group (elliptic curve) to use. One of the various
+ *                  POLARSSL_ECP_DP_XXX macros depending on configuration.
+ * \param f_rng     RNG function
+ * \param p_rng     RNG parameter
+ *
+ * \return          0 on success, or a POLARSSL_ERR_ECP code.
+ */
+int ecdsa_genkey( ecdsa_context *ctx, ecp_group_id gid,
+                  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng );
+
+/**
  * \brief           Initialize context
  *
  * \param ctx       Context to initialize
diff --git a/library/ecdsa.c b/library/ecdsa.c
index cf5355c..6746233 100644
--- a/library/ecdsa.c
+++ b/library/ecdsa.c
@@ -274,6 +274,17 @@
 }
 
 /*
+ * Generate key pair
+ */
+int ecdsa_genkey( ecdsa_context *ctx, ecp_group_id gid,
+                  int (*f_rng)(void *, unsigned char *, size_t), void *p_rng )
+{
+    return( ecp_use_known_dp( &ctx->grp, gid ) ||
+            ecp_gen_keypair( &ctx->grp, &ctx->d, &ctx->Q, f_rng, p_rng ) );
+}
+
+
+/*
  * Initialize context
  */
 void ecdsa_init( ecdsa_context *ctx )
diff --git a/tests/suites/test_suite_ecdsa.function b/tests/suites/test_suite_ecdsa.function
index 46dd1b3..b4d6ffd 100644
--- a/tests/suites/test_suite_ecdsa.function
+++ b/tests/suites/test_suite_ecdsa.function
@@ -95,9 +95,7 @@
     TEST_ASSERT( rnd_pseudo_rand( &rnd_info, hash, sizeof( hash ) ) == 0 );
 
     /* generate signing key */
-    TEST_ASSERT( ecp_use_known_dp( &ctx.grp, id ) == 0 );
-    TEST_ASSERT( ecp_gen_keypair( &ctx.grp, &ctx.d, &ctx.Q,
-                                  &rnd_pseudo_rand, &rnd_info ) == 0 );
+    TEST_ASSERT( ecdsa_genkey( &ctx, id, &rnd_pseudo_rand, &rnd_info ) == 0 );
 
     /* generate and write signature, then read and verify it */
     TEST_ASSERT( ecdsa_write_signature( &ctx, hash, sizeof( hash ),