Annotation of 43BSDReno/usr.bin/xsend/common_source/lib.c, revision 1.1

1.1     ! root        1: #ifndef lint
        !             2: static char sccsid[] = "@(#)lib.c      4.2 5/11/89";
        !             3: #endif
        !             4: 
        !             5: #include "xmail.h"
        !             6: #include "pathnames.h"
        !             7: 
        !             8: MINT *x, *b, *one, *c64, *t45, *z, *q, *r, *two, *t15;
        !             9: MINT *a[42];
        !            10: setup(s) char *s;
        !            11: {      int pf[2];
        !            12:        strncpy(buf, s, 10);
        !            13:        while(*s) *s++ = 0;
        !            14:        pipe(pf);
        !            15:        if(fork()==0)
        !            16:        {
        !            17:                close(0);
        !            18:                close(1);
        !            19:                dup(pf[0]);
        !            20:                dup(pf[1]);
        !            21:                execl(_PATH_MAKEKEY, "-", 0);
        !            22:                exit(1);
        !            23:        }
        !            24:        write(pf[1], buf, 10);
        !            25:        wait((int *)NULL);
        !            26:        if(read(pf[0], buf, 13) != 13)
        !            27:        {       fprintf(stderr, "enroll: cannot generate key\n");
        !            28:                exit(1);
        !            29:        }
        !            30: }
        !            31: mkx()
        !            32: {      int i, j;
        !            33:        for(i=0; i<4; i++)
        !            34:        {       mult(x, t15, x);
        !            35:                *z->val = (short)(rand() ^ buf[i]);
        !            36:                madd(x, z, x);
        !            37:        }
        !            38:        mdiv(x, b, q, x);
        !            39:        for(;;)
        !            40:        {       gcd(b, x, q);
        !            41:                if(q->len == 1 && q->val[0] == 1)
        !            42:                        return;
        !            43:                madd(x, one, x);
        !            44:        }
        !            45: }
        !            46: mka()
        !            47: {      int i, j;
        !            48:        for(i=0; i<42; i++)
        !            49:                a[i] = itom(1);
        !            50:        for(i=j=0; i<42; i++, j++)
        !            51:        {       *z->val = (short)rand()&00;
        !            52:                mult(a[i], z, a[i]);
        !            53:                mult(a[i], t45, a[i]);
        !            54:                rpow(two, j, q);
        !            55:                if( i%14 == 6) j++;
        !            56:                madd(a[i], q, a[i]);
        !            57:                mult(a[i], t15, a[i]);
        !            58:                *z->val = (short)rand()&0777;
        !            59:                madd(a[i], z, a[i]);
        !            60:                mdiv(a[i], b, q, a[i]);
        !            61:        }
        !            62:        for(i=0; i<42; i++)
        !            63:                mult(a[i], x, a[i]);
        !            64:        for(i=0; i<42; i++)
        !            65:        {       mdiv(a[i], b, q, a[i]);
        !            66:        }
        !            67: }
        !            68: mkb()
        !            69: {      int i, c;
        !            70:        unsigned seed;
        !            71:        seed = 123;
        !            72:        for(i=0; i<13; i++)
        !            73:                seed = seed*buf[i] + i;
        !            74:        srand(seed);
        !            75:        *b->val = 04 + (rand()&03);
        !            76:        for(i=0; i<11; i++)
        !            77:        {       *z->val = (buf[i+2] + rand()) & 077;
        !            78:                mult(b, c64, b);
        !            79:                madd(b, z, b);
        !            80:        }
        !            81: }
        !            82: comminit()
        !            83: {      int i;
        !            84:        x = itom(0);
        !            85:        b = itom(1);
        !            86:        one = itom(1);
        !            87:        two = itom(2);
        !            88:        c64 = itom(64);
        !            89:        t45 = itom(1);
        !            90:        t15 = itom(1);
        !            91:        rpow(two, 45, t45);
        !            92:        rpow(two, 15, t15);
        !            93:        z = itom(1);
        !            94:        q = itom(1);
        !            95: }
        !            96: #ifndef debug
        !            97: nout(a, fd) MINT *a; FILE *fd;
        !            98: {
        !            99:        fwrite(&a->len, sizeof(int), 1, fd);
        !           100:        fwrite(a->val, sizeof(short), a->len, fd);
        !           101: }
        !           102: nin(a, fd) MINT *a; FILE *fd;
        !           103: {
        !           104:        xfree(a);
        !           105:        fread(&a->len, sizeof(int), 1, fd);
        !           106:        a->val = xalloc(a->len, "nin");
        !           107:        fread(a->val, sizeof(short), a->len, fd);
        !           108: }
        !           109: #endif
        !           110: xfatal(s) char *s;
        !           111: {
        !           112:        fprintf(stderr, "%s\n", s);
        !           113:        exit(1);
        !           114: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.