Abstract
In this article, a safe communication system is proposed that implements one or more portable devices denominated SBC (singleboard computers), with which photographs are taken and that later utilizes the OpenCV Library for the detection and identification of the faces that appear in them. Subsequently, it consults the information in a stored database, whether locally in SBC or in a remote server, to verify that the faces should be coded, and it encrypts these, implementing a new cryptosystem that executes mathematical models to generate chaotic orbits, one of which is used for application on two occasions the technique of diffusion with the purpose of carrying out a small change in one of the pixels of the image, generating very different cryptograms. In addition, in order to make a safer system, it implements other chaotic orbits during the technique of confusion. With the purpose of verifying the robustness of the encryption algorithm, a statistical analysis is performed employing histograms, horizontal, vertical, and diagonal correlation diagrams, entropy, number of pixel change rate (NPCR), unified average change intensity (UACI), sensitivity of the key, encryption quality analysis, and the avalanche effect. The cryptosystem is very robust in that it generates highly disordered cryptograms, supports differential attacks, and in addition is highly sensitive to changes in the pixels as well as in the encrypted keys.
1. Introduction
Facial recognition is very important today due to its application in security, surveillance systems, forensic analyses, etc. Therefore, it is important to conduct investigation in this area, as well as in research in which a system is developed to detect the drowsiness of a conductor, considering its positions, the form around the eye, and whether the head is inclined [1]. These authors also carried out a balance between image similarities and differences in order to detect human faces even when they had noise or facial expressions and different poses [2]. However, facial recognition can also be utilized to generate damage; thus, it is necessary permit the protection of identity by means of encryption systems, which can be employed to code photographs completely, although it is most recommendable to perform selective encryption, whether on the borders or using facial detection because this considerably reduces the system’s time and resources [3, 4]. Shakir et al. detected faces in the images, considering a database that contains information of different parts of the skin [5]. Rachmawati et al. elaborated a cryptosystem for Android that employs cryptography [6]. Vela Medina et al. carried out an embedded system that utilizes an intelligent camera, in addition to algorithms to detect and recognize faces in a video surveillance system that performs the capture and storage of the images and subsequently, it sends a message to inform the user [7]. Rodrigues et al. coded the human face in a video sequence using AES and VLC (variable length coding); these authors detected the skin, but the method does not render the faces totally unrecognizable [3]. Khashan et al. implemented border and facial detection methods utilizing OpenCV and employing the Blowfish algorithm for encryption [4]. Also, in the work developed by Hong and Jung, the authors implemented a partial encryption method that only codes the facial region in images and videos; they used a Gaussian skincolor model for detection and, in addition, DES (data encryption standard) and AES (advanced encryption standard) for encryption [8]. Gerhardt et al. selectively encrypted faces in videos using Sophisticated Highspeed Object Recognition Engine (SHORE) for the detection and use of AES256 [9]. In another research, these authors encrypted facial regions by applying multilayer encoding on images in the frequency domain, but they do not divide the human region and it may also encrypt clothing [10]. Also, they encrypted important objects in the image that are detected with the machine learning technique through the OpenCV Library and employed an algorithm called RNS to encrypt these, increasing the encryption speed but losing the context of the original image [11]. They extract all of the faces that appear in the videos using highspeed support functions with the OpenCV Library, implementing NewHope, public, private, and SHA3 keys on order to encrypt; faces are encoded in parallel using GPU [12]. Sardar et al. use the treestructured part model (TSPM) to extract the region of the face; for training, they employ sparse representation coding (SRC), coordinate descent (CD) and block coordinate descent (BCD), and the SVM classifier. They also implement a variant of BioHashing to generate face code from the characteristic vector. Then, to provide greater security, they adapt the RSA algorithm [13]. AsgariChenaghlu et al. use YoloV3 to automatically detect objects or the human body of the ROI delimiter and utilize a cryptosystem based on the chaotic sine map and logistic map systems. They only detect objects of interest and encode them [14]. Additionally, investigations have also been developed in which the properties of the chaotic systems are taken advantage of, such as the high sensitivity of the initial conditions as well as of the parameters. This is due to that the latter are excellent candidates for the development of cryptographic systems, such as those in which they detect the face in order to later extract regions of the body and encrypt them [15]. Wen et al. selectively encrypt objectives in infrared images employing logistic chaotic maps and sine [16]. These authors also developed a selective facial encryption system in gray tones utilizing the tent chaotic map [17]. Prabhavathi et al. selectively encrypt regions of interest in medical images utilizing multiple chaotic systems [18]. In addition to the latter, discrete chaotic systems have also been taken advantage of to encrypt images [19–22]. Ayoup et al. divide the image into blocks and, according to the entropy involved, determine which of these to code using pseudorandomized numbers (PRNs), Arnold’s cat map, and AES [23]. The proposed communication system performs selective facial detection, identification, and encryption, encoding only the object of interest and leaving the environment visible, unlike general encryption, which hides everything. Thus, encryption time and resources are reduced compared to the encryption of a full image and increases the security of people who do not want their faces to be visible when others post their photographs. It is also useful for protecting identity in the news when someone is presented who is under criminal proceedings. It allows protecting the identity of minors when adults wish to publish photographs, and it can also be used in closedcircuit video surveillance networks or in photographs published through social media and communication. Our system, in contrast to those described in the current research, can selectively encode only faces indicated in a database or manually when the face cannot be identified. In addition, there is an encryption algorithm that implements novel confusion and diffusion techniques; these allow the system to be robust on confronting different attacks, and especially that of the avalanche effect, which not all cryptosystems approve.
The remainder of this article is organized as follows: in Section 2, the mathematical models are explained that are implemented during encryption. Section 3 details the functioning and the stages carried out by the communications system, while the results and the tests conducted on the cryptogram are presented in Section 4. Finally, Section 5 presents the conclusions of this investigation.
2. Mathematical Models
2.1. Rössler Oscillator
This comprises a simultaneous system of 3 differential equations:where are the dependent variables of time, , are the parameters. In the system, the third equation makes this possess nonlinear chaotic behavior [24].
3. Communication System
This comprises a server and can have one or more portable devices through which recognition can be performed with the Open Computer Vision (OpenCV) Library or, in a particular case, code selected faces in photographs as well as in videos; this is due to that the latter are composed of a series of photograms, in which it is possible to detect the faces and to code them later.
Figure 1 shows the general procedure that the communication system carries out, which includes the following stages:(1)Registration and training(2)Face detection(3)Selective encryption(4)Cryptogram generation
3.1. Registration and Training
First, it is necessary to carry out registration and training with the information of all persons who are to be added to the database, for which the process is performed that is depicted in Figure 2.
3.2. Face Detection
First, the photograph is captured or stored in the singleboard computer (SBC). Subsequently, the OpenCV Library is utilized to locate the faces, which are identified and marked with a square, as can be observed in Figure 3.
3.3. Selective Encryption
The system permits manual selection through an interface, in which the face is selected and encrypted, as can be observed in Figure 4.
Also, encryption can be automatic, by means of a communications schema, which performs recognition, taking information locally, remotely, or considering both databases, as demonstrated in Figure 5.
3.4. Generation of the Cryptogram
Once a certain face is detected that should be coded according to the information stored in the database, the cryptogram should be generated utilizing the following procedure.
3.4.1. Algorithm to Encrypt
The encryption algorithm can work with any chaotic mathematical model one wishes to employ, as long as the required number of orbits is generated. The Rössler oscillator is implemented because it generates three complex chaotic sequences, is highly sensitive to initial conditions and system parameters, and uses six keys each time it is resolved, generating a very wide key space. Keys(i)Diffusion 1: values corresponding to the initial conditions and parameters used to apply Diffusion I, when the chaotic system of the Rössler oscillator is resolved (equation (1)). : keys utilized to apply Diffusion II. : the keys necessary in the two diffusion processes, which are utilized as initial position and that can be taken between 1 and ; where .(ii)Confusion : these initial conditions and parameters are also utilized to resolve the Rössler oscillator (equation (1)). : initial position between 0 and 5. : value between 0 and 16777215, which is employed to select a position. Apply Diffusion I Each face is broken down into the pixels comprising it, and later into their 3 subpixels (red, green, blue (RGB)), which have a value between 0 and 255. Step 1: store in a vector of length , called , the subpixels of the face: Step 2: create a vector called of size L. Step 3: resolve times the system of equation (1), implementing the encryption keys of where R = . The values generated of are stored in a vector called of length : Step 4: assign, to the variable , the value of the key . Step 5: take a value of and assign it to location of vector , as can be observed in Figure 6: Step 6: take the absolute value of an element of the vector , later adding to it ; finally, the result is rounded off and is assigned to the variable : Step 7: verify if , then Step 8: else, if , then Step 9: verify if is empty, assigning to it an element of ; else, go to Step 10 (see Figure 7). Step 10: verify if is not empty and , is decreasing, until finding a formerly empty location; contrariwise, if , increases. On localizing an empty position, assign to it the element of . This procedure is presented in Figure 8. Step 11: repeat Steps 6 through 10, until arranging all of the subpixels of the vector in .
Diffusion I algorithm is shown in Algorithm 1.

