add support for elliptic curves over binary fields
[openssl.git] / crypto / ec / ec_cvt.c
index 3daeb19509e43078e13704260295b13ddd6a76f7..01453a283c711e88c92c2e14edaed455d577383b 100644 (file)
  * Hudson (tjh@cryptsoft.com).
  *
  */
+/* ====================================================================
+ * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
+ *
+ * Portions of the attached software ("Contribution") are developed by 
+ * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
+ *
+ * The Contribution is licensed pursuant to the OpenSSL open source
+ * license provided above.
+ *
+ * In addition, Sun covenants to all licensees who provide a reciprocal
+ * covenant with respect to their own patents if any, not to sue under
+ * current and future patent claims necessarily infringed by the making,
+ * using, practicing, selling, offering for sale and/or otherwise
+ * disposing of the Contribution as delivered hereunder 
+ * (or portions thereof), provided that such covenant shall not apply:
+ *  1) for code that a licensee deletes from the Contribution;
+ *  2) separates from the Contribution; or
+ *  3) for infringements caused by:
+ *       i) the modification of the Contribution or
+ *      ii) the combination of the Contribution with other software or
+ *          devices where such combination causes the infringement.
+ *
+ * The elliptic curve binary polynomial software is originally written by
+ * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
+ *
+ */
 
 #include "ec_lcl.h"
 
@@ -78,3 +104,23 @@ EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, const BIGNUM
 
        return ret;
        }
+
+EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
+       {
+       const EC_METHOD *meth;
+       EC_GROUP *ret;
+       
+       meth = EC_GF2m_simple_method();
+       
+       ret = EC_GROUP_new(meth);
+       if (ret == NULL)
+               return NULL;
+
+       if (!EC_GROUP_set_curve_GF2m(ret, p, a, b, ctx))
+               {
+               EC_GROUP_clear_free(ret);
+               return NULL;
+               }
+
+       return ret;
+       }