Cryptosystems Protocols: Diffie — Hellman, El-Gamal, MTI / A (0), STS

Foreword
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 sections of the Cryptographic Protocols chapter: 1 , 2 , 3


Like the creators of the three-pass protocols from the previous section , the authors of the following algorithms considered them not just mathematical constructions that provided some elementary operation (for example, public key encryption), but tried to build a complete key distribution system around one or two formulas. Some of these constructions, which have been transformed, are used to date (for example, the Diffie-Hellman protocol), some of them remain only in the history of cryptography and information protection.



Later in the 1990s, mathematical asymmetric primitives (encryption and electronic signature) and protocols will be separated, these primitives will be used, which will be demonstrated in the section on asymmetric protocols.



Diffie — Hellman Protocol



The first public key algorithm was proposed by Diffie and Hellman in 1976, “New Directions in Cryptography” ( Bailey Whitfield Diffie, Martin Edward Hellman, “New directions in cryptography” , [Diffie, Hellman 1976] ). This protocol, which can also be called the Diffie-Hellman scheme , was the first to reduce the requirements for the communication channel to establish a secure connection without first exchanging keys.



The protocol allows two parties to create a common session key using a communication channel that an attacker can listen to, but on the assumption that the latter cannot change the message content.



Let p - a large prime number g - a primitive element of the group  mathbbZp , y=gx bmodp , and p , y and g known in advance. Function y=gx bmodp we consider unidirectional, that is, calculating a function with a known value of an argument is an easy task, and its inversion (finding an argument) with a known value of a function is difficult. (Inverse function x= loggy bmodp called the discrete logarithm function. There are currently no quick ways to calculate such a function for large simple p .)



The exchange protocol consists of the following actions.



Participant Interaction in the Diffie-Hellman Protocol








  1. Alice picks a random 2 leqa leqp1

    Alice \ to \ left \ {A = g ^ a \ bmod p \ right \} \ to Bob
  2. Bob picks random 2 leqb leqp1

    Bob calculates a session key K=Ab bmodp

    Bob \ to \ left \ {B = g ^ b \ bmod p \ right \} \ to Alice
  3. Alice calculates K=Ba bmodp



In this way, a shared secret session key is created K . Due to the random selection of values a and b in a new session, a new session key will be received.



The protocol provides only the generation of new session keys (target G10). In the absence of a third trusted party, it does not provide authentication of the parties (target G1), due to the absence of passages with confirmation of ownership of the key, there is no authentication of the key (target G8). But, since the protocol does not use long “master” keys, we can say that it has the property of perfect direct secrecy (goal G9).



The protocol can only be used with communication channels into which an active cryptanalyst cannot intervene. Otherwise, the protocol becomes vulnerable to a simple “middle attack”.



Interaction of participants in the Diffie-Hellman protocol in a model with an active cryptanalyst








  1. Alice picks a random 2 leqa leqp1

    Alice \ to \ left \ {A = g ^ a \ bmod p \ right \} \ to Mellory ~ (Bob)
  2. Mallory picks a random 2 leqm leqp1

    Mallory calculates a session key for a channel with Alice





    KAM=Am bmodp=gam bmodp







    Mellory ~ (Alice) \ to \ left \ {M = g ^ m \ bmod p \ right \} \ to Bob

    Mellory ~ (Bob) \ to \ left \ {M = g ^ m \ bmod p \ right \} \ to Alice
  3. Alice calculates the session key for the channel with Mallory (thinking that Mallory is Bob)





    KAM=Ma bmodp=gam bmodp





  4. Bob picks random 2 leqb leqp1

    Bob calculates the session key for the channel with Mallory (thinking that Mallory is Alice)





    KBM=Mb bmodp=gbm bmodp







    Bob \ to \ left \ {B = g ^ b \ bmod p \ right \} \ to Mellory ~ (Alice)
  5. Mallory calculates a session key for a channel with Bob





    KBM=Bm bmodp=gbm bmodp









As a result, Alice and Bob received new session keys, but they established a “secure” communication channel not with each other, but with an attacker who now has the ability to relay or change all transmitted messages between Alice and Bob.



The Diffie-Hellman protocol differs from most key distribution protocols due to the fact that it does not use other cryptographic primitives (encryption, digital signature or hashing functions), but in itself is in a sense a cryptographic primitive for constructing more complex protocols. It provides random number generation in a distributed system without a trusted center. Moreover, neither side can force the other side to use the old session key, unlike, for example, the Yahalom protocol.



