Annotation of researchv10no/cmd/sign/xs.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <string.h>
        !             3: 
        !             4: char *xs();
        !             5: unsigned long xsum();
        !             6: 
        !             7: 
        !             8: char *
        !             9: xs(key,body,n)
        !            10: char *key, *body;
        !            11: {
        !            12:        unsigned long t;
        !            13:        unsigned int x[2];
        !            14:        static char s[17];
        !            15:        char key2[8];
        !            16:        int i;
        !            17: 
        !            18:        strncpy(key2,key,8);
        !            19:        sprintf(s, "%d", n);
        !            20:        xinit();
        !            21:        xstring(s, strlen(s));
        !            22:        xstring("$$$",3);
        !            23:        xstring(key2,8);
        !            24:        xstring(body,n);
        !            25:        xstring("$$$",3);
        !            26:        xstring(body,n);
        !            27:        xstring(key2,8);
        !            28:        xstring("omega",5);
        !            29: 
        !            30:        t = xsum();
        !            31:        x[0] = t & 0xffff;
        !            32:        x[1] = (t>>16) & 0xffff;
        !            33: 
        !            34:        sprintf(s, "%4x%4x", x[0], x[1]);
        !            35:        xstring("digamma",7);
        !            36:        t = xsum();
        !            37:        x[0] ^= t & 0xffff;
        !            38:        x[1] ^= (t>>16) & 0xffff;
        !            39:        sprintf(s+8, "%4x%4x", x[0], x[1]);
        !            40:        for(i=0; i<16; i++) if(s[i]==' ') s[i] = '0';
        !            41:        return s;
        !            42: }
        !            43: 
        !            44: #define SRLEN 5
        !            45: 
        !            46: static unsigned long sr[SRLEN], *sa, *sb;
        !            47: 
        !            48: xinit()
        !            49: {
        !            50:        int i;
        !            51:        for(i=0; i<SRLEN; i++) sr[i] = 0;
        !            52:        sa = &sr[0];
        !            53:        sb = &sr[1];
        !            54: }
        !            55: 
        !            56: unsigned long xsum() {
        !            57:        return *sa ^ *sb;
        !            58: }
        !            59: 
        !            60: xstring(s,n)
        !            61: register char *s;
        !            62: {
        !            63:        while(n-->0)
        !            64:                xcrank(*s++);
        !            65: }
        !            66: 
        !            67: unsigned long
        !            68: phi(x)
        !            69: register unsigned long x;
        !            70: {
        !            71:        do {
        !            72:                x += 14921776 + x*(17761492 + x);
        !            73:                x ^= 0x5827066;
        !            74:                x += 0x2c357 + x*(10661688 ^ x);
        !            75:                x ^= x>>16;
        !            76:        } while((x&0x80000002) == 2);
        !            77:        return x;
        !            78: }
        !            79: 
        !            80: xcrank(x)
        !            81: register x;
        !            82: {
        !            83:        *sb++ += phi((x&0xff) + *sa++);
        !            84:        if(sa >= &sr[SRLEN]) sa = &sr[0];
        !            85:        if(sb >= &sr[SRLEN]) sb = &sr[0];
        !            86: }

unix.superglobalmegacorp.com

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