Annotation of researchv10no/ipc/mgrs/oauthmgr/makekey.c, revision 1.1.1.1

1.1       root        1: /* makekey - make a key for the Atalla box.  Courtesy ftg. */
                      2: 
                      3: 
                      4: main(){
                      5:        int i, b;
                      6:        unsigned long key=0;
                      7: 
                      8:        srand((int)time((long *)0));
                      9: 
                     10:        printf("xxx:atalla:");
                     11: 
                     12:        for(i=0; i<8; i++) {
                     13:                printf("%.3o%s", b=nrand(256), i<7 ? " " : "");
                     14:                key = (key << 8) | b;
                     15:        }
                     16: 
                     17:        printf(":\n");
                     18: 
                     19:        /* printf("Check:  %u\n", key); */
                     20: }
                     21: 
                     22: #define        LENG    17
                     23: static
                     24: long   ary[LENG] =
                     25: {
                     26:        0x4B14EA50L,
                     27:        0x53C4A8E0L,
                     28:        0x67B1FA98L,
                     29:        0x9CFB3BB5L,
                     30:        0x18761AF1L,
                     31:        0x7970CD66L,
                     32:        0xDBAFE136L,
                     33:        0x3C31FC3EL,
                     34:        0x697B37DEL,
                     35:        0x07BC568BL,
                     36:        0xCAFD3967L,
                     37:        0xA8F48722L,
                     38:        0x4AB26824L,
                     39:        0xA479EE47L,
                     40:        0x5C7246E2L,
                     41:        0x954BF297L,
                     42:        0x20A713ADL,
                     43: };
                     44: static
                     45: int    i1 = 0;
                     46: static
                     47: int    i2 = 12;
                     48: 
                     49: srand(seed)
                     50: {
                     51:        register i, j;
                     52: 
                     53:        for(i = 0; i < LENG; i++) {
                     54:                ary[i] = 0x55555555L;
                     55:                if(seed & 1)
                     56:                        ary[i] = 0xCCCCCCCCL;
                     57:                if(seed & 0x8000)
                     58:                        ary[i] ^= 0xF0F0F0F0L;
                     59:                seed >>= 1;
                     60:        }
                     61:        i1 = 0;
                     62:        i2 = 12;
                     63:        for(i = 1; i < 32; i += i)
                     64:        do {
                     65:                j = rand();
                     66:                ary[i1] += ary[i1] >> i;
                     67:                ary[i2] += ary[i2] << i;
                     68:        } while (i1);
                     69: }
                     70: 
                     71: rand()
                     72: {
                     73: 
                     74:        if(++i1 >= LENG)
                     75:                i1 = 0;
                     76:        if(++i2 >= LENG)
                     77:                i2 = 0;
                     78:        ary[i1] += ary[i2];
                     79:        return((ary[i1] >> 15) & 0x7FFF);
                     80: }
                     81: 
                     82: long
                     83: lrand()
                     84: {
                     85: 
                     86:        if(++i1 >= LENG)
                     87:                i1 = 0;
                     88:        if(++i2 >= LENG)
                     89:                i2 = 0;
                     90:        ary[i1] += ary[i2];
                     91:        return(ary[i1] & 0x7FFFFFFFL);
                     92: }
                     93: 
                     94: double
                     95: frand()
                     96: {
                     97: 
                     98:        if(++i1 >= LENG)
                     99:                i1 = 0;
                    100:        if(++i2 >= LENG)
                    101:                i2 = 0;
                    102:        ary[i1] += ary[i2];
                    103:        return((ary[i1] & 0x7FFFFFFFL) / 2.147483648e9);
                    104: }
                    105: 
                    106: nrand(n)
                    107: {
                    108:        register long slop = 0x7FFFFFFFL % n, v;
                    109: 
                    110:        do{
                    111:                if(++i1 >= LENG)
                    112:                        i1 = 0;
                    113:                if(++i2 >= LENG)
                    114:                        i2 = 0;
                    115:                ary[i1] += ary[i2];
                    116:                v = ary[i1] & 0x7FFFFFFFL;
                    117:        }while(v <= slop);
                    118:        return(v % n);
                    119: }
                    120: 
                    121: Srand(c1, c2, carray, clen)
                    122:        int *c1, *c2, *carray, *clen;
                    123: {
                    124:        register i, j;
                    125: 
                    126:        i = *c1; *c1 = i1; i1 = i;
                    127:        i = *c2; *c2 = i2; i2 = i;
                    128:        *clen = LENG;
                    129:        for(i = 0; i < LENG; i++)
                    130:        {
                    131:                j = carray[i]; carray[i] = ary[i]; ary[i] = j;
                    132:        }
                    133: }

unix.superglobalmegacorp.com

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