The protocol can be changed so that instead of the multiplicative group of simple multiplication, use the additive group of addition of points of the elliptic curve. In this case, the parties will continue to choose some random integers, but do not raise the generator-number to a power, but multiply the generator-point by the desired number.



  1. The parties agreed on a group of points of the elliptic curve  mathbbE its cyclic subgroup  mathbbG power n= | mathbbG | and generator G groups  mathbbG (or at least a sufficiently large subgroup of the group  mathbbG )
  2. Alice picks a random 2 leqa leqn1

    Alice \ to \ left \ {A = a \ times G \ right \} \ to Bob
  3. Bob picks random 2 leqb leqn1

    Bob calculates the point K=b timesA

    Bob \ to \ left \ {B = g \ times G \ right \} \ to Alice
  4. Alice calculates the point K=a timesB


As a new session key, the parties can choose, for example, the first coordinate of the found point K .



El Gamal Protocol



The El-Gamal protocol ( [ElGamal, 1984] , [ElGamal, 1985] ), due to the preliminary distribution of the public key of one of the parties, provides authentication of the key for this side. It can be guaranteed that only the owner of the corresponding private key can calculate the session key. However, confirmation of the receipt of the key (fulfillment of goals G1 and G8) is not part of the protocol.



    -








  1. Alice and Bob choose common options p and g where p Is a large prime, and g - primitive field element  mathbbZp .

    Bob creates a pair of private and public keys b and KB :





     beginarraylb:2 leqb leqp1,KB=gb bmodp. endarray







    Public key KB It is in the public open access for all parties. A cryptanalyst cannot replace him - the substitution will be noticeable.
  2. Alice picks a secret x and calculates the session key K





    K=KBx=gbx bmodp.











    Alice \ to \ left \ {g ^ x \ bmod p \ right \} \ to Bob





  3. Bob computes the session key





    K=(gx)b=gbx bmodp.







The protocol does not guarantee the selection of a new session key in each protocol session (G10), and the use of a “master” key KB to transfer a session key allows an attacker to calculate all session keys from past sessions when a private key is compromised b (goal G9).



MTI / A Protocol (0)



In 1986, C. Matsumoto ( Tsutomu Matsumoto ), I. Takashima ( Youichi Takashima ) and H. Imai ( Hideki Imai ) proposed several algorithms, later called the MTI protocol family ( [Matsumoto, Tsutomu, Imai 1986] ). Due to the preliminary distribution of the public keys of both parties, they provided implicit key authentication (target G7). That is, the session key was guaranteed to be received only by the owners of the corresponding public keys. We will consider one of the representatives of this family - the MTI / A protocol (0).



Previously, the parties agreed on the general parameters of the system. p and g where p Is a large prime, and g - primitive field element  mathbbZp .



    MTI/A(0)






Each of the parties (Alice and Bob) generated a pair of private and public keys:





\ begin {array} {ll} Alice: & ~ a, ~~ K_A = g ^ a \ bmod p, \\ Bob: & ~ b, ~~ K_B = g ^ b \ bmod p. \\ \ end {array}







  1. Alice generated a random number RA: 2 leqRA leqp1

    Alice \ to \ left \ {g ^ {R_A} \ bmod p \ right \} \ to Bob
  2. Bob generated a random number RB: 2 leqRB leqp1

    Bob figured out a session key K=(gRA)b cdotKARB bmodp

    Bob \ to \ left \ {g ^ {R_B} \ bmod p \ right \} \ to Alice
  3. Alice computed the session key K=(gRB)a cdotKBRA bmodp


If the public keys KA and KB match your private keys a and b , then the session keys calculated by the participants match:





\ begin {array} {lll} (g ^ {R_A}) ^ b \ cdot K_A ^ {R_B} \ bmod p & = & g ^ {b R_A + a R_B} \ bmod p, \\ (g ^ { R_B}) ^ a \ cdot K_B ^ {R_A} \ bmod p & = & g ^ {a R_B + b R_A} \ bmod p. \ end {array}







Due to the complexity of the discrete logarithm task, an attacker will not be able to obtain a,RA or b,RB from the transmitted messages, and the preliminary publication of public keys ensures that only legitimate users receive the session key. Random selection RA and RB ensures that both parties can be sure to create a new session key in each protocol session.



