## 4 SeKeQ: Secure Key Exchange with QR Code Protocol  
Our protocol SeKeQ works as follows; Devices A and B agree on finite group \(G\) from \(Z/pZ\) with multiplication modulo a prime number \(p\). In addition, users generate random numbers for key exchange on \(Z/pZ\) field. They exchange these random numbers modulo \(p\) on our key agreement process. Devices A and B agree in clear over wireless channel on prime large \(p\) and a generator \(g\) from \(Z/pZ\) field, we call them the key pair. They are exchanged as follows, A creates its own Diffie-Hellman key pair with 2048 bits key size and initializes its Diffie-Hellman Key Agreement object. Then, A encodes its public key, and sends it over to B. On device B, it has received A public key in an encoded format, it instantiates a Diffie-Hellman public key from the encoded key material. B gets the Diffie-Hellman parameters associated with A public key. Then, it must use the same parameters when it generates its own key pair. At this stage, both A and B have completed the Diffie Hellman agreement on the key pair \(p\) and \(g\). Then [PERSON] selects its private random number \(a\) and calculates \(g^{a}modp\) and sends the result publicly to B. Now, [PERSON] selects its private random number b and calculates \(g^{b}modp\) and sends this result to A. In the next step, the calculation of the shared secret begins, A takes B public result and raises it to the power of its private number \(a\) mod \(p\) to obtain the shared secret, called \(S1\). Then, B takes A public result and raises it to the power of its private number \(b\) mod \(p\) resulting on a shared secret called \(S2\). It is worth noticing that both devices did the same calculation. As we see, it is an efficient key agreement protocol but still vulnerable to the Man in the Middle attack. Which makes the studies fundamental to enhance the secrecy of the algorithm. In the next step, and to provide a high security level, Devices A and B put their shared keys \(S1\) and \(S2\), respectively, to a one way hash function, which is, in our case, SHA-256. They generate \(h(S1)\), the hash value of \(S1\) for device A and \(h(S2)\) the hash value of \(S2\) for device B. The hash value is a large number. In our case, the hash value is represented by 32 Hexadecimal digits. We should obtain \(h(S1)=h(S2)\), since \(S1\) and \(S2\) are equal which is the adequate case for verifying the integrity of the shared secret key. However, the hash value have to be compared manually by D2D devices. The authors in [18] proposed a key agreement based on Diffie-Hellman and commitment scheme. They succeed at reducing the large size of the hash value \(h(k)\), resulting 5 Hexadecimal digits as the size of the shared secret key. However, this proposal is still inefficient because it requires that the shared secret have to be compared visually or verbally by D2D users. To overcome this limitation, we propose an automatic key comparison process of the shared secret key by the use of the QR Code as an additional step of our SeKeQ protocol. The QR code is a type of two-dimensional bar code (or matrix code) consisting of black modules or points arranged in a square with a white background. The arrangement of these points defines the information contained in the code. This information can be a website, text, phone number or an SMS [25]. It is first generated containing the desired data which can go up to 4000 characters, and displayed as a picture on a computer, smartphone or printed on a paper. Then, with nowadays large mobile devices, using the device camera, the QR is scanned and results its content at high speeds. The QR Code have multiple application uses, such as storing information of patients in the medical field, scanning passenger's coordination for accessing a facilities and private zones. In addition, it can be used for reliable verification of products before packaging.