hashsum.1: Write some notes about compatibility with GNU Coreutils.
[u/mdw/catacomb] / group.h
diff --git a/group.h b/group.h
index 0e32de6..a144706 100644 (file)
--- a/group.h
+++ b/group.h
@@ -1,13 +1,13 @@
 /* -*-c-*-
  *
- * $Id: group.h,v 1.3 2004/04/04 19:04:11 mdw Exp $
+ * $Id$
  *
  * General cyclic group abstraction
  *
  * (c) 2004 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Catacomb.
  *
  * it under the terms of the GNU Library General Public License as
  * published by the Free Software Foundation; either version 2 of the
  * License, or (at your option) any later version.
- * 
+ *
  * Catacomb is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Library General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Library General Public
  * License along with Catacomb; if not, write to the Free
  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: group.h,v $
- * Revision 1.3  2004/04/04 19:04:11  mdw
- * Raw I/O of elliptic curve points and group elements.
- *
- * Revision 1.2  2004/04/03 03:32:05  mdw
- * General robustification.
- *
- * Revision 1.1  2004/04/01 12:50:09  mdw
- * Add cyclic group abstraction, with test code.  Separate off exponentation
- * functions for better static linking.  Fix a buttload of bugs on the way.
- * Generally ensure that negative exponents do inversion correctly.  Add
- * table of standard prime-field subgroups.  (Binary field subgroups are
- * currently unimplemented but easy to add if anyone ever finds a good one.)
- *
- */
-
 #ifndef CATACOMB_GROUP_H
 #define CATACOMB_GROUP_H
 
@@ -98,7 +80,11 @@ typedef struct group_expfactor {
 } group_expfactor;
 
 typedef struct group_ops {
+
+  /* --- General information --- */
+
   unsigned ty;                         /* Type of this group */
+  const char *name;                    /* Textual name string */
 
   /* --- Memory management --- */
 
@@ -140,7 +126,7 @@ typedef struct group_ops {
   mp *(*toint)(group */*g*/, mp */*d*/, ge */*x*/);
   int (*fromint)(group */*g*/, ge */*d*/, mp */*x*/);
   int (*toec)(group */*g*/, ec */*d*/, ge */*x*/);
-  int (*fromec)(group */*g*/, ge */*d*/, ec */*p*/);
+  int (*fromec)(group */*g*/, ge */*d*/, const ec */*p*/);
   int (*tobuf)(group */*h*/, buf */*b*/, ge */*x*/);
   int (*frombuf)(group */*h*/, buf */*b*/, ge */*d*/);
   int (*toraw)(group */*h*/, buf */*b*/, ge */*x*/);
@@ -154,6 +140,9 @@ enum {
   GTY_EC                               /* Elliptic curve group */
 };
 
+#define G_NAME(g)              (g)->ops->name
+#define G_TYPE(g)              (g)->ops->ty
+
 #define G_DESTROYGROUP(g)      (g)->ops->destroygroup((g))
 #define G_CREATE(g)            (g)->ops->create((g))
 #define G_COPY(g, d, x)                (g)->ops->copy((g), (d), (x))
@@ -323,7 +312,7 @@ extern int group_stdtoec(group */*g*/, ec */*d*/, ge */*x*/);
  *
  * Arguments:  @group *g@ = abstract group
  *             @ge *d@ = destination pointer
- *             @ec *p@ = elliptic curve point
+ *             @const ec *p@ = elliptic curve point
  *
  * Returns:    Zero for success, @-1@ on failure.
  *
@@ -331,7 +320,7 @@ extern int group_stdtoec(group */*g*/, ec */*d*/, ge */*x*/);
  *             coordinate.
  */
 
-extern int group_stdfromec(group */*g*/, ge */*d*/, ec */*p*/);
+extern int group_stdfromec(group */*g*/, ge */*d*/, const ec */*p*/);
 
 /*----- Prime field subgroups ---------------------------------------------*/
 
@@ -352,6 +341,22 @@ typedef struct gprime_param {
 
 group *group_prime(const gprime_param */*gp*/);
 
+/*----- Binary field subgroups --------------------------------------------*/
+
+typedef gprime_param gbin_param;
+
+/* --- @group_binary@ --- *
+ *
+ * Arguments:  @const gbin_param *gb@ = group parameters
+ *
+ * Returns:    A pointer to the group, or null.
+ *
+ * Use:                Constructs an abstract group interface for a subgroup of a
+ *             prime field.  Group elements are @mp *@ pointers.
+ */
+
+group *group_binary(const gbin_param */*gp*/);
+
 /*----- Elliptic curve groups ---------------------------------------------*/
 
 /* --- @group_ec@ --- *