Added ecp_use_known_dp()
diff --git a/include/polarssl/ecp.h b/include/polarssl/ecp.h
index 2bede2c..8763fc1 100644
--- a/include/polarssl/ecp.h
+++ b/include/polarssl/ecp.h
@@ -32,9 +32,9 @@
 /*
  * ECP error codes
  *
- * (The functions written up to now return MPI error codes only.)
+ * (Only one error code available...)
  */
-
+#define POLARSSL_ERR_ECP_GENERIC    -0x007E  /**<  Generic ECP error */
 
 /**
  * \brief           ECP point structure (affine coordinates)
@@ -75,6 +75,12 @@
  * parameters. Therefore, only well-known domain parameters from trusted
  * sources (such as the ones below) should be used.
  */
+#define POLARSSL_ECP_DP_SECP192R1   0
+#define POLARSSL_ECP_DP_SECP224R1   1
+#define POLARSSL_ECP_DP_SECP256R1   2
+#define POLARSSL_ECP_DP_SECP384R1   3
+#define POLARSSL_ECP_DP_SECP521R1   4
+
 #define POLARSSL_ECP_SECP192R1_P \
     "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF"
 #define POLARSSL_ECP_SECP192R1_B \
@@ -216,6 +222,20 @@
                            const char *gx, const char *gy, const char *n);
 
 /**
+ * \brief           Set a group using well-known domain parameters
+ *
+ * \param grp       Destination group
+ * \param index     Index in the list of well-known domain parameters
+ *
+ * \return          O if successul,
+ *                  POLARSSL_ERR_MPI_XXX if initialization failed
+ *                  POLARSSL_ERR_ECP_GENERIC if index is out of range
+ *
+ * \note            Index should be a POLARSSL_ECP_DP_XXX macro.
+ */
+int ecp_use_known_dp( ecp_group *grp, size_t index );
+
+/**
  * \brief           Addition: R = P + Q
  *
  * \param grp       ECP group
diff --git a/include/polarssl/error.h b/include/polarssl/error.h
index 96815a7..736e8a7 100644
--- a/include/polarssl/error.h
+++ b/include/polarssl/error.h
@@ -68,6 +68,7 @@
  * SHA2      1  0x0078-0x0078
  * SHA4      1  0x007A-0x007A
  * PBKDF2    1  0x007C-0x007C
+ * ECP       1  0x007E-0x007E
  *
  * High-level module nr (3 bits - 0x1...-0x8...)
  * Name     ID  Nr of Errors
diff --git a/library/ecp.c b/library/ecp.c
index db69e42..ee3d6bf 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -154,7 +154,57 @@
     return( ret );
 }
 
-#define dbg(X)  printf(#X " = %s%lu\n", X.s < 0 ? "-" : "", X.p[0])
+/*
+ * Set a group using well-known domain parameters
+ */
+int ecp_use_known_dp( ecp_group *grp, size_t index )
+{
+    switch( index )
+    {
+        case POLARSSL_ECP_DP_SECP192R1:
+            return( ecp_group_read_string( grp, 16,
+                        POLARSSL_ECP_SECP192R1_P,
+                        POLARSSL_ECP_SECP192R1_B,
+                        POLARSSL_ECP_SECP192R1_GX,
+                        POLARSSL_ECP_SECP192R1_GY,
+                        POLARSSL_ECP_SECP192R1_N )
+                    );
+        case POLARSSL_ECP_DP_SECP224R1:
+            return( ecp_group_read_string( grp, 16,
+                        POLARSSL_ECP_SECP224R1_P,
+                        POLARSSL_ECP_SECP224R1_B,
+                        POLARSSL_ECP_SECP224R1_GX,
+                        POLARSSL_ECP_SECP224R1_GY,
+                        POLARSSL_ECP_SECP224R1_N )
+                    );
+        case POLARSSL_ECP_DP_SECP256R1:
+            return( ecp_group_read_string( grp, 16,
+                        POLARSSL_ECP_SECP256R1_P,
+                        POLARSSL_ECP_SECP256R1_B,
+                        POLARSSL_ECP_SECP256R1_GX,
+                        POLARSSL_ECP_SECP256R1_GY,
+                        POLARSSL_ECP_SECP256R1_N )
+                    );
+        case POLARSSL_ECP_DP_SECP384R1:
+            return( ecp_group_read_string( grp, 16,
+                        POLARSSL_ECP_SECP384R1_P,
+                        POLARSSL_ECP_SECP384R1_B,
+                        POLARSSL_ECP_SECP384R1_GX,
+                        POLARSSL_ECP_SECP384R1_GY,
+                        POLARSSL_ECP_SECP384R1_N )
+                    );
+        case POLARSSL_ECP_DP_SECP521R1:
+            return( ecp_group_read_string( grp, 16,
+                        POLARSSL_ECP_SECP521R1_P,
+                        POLARSSL_ECP_SECP521R1_B,
+                        POLARSSL_ECP_SECP521R1_GX,
+                        POLARSSL_ECP_SECP521R1_GY,
+                        POLARSSL_ECP_SECP521R1_N )
+                    );
+    }
+
+    return( POLARSSL_ERR_ECP_GENERIC );
+}
 
 /*
  * Addition: R = P + Q, generic case (P != Q, P != 0, Q != 0, R != 0)
@@ -476,7 +526,7 @@
         }
     }
 
-    if (verbose != 0 )
+    if( verbose != 0 )
         printf( "passed\n" );
 
     MPI_CHK( ecp_copy( &mul_tbl[0], &O ) );
@@ -507,9 +557,21 @@
         }
     }
 
-    if (verbose != 0 )
+    if( verbose != 0 )
         printf( "passed\n" );
 
+    if( verbose != 0 )
+        printf( "  ECP test #3 (use_known_dp): " );
+
+    for( i = 0; i <= POLARSSL_ECP_DP_SECP521R1; i++ )
+    {
+        MPI_CHK( ecp_use_known_dp( &grp, i ) );
+    }
+
+    if( verbose != 0 )
+        printf( "passed\n" );
+
+
 cleanup:
 
     if( ret != 0 && verbose != 0 )