More method functions for elliptic curves,
[openssl.git] / crypto / ec / ec_cvt.c
index be06d3d92f9405f02a6c36431d59e40b13f60507..361dcc3992dd505f0c82e804230c40105899abe9 100644 (file)
@@ -1,4 +1,3 @@
-/* TODO */
 /* crypto/ec/ec_cvt.c */
 /* ====================================================================
  * Copyright (c) 1998-2001 The OpenSSL Project.  All rights reserved.
  */
 
 #include "ec_lcl.h"
+
+
+EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
+       {
+       const EC_METHOD *meth;
+       EC_GROUP *ret;
+       
+       /* Finally, this will use EC_GFp_nist_method if 'p' is a special
+        * prime with optimized modular arithmetics (for NIST curves)
+        * and EC_GFp_mont_method or EC_GFp_recp_method otherwise. */
+       meth = EC_GFp_simple_method();
+       
+       ret = EC_GROUP_new(meth);
+       if (ret == NULL)
+               return NULL;
+
+       if (!EC_GROUP_set_curve_GFp(ret, p, a, b, ctx))
+               {
+               EC_GROUP_clear_free(ret);
+               return NULL;
+               }
+
+       return ret;
+       }