URI:
       teggen.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       teggen.c (413B)
       ---
            1 #include "os.h"
            2 #include <mp.h>
            3 #include <libsec.h>
            4 
            5 EGpriv*
            6 eggen(int nlen, int rounds)
            7 {
            8         EGpub *pub;
            9         EGpriv *priv;
           10 
           11         priv = egprivalloc();
           12         pub = &priv->pub;
           13         pub->p = mpnew(0);
           14         pub->alpha = mpnew(0);
           15         pub->key = mpnew(0);
           16         priv->secret = mpnew(0);
           17         gensafeprime(pub->p, pub->alpha, nlen, rounds);
           18         mprand(nlen-1, genrandom, priv->secret);
           19         mpexp(pub->alpha, priv->secret, pub->p, pub->key);
           20         return priv;
           21 }