|
|
1.1 ! root 1: /* ! 2: * $Source: /usr/src/kerberosIV/make_p_table/RCS/make_p_table.c,v $ ! 3: * $Author: jtkohl $ ! 4: * ! 5: * Copyright 1985, 1988 by the Massachusetts Institute of Technology. ! 6: * ! 7: * For copying and distribution information, please ! 8: * see the file <mit-copyright.h>. ! 9: * ! 10: */ ! 11: ! 12: #include <mit-copyright.h> ! 13: #include <stdio.h> ! 14: #include "des_internal.h" ! 15: #include "tables.h" ! 16: ! 17: extern unsigned long swap_byte_bits(); ! 18: extern unsigned long rev_swap_bit_pos_0(); ! 19: static unsigned char P_temp[32]; ! 20: static unsigned long P_prime[4][256]; ! 21: ! 22: void gen(stream) ! 23: FILE *stream; ! 24: { ! 25: register i,j,k,m; ! 26: /* P permutes 32 bit input R1 into 32 bit output R2 */ ! 27: ! 28: #ifdef BIG ! 29: /* flip p into p_temp */ ! 30: for (i = 0; i<32; i++) ! 31: P_temp[P[rev_swap_bit_pos_0(i)]] = rev_swap_bit_pos_0(i); ! 32: ! 33: /* ! 34: * now for each byte of input, figure out all possible combinations ! 35: */ ! 36: for (i = 0; i <4 ; i ++) { /* each input byte */ ! 37: for (j = 0; j<256; j++) { /* each possible byte value */ ! 38: /* flip bit order */ ! 39: k = j; ! 40: /* swap_byte_bits(j); */ ! 41: for (m = 0; m < 8; m++) { /* each bit */ ! 42: if (k & (1 << m)) { ! 43: /* set output values */ ! 44: P_prime[i][j] |= 1 << P_temp[(i*8)+m]; ! 45: } ! 46: } ! 47: } ! 48: } ! 49: ! 50: fprintf(stream, ! 51: "\n\tstatic unsigned long const P_prime[4][256] = {\n\t"); ! 52: for (i = 0; i < 4; i++) { ! 53: fprintf(stream,"\n"); ! 54: for (j = 0; j < 64; j++) { ! 55: fprintf(stream,"\n"); ! 56: for (k = 0; k < 4; k++) { ! 57: fprintf(stream,"0x%08X",P_prime[i][j*4+k]); ! 58: if ((i == 3) && (j == 63) && (k == 3)) ! 59: fprintf(stream,"\n};"); ! 60: else ! 61: fprintf(stream,", "); ! 62: } ! 63: } ! 64: } ! 65: ! 66: #endif ! 67: fprintf(stream,"\n"); ! 68: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.