Like other representatives of cryptosystem protocols, MTI was not developed taking into account the possibility of compromising private master keys a and b (goal G9).



Station-to-Station Protocol



The STS protocol ( Station-to-Station , [Diffie, Oorschot, Wiener 1992] ) is intended for mobile communication systems. It uses the ideas of the Diffie-Hellman protocol and the RSA cryptosystem. A feature of the protocol is the use of an electronic signature mechanism for mutual authentication of the parties.



Previously, the parties agreed on the general parameters of the system. p and g where p Is a large prime, and g - primitive field element  mathbbZp .



Each side A and B possesses a long-term pair of keys: a private key for decrypting and creating an electronic signature K textpublic and public key for encryption and signature verification K textpublic .







\ begin {array} {ll} A: K_ {A, \ text {private}}, K_ {A, \ text {public}}: \ forall M: & \ text {Verify} _A (M, S_A (M )) = true, \\ & D_A (E_A (M)) = M, \\ B: K_ {B, \ text {private}}, K_ {B, \ text {public}}: \ forall M: & \ text {Verify} _B (M, S_B (M)) = true, \\ & D_B (E_B (M)) = M. \\ \ end {array}









Where  textVerifyA( dots) it is a function of checking electronic signature on a public key KA, textpublic , but DA - decryption function using the private key KA, textprivate .



The protocol consists of four passes, three of which include the transmission of messages ( [Cheryomushkin 2009] ).



    STS








  1. Alice picks a random number RA:2 leqRA leqp1 .

    Alice \ to \ left \ {A, m_A = g ^ {R_A} \ bmod p \ right \} \ to Bob
  2. Bob picks a random number RB:2 leqRB leqp1 .

    Bob calculates a session key K=mARB bmodp .

    Bob \ to \ left \ {B, A, m_B = g ^ {R_B} \ bmod p, E_K (S_B (m_A, m_B)) \ right \} \ to Alice
  3. Alice calculates a session key K=mBRA bmodp .

    Alice verifies the signature in the message EK(SB(mA,mB)) .

    Alice \ to \ left \ {A, B, E_K (S_A (m_A, m_B)) \ right \} \ to Bob
  4. Bob verifies the signature in the message EK(SA(mA,mB)) .


The protocol ensures the guarantee of the formation of new keys (G10), but not perfect direct secrecy (G9).



As the 1996 Lowe attack ( [Lowe 1996] ) showed, a protocol cannot guarantee authentication of subjects (target G1), keys (G7), and proof of ownership of the session key (G8). Although the attacker cannot gain access to the new session key if the protocol is used only to authenticate the subjects, Alice can mistake the attacker for Bob.



    STS








  1. Alice picks a random number RA:2 leqRA leqp1 .

    Alice \ to \ left \ {A, m_A = g ^ {R_A} \ bmod p \ right \} \ to Mellory ~ (Bob)

  2. Mellory \ to \ left \ {M, m_A \ right \} \ to Bob

  3. Bob picks a random number RB:2 leqRB leqp1 .

    Bob calculates a session key K=mARB bmodp .

    Bob \ to \ left \ {B, M, m_B, E_K (S_B (m_A, m_B)) \ right \} \ to Mellory

  4. Mellory ~ (Bob) \ to \ left \ {B, A, E_K (S_B (m_A, m_B)) \ right \} \ to Alice

  5. Alice calculates a session key K=mBRA bmodp .

    Alice verifies the signature in the message EK(SB(mA,mB)) .

    Alice \ to \ left \ {A, B, E_K (S_A (m_A, m_B)) \ right \} \ to Mellory ~ (Bob)



After successfully completing the protocol, Alice is confident that she is communicating with Bob.



Like all other “cryptosystem-protocols”, the Station-to-Station protocol is based on some external source of information about the public keys of participants, without questioning the correctness and reliability of this source. Which, in the general case, is wrong. If information about the keys of participants needs to be received externally at each protocol session (for example, if there are a lot of participants and there is no possibility to remember the keys for all), then the channel for obtaining public keys will be the main goal of an active cryptanalyst for the considered protocols. How to protect yourself from this using asymmetric cryptography primitives is in the next section.



Literature





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



All Articles