Extra Systems

CYPHERNET

transmitter (output)


The transmitter (output) is used to transmit information from the subscriber who is negotiating to the other subscriber with whom they are being conducted. At the other end, this information is output to the console using the input program. At the beginning of the session, the transmitter asks the user for his identifier, as well as the identifier of the subscriber to whom the text information will be transmitted. The transmitter must have the private key of the subscriber who is using it and the public key of the subscriber with whom the negotiations will be conducted. The corresponding fingerprint must also be available.

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

After establishing a connection via the Extra Systems Cypher Net central server with the input program, the output 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 output sends him 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 input program.

Having received the specified information from the partner, output decrypts the session key with its private RSA key and checks the hash match. Then both communication participants (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 the session key. All these actions are performed by the get_common_key procedure, which is the same in both the receiver and the transmitter.

After 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 selected 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 output program does its job using the following algorithm:

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

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();
	printf ("Начинайте передачу информации...\n\n");
	while (get_string_from_console(str_buf, STR_BUF_SIZE))
	{
		buf_size = strlen(str_buf);
		encrypt_buffer(str_buf, buf_size);
		socket_send_buffer(my_socket, str_buf, buf_size);
	}
	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