/* Author: Pate Williams (c) 1997 Exercise "7.6 Using the (original) expansion function for SHS, Equation 7.1, express each of X[16],..., X[79] in terms of X[0],..., X[15]. Now, for each pair X[i], X[j] where 1 <= i < j <= 15, use a computer program to determine lambda(i, j), which denotes the number of X[k]'s (16 <= k <= 79) such that X[i] and X[j] both occur in the expression for X[k]. What is the range of values for lambda(i, j)?" -Douglas R. Stinson- See "Cryptography: Theory and Practice" by Douglas R. Stinson. */ #include int main(void) { long i, j, k, max = 0, min = 80; long matrix[80][20] = {{0}}; long lambda[20][20] = {{0}}; printf("the X[0] to X[15] usage matrix is:\n"); for (i = 0; i <= 15; i++) matrix[i][i] = 1; for (i = 16; i <= 79; i++) { for (j = 0; j <= 15; j++) { matrix[i][j] ^= matrix[i - 3][j]; matrix[i][j] ^= matrix[i - 8][j]; matrix[i][j] ^= matrix[i - 14][j]; matrix[i][j] ^= matrix[i - 16][j]; } } for (i = 1; i <= 15; i++) for (j = i + 1; j <= 15; j++) for (k = 16; k <= 79; k++) if (matrix[k][i] == 1 && matrix[k][j] == 1) lambda[i][j]++; for (i = 16; i <= 79; i++) { printf("%2ld ", i); for (j = 0; j <= 15; j++) printf("%ld ", matrix[i][j]); printf("\n"); } printf("the lambda matrix is:\n"); for (i = 1; i <= 15; i++) { for (j = i + 1; j <= 15; j++) { printf("%ld ", lambda[i][j]); if (lambda[i][j] < min) min = lambda[i][j]; if (lambda[i][j] > max) max = lambda[i][j]; } printf("\n"); } printf("maximum lambda = %ld\n", max); printf("minimum lambda = %ld\n", min); return 0; }