]> git.lizzy.rs Git - plan9front.git/blobdiff - sys/include/mp.h
ssh: document thumbfile options
[plan9front.git] / sys / include / mp.h
index 31e4ef3d83b80915beafdfcacda05bd2fca22451..9aa8a4715e59d31c2754aa51209a7429111da7d9 100644 (file)
@@ -8,7 +8,6 @@
  * mpdigit must be an atomic type.  mpdigit is defined
  * in the architecture specific u.h
  */
-
 typedef struct mpint mpint;
 
 struct mpint
@@ -25,6 +24,7 @@ enum
        MPstatic=       0x01,   /* static constant */
        MPnorm=         0x02,   /* normalization status */
        MPtimesafe=     0x04,   /* request time invariant computation */
+       MPfield=        0x08,   /* this mpint is a field modulus */
 
        Dbytes=         sizeof(mpdigit),        /* bytes per digit */
        Dbits=          Dbytes*8                /* bits per digit */
@@ -84,6 +84,7 @@ void  mpnot(mpint *b, mpint *res);
 void   mpxor(mpint *b1, mpint *b2, mpint *res);
 void   mptrunc(mpint *b, int n, mpint *res);
 void   mpxtend(mpint *b, int n, mpint *res);
+void   mpasr(mpint *b, int shift, mpint *res);
 
 /* modular arithmetic, time invariant when 0≤b1≤m-1 and 0≤b2≤m-1 */
 void   mpmodadd(mpint *b1, mpint *b2, mpint *m, mpint *sum);   /* sum = b1+b2 % m */
@@ -165,5 +166,18 @@ void       crtout(CRTpre*, CRTres*, mpint*);       /* convert residues to mpint */
 void   crtprefree(CRTpre*);
 void   crtresfree(CRTres*);
 
+/* fast field arithmetic */
+typedef struct Mfield  Mfield;
+
+struct Mfield
+{
+       mpint;
+       int     (*reduce)(Mfield*, mpint*, mpint*);
+};
+
+mpint *mpfield(mpint*);
+
+Mfield *gmfield(mpint*);
+Mfield *cnfield(mpint*);
 
 #pragma        varargck        type    "B"     mpint*