3-pass protocols

This text will be one of the rewritten chapters for the training manual on information protection of the Department of Radio Engineering and Control Systems, as well as, from this training code, the Department of Information Protection of the MIPT (GU). The full tutorial is available on github (see also draft releases ). On Habrir I plan to upload new "big" pieces, firstly, to collect useful comments and observations, and secondly, to give the community more overview material on useful and interesting topics.



Previous topics:





If there is a communication channel between Alice and Bob that is not accessible for modification by an attacker (that is, when only the passive cryptanalyst model is applicable), then even without a preliminary exchange of secret keys or other information, you can use the ideas used previously in public key cryptography. After describing the RSA in 1978, in 1980 Adi Shamir proposed using cryptosystems based on commutative operations to transmit information without first exchanging secret keys. If we assume that the transmitted information is a secret session key generated by one of the parties, then in general we get the following three-pass protocol.



Preliminary:





The protocol consists of three passes with the transmission of messages (hence the name) and one final one, on which Bob receives the key.







  1. Alice picks a new session key K



    Alice \ to \ left \ {E_A \ left (K \ right) \ right \} \ to Bob
  2. Bob \ to \ left \ {E_B \ left (E_A \ left (K \ right) \ right) \ right \} \ to Alice
  3. Alice, using the commutativity of the encryption function,





    DA left(EB left(EA left(K right) right) right)=DA left(EA left(EB left(K right) right) right)=EB left(K right).





    Alice \ to \ left \ {E_B \ left (K \ right) \ right \} \ to Bob
  4. Bob decrypts DB left(EB left(K right) right)=K


As a result, the parties receive a shared secret key. K .



A common drawback of all such protocols is the lack of authentication of the parties. Of course, in the case of a passive cryptanalyst, this is not required, but in real life you still need to consider all possible models (including an active cryptanalyst) and use protocols that involve mutual authentication of the parties. Also, unlike the Diffie – Hellman scheme, the new key is selected by the session initiator, which allows the initiator, not with good intentions, to force the second participant to use the outdated session key.



Speaking in terms of security properties , all representatives of this class of protocols declare only key authentication (G7). Unlike the Diffie – Hellman scheme, three-pass protocols do not require the selection of new β€œmaster” keys for each protocol session, which is why neither perfect direct secrecy (G9) nor the formation of new keys (G10) can be guaranteed.



Trivial option



Let us give an example of a protocol based on the XOR function (bitwise addition modulo 2). Although this function can be used as a foundation for building systems of perfect cryptographic strength, for a three-pass protocol this is a bad choice.



Before starting the protocol, both parties have their secret keys. KA and KB representing random binary sequences with a uniform distribution of characters. The encryption function is defined as Ei(X)=X oplusKi where X this message as well Ki - The secret key. It's obvious that:





 foralli,j,X:Ei left(Ej left(X right) right)=X oplusKj oplusKi=X oplusKi oplusKj=Ej left(Ei left(X right) right)





  1. Alice picks a new session key K



    Alice \ to \ left \ {E_A \ left (K \ right) = K \ oplus K_A \ right \} \ to Bob
  2. Bob \ to \ left \ {E_B \ left (E_A \ left (K \ right) \ right) = K \ oplus K_A \ oplus K_B \ right \} \ to Alice
  3. Alice, using the commutativity of the encryption function,





    DA left(EB left(EA left(K right) right) right)=K oplusKA oplusKB oplusKA=K oplusKB=EB left(K right).





    Alice \ to \ left \ {E_B \ left (K \ right) = K \ oplus K_B \ right \} \ to Bob
  4. Bob decrypts DB left(EB left(K right) right)=K oplusKB oplusKB=K


At the end of the protocol session, Alice and Bob know the common session key K .



The proposed choice of the commutative encryption function of perfect secrecy is unsuccessful, as there are situations in which a cryptanalyst can determine the key K . Suppose a cryptanalyst intercepted all three messages:





K oplusKA,  K oplusKA oplusKB,  K oplusKB.







Modulo 2 addition of all three messages gives the key K . Therefore, such an encryption system is not used.



Now we present the protocol for reliable transfer of the secret key, based on the exponential (commutative) encryption function. The stability of this protocol is associated with the difficulty of the task of computing the discrete logarithm: for known values y,g,p , to find x from the equation y=gx bmodp .



Shamir's Keyless Protocol



Parties tentatively agree on a large prime p sim21024 . Each of the parties chooses a secret key. a and b . These keys are smaller and mutually simple. pβˆ’1 . Also, the parties prepared according to a special number aβ€² and bβ€² that allow them to decrypt a message encrypted with their key:





 beginarraylaβ€²=aβˆ’1 mod(pβˆ’1),a timesaβ€²=1 mod(pβˆ’1), forallX:(Xa)aβ€²=X. endarray









The last expression is true as a consequence of Fermat’s small theorem \ index {theorem! The farm is small}. Encryption and decryption operations are defined as follows:





\ begin {array} {lll} \ forall M <p: & C = E (M) = M ^ {a} & \ mod p, \\ & D (C) = C ^ {a '} & \ mod p, \\ & D_A (E_A (M)) = M ^ {aa '} = M & \ mod p. \\ \ end {array}







  1. Alice picks a new session key K<p



    Alice \ to \ left \ {E_A \ left (K \ right) = K ^ a \ bmod p \ right \} \ to Bob
  2. Bob \ to \ left \ {E_B \ left (E_A \ left (K \ right) \ right) = K ^ {ab} \ bmod p \ right \} \ to Alice
  3. Alice, using the commutativity of the encryption function,





    DA left(EB left(EA left(K right) right) right)=Kabaβ€²=Kb=EB left(K right) modp.







    Alice \ to \ left \ {E_B \ left (K \ right) = K ^ b \ right \} \ to Bob
  4. Bob decrypts DB left(EB left(K right) right)=Kbbβ€² bmodp=K


At the end of the protocol session, Alice and Bob know the common session key K .



Suppose a cryptanalyst intercepted three messages:





 beginarrayly1=Ka bmodp,y2=Kab bmodp,y3=Kb bmodp. endarray







To find the key K , a cryptanalyst needs to solve a system of these three equations, which has a very large computational complexity, unacceptable from a practical point of view, if all three numbers a,b,ab quite large. Let's pretend that a (or b ) few. Then, computing successive degrees y3 (or y1 ), can be found a (or b ), comparing the result with y2 . Knowing a , easy to find aβˆ’1 bmod(pβˆ’1) and K=(y1)aβˆ’1 bmodp .



Massey-Omura Cryptosystem



In 1982, James Massey and Jim Omura filed a patent (James Massey, Jim K. Omura), improving (in their opinion) the keyless protocol of Shamir. As an encryption operation instead of exponentiation in a multiplicative group  mathbbZpβˆ— they suggested using exponentiation in the Galois field  mathbbGF2n . Secret key of each party (for Alice - a ) must satisfy the conditions:





 beginarrayla in mathbbGF2n,gfd left(a,xnβˆ’1+xnβˆ’2+...+x+1 right)=1. endarray







Otherwise, the protocol looks similar.



Afterword



The author will be grateful for factual and other comments on the text.



All Articles