Extra Systems

CYPHERNET

receiver (input)


The receiver (input) is used to receive information from the subscriber with whom negotiations are being conducted and to display the received information on the console screen. At the beginning of the session, the receiver requests the user's identifier, as well as the identifier of the subscriber from whom text information will be received. The receiver must have the private key of the subscriber who uses it and the public key of the subscriber with whom negotiations will be conducted. The corresponding fingerprint must also be available.

Sending the corresponding fingerprint to the server (the server identifies the client and determines which subscriber it should be connected to) is done by the send_finger_print procedure.

After establishing a connection via the Extra Systems Cypher Net central server with the output program, the input program generates a random session key and encrypts it via RSA with the public key of the subscriber with whom the negotiations are being conducted. Then input sends it this encryption, and immediately after that sends the hash of the generated key. Similar events occur at the other end of the connection in the output program.

After receiving the specified information from the partner, input decrypts the session key with its private RSA key and checks the hash match. Then both participants in the connection (input and output) add the two random sequences they generated modulo each other and, due to the commutativity of this operation, obtain the same value, which is then used as a session key. All these actions are performed by the get_common_key procedure, which is the same in both the receiver and the transmitter.

Once the session key has been generated in this way, the stream encryption module comes into play. It exports universal (encapsulating the necessary operations in a way independent of the chosen stream encryption algorithm) functions make_crypt_key_table (creates a key table), encrypt_buffer (encrypts the buffer in the input program) and decrypt_buffer (decrypts the buffer in the output program).

The input program does its job using the following algorithm:

#include "common.h"
#define STR_BUF_SIZE 4096
#define CLIENT_MODE CLIENT_MODE_INPUT

int main(void)
{
	int my_id, his_id, my_socket, buf_size, client_mode = CLIENT_MODE;
	char str_buf[STR_BUF_SIZE];
	char public_name[64], private_name[64];
	set_console_code_page();
	printf ("\nКлиент консольной шифросвязи (приемник)\n(C) Extra Systems, 2024\n\n");
	printf ("Укажите свой идентификатор: ");
	scanf("%d", &my_id);
	printf ("Укажите идентификатор партнера: ");
	scanf("%d", &his_id);
	printf ("\n");
	sprintf(private_name, "private_%d", my_id);
	sprintf(public_name, "public_%d", his_id);
	if (!load_rsa_keys(public_name, private_name)) {
		printf("На диске отсутствуют нужные ключи...\n\n");
		return 1;
	}
	print_crypt_params();
	sockets_startup();
	my_socket = create_client_socket(main_server_name, main_server_port);
	if (!send_finger_print(my_socket, my_id, his_id, CLIENT_MODE)) {
		printf("На диске отсутствует нужный fingerprint...\n\n");
		return 1;
	}
	if (!get_common_key(my_socket)) {
		printf("Канал связи установить не удалось...\n");
		return 1;
	}
	make_crypt_key_table();
	while (buf_size = socket_read_buffer(my_socket, str_buf, STR_BUF_SIZE))
	{
			str_buf[buf_size] = 0;
			decrypt_buffer(str_buf, buf_size);
			printf( "%s", str_buf);
	}
	close_socket(my_socket);
	sockets_cleanup();
	return 0;
}

The content of this page is also available in French, German, Ukrainian and Russian.


© Extra Systems, 2024 Extra Web Top