in English

Криптопримтив

Хэш функция

... а еще алгоритм шифрования и процедура расширения ключа

Сама функция очень проста:

void doHash(const char data[], char hash[]) {
	byte s = 0;

	for (int c = 0; c < 64; c++) {

		for (int i = 0; i < 64; i++) {

			hash[i] = d_matrix[i][s][data[c_matrix[c][i]] + hash[i]];
			s = s_matrix[i][s + data[c_matrix[c][i]]];

		}

	}

}

о применяемых структурах:

byte s_matrix[64][256];
byte d_matrix[64][256][256];
int c_matrix[64][64];

о генерации структур:

void build_c_matrix() {
	for (int c = 0; c < 64; c++) {

		for (int i = 0; i < 64; i++) {

			c_matrix[c][i] = (i + c) % 64;

		}

	}
}

void build_s_matrix() {
	for (int c = 0; c < 64; c++) {

		for (int i = 0; i < 256; i++) {

			byte v;

			do {
				v = PRNG();
			}

			while (v == i);

			s_matrix[c][i] = v;

		}

	}
}

void build_d_matrix() {	
	for (int c = 0; c < 64; c++) {

		for (int x = 0; x < 256; x++) {

			for (int y = 0; y < 256; y++) {

				byte v;

				do {
					v = PRNG();
				}

				while (v == y);

				d_matrix[c][x][y] = v;

			}
		}

	}
}

о результататах:

Test results for file rnd.data.
Entropy = 7.999934 bits per byte.

Optimum compression would reduce the size
of this 512000064 bytes file by 0 percent.

Chi square distribution for 512000064 samples is 47176.54 (factor 184.2833571), and randomly
would exceed this value less than 0.01 percent of the times.

Arithmetic mean value of data bytes is 127.4871 (127.5 = random).
Monte Carlo value for Pi is 3.141708779 (error 0.00 percent).
Serial correlation coefficient is -0.000022 (totally uncorrelated = 0.0).

Как видно, функция крайне ресурсоемка. Масштабируема. Параметризуется, например, количество раундов