X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/02d7884df1f33c9c7dc3a14c4b1a5f520ebe090a..c65df27983057ec76ed0e72bb370f9a5ae7dad28:/group.h diff --git a/group.h b/group.h index d099a8f..9578f33 100644 --- a/group.h +++ b/group.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: group.h,v 1.2 2004/04/03 03:32:05 mdw Exp $ + * $Id: group.h,v 1.5 2004/04/17 09:58:37 mdw Exp $ * * General cyclic group abstraction * @@ -27,21 +27,6 @@ * MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: group.h,v $ - * 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 @@ -82,7 +67,7 @@ typedef struct group_ { const struct group_ops *ops; /* Operations table */ size_t nbits; /* Size of an element in bits */ - size_t noctets; /* Size of an element in octets */ + size_t noctets; /* Size of raw element in octets */ ge *i; /* Identity element */ ge *g; /* Generator element */ mp *r; /* Order of the generator */ @@ -137,9 +122,11 @@ 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*/); + int (*fromraw)(group */*h*/, buf */*b*/, ge */*d*/); } group_ops; @@ -177,6 +164,8 @@ enum { #define G_FROMEC(g, d, p) (g)->ops->fromec((g), (d), (p)) #define G_TOBUF(g, b, x) (g)->ops->tobuf((g), (b), (x)) #define G_FROMBUF(g, b, d) (g)->ops->frombuf((g), (b), (d)) +#define G_TORAW(g, b, x) (g)->ops->toraw((g), (b), (x)) +#define G_FROMRAW(g, b, d) (g)->ops->fromraw((g), (b), (d)) /*----- Handy functions ---------------------------------------------------*/ @@ -316,7 +305,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. * @@ -324,7 +313,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 ---------------------------------------------*/