Confusion
Step 1: convert, to their value in pixel [0, 16777215], the elements of and store them in a vector of R length: Step 2: resolve R times the system of equation (1) using encryption keys , yielding as a result three orbits: Step 3: generate integer values between 0 and 16777215, dividing an element of between the absolute value of the highest number of the vector, subsequently multiplying this by 16777215. The result is rounded off and the value of is substituted. Step 4: convert, to a 6digit hexadecimal, each element of , as shown in Figure 9.Confusion algorithm is shown in Algorithm 2.

Diffusion II. Take vector and apply the procedure indicated in Diffusion I, but with keys and ; in the end, the cryptogram is generated.
3.4.2. Algorithm for Decryption
Eliminate Diffusion II Step 1: store the cryptogram’s subpixel vector , which has a length of Step 2: create a vector called . Step 3: resolve times the system of equation (1), with encryption keys . The values generated of are stored in a vector denominated : Step 4: assign, to the variable , the value of key . Step 5: take, from location in vector , the value and place it in . This procedure is shown in Figure 13. Step 6: take the absolute value of an element of the vector , later adding it to a value of , rounded off the result and assigning it to : Step 7: verify if , then Step 8: contrariwise, if , then Step 9: verify if has a value, assigning it to the next position in ; contrariwise, proceed to Step 10 (see Figure 14). Step 10: in the case of being empty and , will decrease; contrariwise, if , increases. This procedure is carried out until finding a value and assigning it to (see Figure 15). Step 11: repeat Steps 6–10 until arranging all elements in .
Eliminate diffusion II algorithm is shown in Algorithm 3.

Eliminate Confusion
Step 1: convert the elements of vector from subpixels into pixels: Step 2: create . Step 3: again, generate whole values between 0 and 16777215 (Step 3, confusion): Step 4: apply XOR between and , with the result stored in , as can be observed in Figure 16. Step 5: assign, to variable and to vector , the result of applying XOR between the first element of and . Repeat this procedure to decrypt the entire vector . But, from the second iteration, the value stored in is utilized to apply XOR with the elements after , instead of , as can be observed in Figure 17. Step 6: regenerate , taking the 6 first decimals of an element of vector . Step 7: implement the algorithm to eliminate diffusion II, taking an element of , the key and the positions indicated in ; later, convert this into a decimal, as can be observed in Figure 18. Step 8: repeat Steps 6 and 7 until rearranging each element of vector . Step 9: convert from a hexadecimal into a decimal.Eliminate confusion algorithm is shown in Algorithm 4.
