A method for applying PAKE to SSH protocol key exchange
By embedding PAKE into the SSH protocol, key exchange and user authentication are integrated, solving the problem of multiple interaction rounds in the SSH protocol, improving connection efficiency and enhancing security.
Patent Information
- Application Number
- CN202611525028.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-29
- Publication Date
- 2026-11-17
AI Technical Summary
The separation of key exchange and user authentication in the existing SSH protocol leads to problems such as multiple rounds of interaction and low connection establishment efficiency.
Applying PAKE to the SSH protocol key exchange phase optimizes the overall interaction rounds of the SSH protocol by embedding a password authentication mechanism to simultaneously complete key negotiation and user authentication during the key exchange process.
It reduces the number of interaction rounds in the SSH protocol, improves connection establishment efficiency, reduces the risk of client key material leakage, and is compatible with classical DH and quantum-resistant KEM key exchange, possessing good scalability and security.
Smart Images

Figure CN123122845A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of information security technology, specifically relating to a key exchange method for SSH (Secure Shell) protocol, and particularly to a method and apparatus for applying PAKE (Password Authenticated Key Exchange) to SSH protocol key exchange. Background Technology
[0002] The SSH protocol is a widely used secure remote login protocol on the Internet. The SSH protocol framework divides the connection establishment process into three layers: transport layer protocol, user authentication protocol, and connection protocol. In the transport layer protocol, the client and server first negotiate and generate a session key through a key exchange (KEX) to establish an encrypted channel; then, in the user authentication phase, the client requests the service and proves its identity to the server (e.g., through password authentication or public key authentication); only after successful authentication does the connection phase begin for actual data transmission.
[0003] Existing SSH key exchange methods (such as diffie-hellman-group-exchange-sha256, curve25519-sha256, etc.) only implement key negotiation and do not include user authentication. User authentication needs to be completed through a separate user authentication protocol phase after key exchange. This two-phase design of "key exchange first, user authentication later" makes the SSH protocol framework highly flexible, but it involves many protocol interaction rounds and has low connection establishment efficiency. Summary of the Invention
[0004] To address the issues of multiple interaction rounds and low connection establishment efficiency caused by the separation of key exchange and user authentication in the existing SSH protocol, this disclosure provides a method for applying PAKE to the key exchange phase of the SSH protocol. By embedding the password authentication mechanism into the key exchange process, key negotiation and user authentication are completed simultaneously during the key exchange phase, thereby skipping the user authentication phase in the original protocol framework and optimizing the overall interaction rounds of the SSH protocol.
[0005] This method includes an offline registration phase and an online key exchange phase for PAKE, as well as an application design method based on SSH protocol extensions for PAKE: During the offline registration phase, the client and server interact based on a shared password to derive hashes H1 and H2. H1 is used for symmetric encryption, and H2 serves as a seed to generate the client authentication key pair. The server stores H1 and the client's authentication public key, while the client does not store any registration materials. During the online key exchange phase, the client and server exchange keys based on a temporary key pair to generate a first shared key K1. The client then derives H2 again to generate an authentication key pair, and performs encapsulation / decapsulation operations with the server based on the authentication key to generate a second shared key K2. The client generates a MAC address based on K1 and K2, and if the server verifies it, the key exchange and user authentication are complete.
[0006] By extending the SSH protocol framework, the above-mentioned password authentication key exchange method is added to the SSH key exchange algorithm list. After the key exchange is completed, the user authentication status is configured as completed, and the encrypted transmission stage can be directly entered, skipping the user authentication interaction process in the original SSH protocol framework, thereby optimizing the protocol interaction rounds.
[0007] Specifically, the method provided in this disclosure includes the following steps: S1, Offline Registration Stage: The client and server interact based on a shared password to generate derived hashes H1 and H2 based on the password. H1 is used for symmetric encryption in the password authentication key exchange process, and H2 is used as a seed to generate a client authentication key pair. The client does not store any materials generated during the registration stage, and the server stores H1 and the generated client authentication public key PK. S2, Online Key Exchange Phase: S21, the client generates a temporary key pair for key exchange, and exchanges keys with the server based on the temporary key pair to generate the first shared key respectively; S22, the client uses the same method as in the offline registration phase to re-derive H2 based on the shared password and generate a client authentication key pair; the server uses the stored client authentication public key PK for encapsulation, and the client uses the re-derived authentication private key for decapsulation, each generating a second shared key; S23, the client generates a message authentication code based on its first and second shared keys and sends it to the server; S24, the server generates a message authentication code based on its local first and second shared keys, and compares it with the message authentication code received from the client. If they match, the key exchange is considered successful and the client's identity authentication is successful.
[0008] Furthermore, in step S1, the derived hashes H1 and H2 are generated by combining a password-based key derivation function PBKDF or a cryptographic hash function with a salt value, wherein the salt value is provided by the server or determined by negotiation between the client and the server.
[0009] Furthermore, step S21 can be completed using classic Diffie-Hellman (DH) key exchange, specifically including: The client generates a temporary key pair (SK1,PK1), encrypts the temporary public key PK1 using H1 to generate ciphertext C1=Enc(H1,PK1), and sends C1 to the server. The server generates a temporary key pair (SK2, PK2), decrypts it using H1 to obtain the client's temporary public key PK1, and uses SK2 and PK1 to perform a classic DH key exchange to generate the first shared key. The server sends its own temporary public key PK2 to the client; The client uses SK1 and PK2 to perform a classic DH key exchange to generate its first shared key.
[0010] Furthermore, step S21 can be completed using a quantum-resistant key encapsulation mechanism, specifically including: The client generates a temporary key pair (SK1,PK1), encrypts the temporary public key PK1 using H1, generates ciphertext C1=Enc(H1,PK1), and sends C1 to the server. The server uses H1 to decrypt and obtains the client's temporary public key PK1. PK1 is then used for quantum-resistant encapsulation to generate the encapsulated ciphertext C1' and the first shared key. The server sends the encapsulated ciphertext C1' to the client; The client uses SK1 to perform quantum-resistant de-encapsulation of the encapsulated ciphertext C1', generating a first shared key.
[0011] Furthermore, step S21 can employ a hybrid parallel key exchange based on classical cryptographic algorithms and quantum-resistant cryptographic algorithms, specifically as follows: During a single key exchange, the client and server perform classical DH key exchange and quantum-resistant KEM key exchange in parallel, generating classical shared key components and quantum-resistant shared key components respectively, which are then combined as their respective first shared keys.
[0012] Furthermore, in step S22, the server uses the stored client authentication public key PK for encapsulation, and the client uses the newly derived private key for decapsulation, each generating a second shared key, specifically including: The server uses the stored client authentication public key PK to encapsulate the data, generating encapsulated ciphertext C2 and a second shared key, and then sends C2 to the client. The client uses the private key from the re-derived client authentication key pair to decapsulate C2 and generate its second shared key.
[0013] Furthermore, in steps S23 and S24, the method by which the client or server generates the MAC based on the first shared key K1 and the second shared key K2 includes, but is not limited to: MAC = Hash(K1 || K2) or MAC = Hash(K1) ⊕ Hash(K2), Hash is a cryptographically secure hash function.
[0014] Furthermore, the method also includes the following steps: Based on the algorithm extension design in the SSH protocol framework, the above method is defined as a password-based online authentication key exchange method. The method is marked by adding the "pake" identifier and added to the list of key exchange algorithms supported by the SSH protocol.
[0015] Furthermore, the password-based online authentication key exchange method completes key exchange and user authentication simultaneously during the key exchange phase, and then directly enters the encrypted transmission phase, without executing the user authentication interaction process after key exchange in the original SSH protocol framework.
[0016] Compared with the prior art, the beneficial effects of this disclosure are: ① By utilizing the PAKE protocol's ability to simultaneously complete key exchange and authentication, user authentication in the SSH protocol is embedded in the key exchange phase. Once the key exchange is complete, the user authentication status can be configured as completed, skipping the user authentication steps in the original SSH protocol framework. This significantly reduces the number of protocol interaction rounds and improves the efficiency of establishing SSH connections. ②The client does not store any registration-generated materials during the registration phase. The authentication key is regenerated in real time based on the shared password each time an online key is exchanged, which reduces the risk of client key material leakage; ③ It is compatible with classical DH key exchange, quantum-resistant KEM key exchange, and a hybrid parallel scheme of the two, and has good scalability and adaptability. The hybrid parallel scheme has both classical cryptographic security and quantum security of quantum-resistant cryptography. ④ In accordance with the algorithm extension requirements in the SSH protocol framework, the custom method is added to the SSH key exchange algorithm list, which conforms to the extension mechanism of the SSH protocol and is conducive to the smooth and agile improvement of protocol capabilities. Attached Figure Description
[0017] The above and other objects, features and advantages of this disclosure will become more apparent from the more detailed description of exemplary embodiments of this disclosure taken in conjunction with the accompanying drawings, in which the same reference numerals generally represent the same components.
[0018] Figure 1This is a logic diagram of the interaction between the offline registration and online key exchange phases based on PAKE. Figure 2 This diagram illustrates the application of PAKE-based key exchange in the SSH protocol. Detailed Implementation
[0019] Preferred embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. While preferred embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be thorough and complete, and will fully convey the scope of the present disclosure to those skilled in the art.
[0020] This disclosure provides a method and apparatus for applying PAKE to SSH protocol key exchange. By utilizing the ability of the PAKE protocol to simultaneously complete key exchange and authentication, a method is constructed that can deeply integrate password authentication and key exchange, and complete user authentication simultaneously during the key exchange stage. This reduces the number of interaction rounds in the SSH protocol, improves connection establishment efficiency, and is compatible with classical cryptography and quantum-resistant cryptography.
[0021] This method specifically includes: offline registration of PAKE, online key exchange, and the method of embedding PAKE in the SSH protocol. A general implementation example is attached. Figure 1 As shown, the main steps include: (1) Offline registration stage: The client and server interact based on a shared password, generating password-derived hashes H1 and H2. H1 is used for symmetric encryption during the password authentication key exchange process, and H2 serves as a seed to generate the client authentication key pair (SK, PK), where SK is the client authentication private key and PK is the client authentication public key. The client does not store any materials generated during the registration phase; the server stores H1 and the client authentication public key PK.
[0022] During the offline registration phase, a client authentication key is generated. This key is used for client authentication during subsequent online key exchange. However, for security reasons, if the client stores sensitive information such as the authentication key for an extended period, it risks being obtained by attackers. This is because, in practical applications, client security capabilities are limited, while the server can employ security facilities such as key management centers and secure databases for data protection. Therefore, the client does not store the authentication key permanently. It is only provided to the server securely during the registration phase. In the subsequent key exchange phase, because the client needs to prove that it has the private key for the authentication key, it will use the same calculation method to derive a new authentication key from the password and participate in the key exchange calculation. If the subsequent key exchange is successful, it indicates that the client has derived the correct authentication key, thus proving that the client possesses the correct password.
[0023] In standard SSH protocol user password authentication, the password is entered by the user, and the SSH client is assumed to hold the password. Materials generated during the registration phase, such as the H1 and PK, are not stored by the client. For each subsequent login, the client still only requires the user to enter the password through the interactive window. The client can then derive a new authentication key from the password for user authentication calculations during the key exchange phase, without needing to re-register. The offline registration process involves the server holding the legitimate client's authentication public key (PK), which is used by the server to authenticate the client's identity during the key exchange phase.
[0024] Derived hashes H1 and H2 can be generated by combining a password-based key derivation function (such as PBKDF2) or a cryptographic hash function with a salt value, which is provided by the server or determined by negotiation between the client and the server.
[0025] (2) Online key exchange phase: The client generates a temporary key pair for key exchange and exchanges keys with the server based on the temporary key pair to generate the first shared key K1. This step can employ classical Diffie-Hellman (DH) key exchange, quantum-resistant key encapsulation (KEM) mechanism, or a hybrid parallel scheme of both.
[0026] The client re-derives H2 based on the shared password in the same way as in the offline registration phase and generates a client authentication key pair (SK', PK').
[0027] The client and server perform encapsulation / decapsulation operations based on the authentication key pair: the server uses the stored client authentication public key PK to encapsulate and generate the encapsulated ciphertext C2 and the second shared key K2; the client uses the re-derived authentication private key SK' to decapsulate C2 and generate the second shared key.
[0028] The client generates a message authentication code (MAC) based on K1 and K2 (e.g., MAC = Hash(K1||K2) or adds common parameters and interaction context to the hash) and sends it to the server. The server generates a MAC locally based on K1 and K2, and compares it with the received client MAC. If they match, the key exchange is successful and the client's identity is successfully authenticated.
[0029] In this process, the server uses the client authentication public key generated during the offline registration phase. This public key is stored by the server after registration, but not by the client. The server encapsulates the encrypted data using the stored client authentication public key. The client needs to derive a new authentication key pair using the password and decapsulate the ciphertext sent by the server using its private key. Only after successful decapsulation can the client obtain the same shared key. Successful key verification indicates that the shared key was generated correctly, which in turn means that decapsulation and authentication key generation were successful. This confirms that the client possesses the correct password, thus authenticating the client's identity.
[0030] (3) Algorithm registration and process optimization: The SSH protocol has an extension mechanism that supports key exchange algorithms. For example, the open-source implementation OpenSSH allows new key exchange methods to be added to the list of algorithms supported by the protocol through algorithm registration.
[0031] Based on the algorithm extension requirements in the SSH protocol framework, the above-mentioned password-based online key exchange method is defined (the key exchange method name carries the identifier "pake"), and this method is added to the list of key exchange algorithms supported by the SSH protocol. See attached... Figure 2 As shown, since the custom key exchange method completes both key exchange and user authentication during the key exchange phase, by configuring the user authentication status to "completed," the SSH protocol can directly enter the encrypted transmission phase after completing the custom key exchange, skipping the service request and user authentication interaction processes after key exchange in the original SSH protocol framework, thus reducing the overall number of interaction rounds in the SSH protocol.
[0032] This method is compatible with classical DH key exchange, quantum-resistant KEM key exchange, and a hybrid parallel scheme of both. Specific examples are illustrated below: Example 1: Implementation based on classic DH key exchange Step 1 (Offline Registration Phase): The client and server generate derived hashes H1 and H2 based on a shared password. H1 is used for symmetric encryption during the password authentication key exchange process, and H2 serves as a seed to generate the client authentication key pair (SK, PK). The client does not store the registration generation materials, while the server stores H1 and the client authentication public key PK.
[0033] Step 2: The client generates a temporary key pair (SK1, PK1) for key exchange, encrypts the temporary public key PK1 using H1, generates ciphertext C1=Enc(H1, PK1), and sends the ciphertext C1 to the server.
[0034] Step 3: The server generates a temporary key pair (SK2, PK2) for key exchange. It decrypts this pair using H1 to obtain the client's temporary public key PK1. Then, it performs a classic DH key exchange using SK2 and PK1 to generate a shared key K1. The server encapsulates this shared key using the client's authentication public key PK, generating a ciphertext C2 and the shared key K2. The server then sends its temporary public key PK2 and the ciphertext C2 to the client.
[0035] Step 4: The client uses SK1 and PK2 to perform a classic DH key exchange, generating a shared key K1'. The client then uses the same method as in the registration phase to regenerate H2' based on the password and generate an authentication key pair (SK', PK'). SK' is used to decapsulate C2, generating the shared key K2'. The client generates a MAC' based on K1' and K2' and sends it to the server.
[0036] Step 5: The server generates a MAC address locally based on K1 and K2, and compares it with the received client MAC address. If they match, the key exchange is successful and the client authentication is successful.
[0037] Example 2: Implementation based on quantum-resistant KEM key exchange Step 1 (Offline Registration Stage): Same as Step 1 in Example 1.
[0038] Step 2: The client generates a temporary key pair (SK1, PK1) for key exchange, encrypts the temporary public key PK1 using H1, generates ciphertext C1=Enc(H1, PK1), and sends the ciphertext C1 to the server.
[0039] Step 3: The server uses H1 to decrypt and obtain the client's temporary public key PK1. It then uses PK1 for quantum-resistant encapsulation (e.g., lattice-based post-quantum KEM) to generate the encapsulated ciphertext C1' and the shared key K1. The server then uses the client's authentication public key PK for encapsulation, generating the encapsulated ciphertext C2 and the shared key K2. The server sends the encapsulated ciphertext C1' and C2 to the client.
[0040] Step 4: The client uses SK1 to perform quantum-resistant decapsulation of C1', generating a shared key K1'. The client then uses the same method as in the registration phase to regenerate H2' based on the password and generate an authentication key pair (SK', PK'). SK' is used to decapsulate C2, generating a shared key K2'. The client generates a MAC' based on K1' and K2' and sends it to the server.
[0041] Step 5: The server generates a MAC address locally based on K1 and K2, and compares it with the received client MAC address. If they match, the key exchange is successful and the client authentication is successful.
[0042] Example 3: Parallel Implementation of Classical Cryptography and Quantum-Resistant Cryptography In steps 2-4, the client and server perform classical DH key exchange and quantum-resistant KEM key exchange in parallel during a single key exchange. Specifically: In step 2, the client generates a classical temporary key pair and a quantum-resistant temporary key pair, which are then encrypted using H1 and sent to the server.
[0043] In step 3, the server performs classical DH key exchange and quantum-resistant KEM encapsulation respectively to generate classical shared key component K1_DH and quantum-resistant shared key component K1_KEM, which are combined as the first shared key K1 (e.g., K1=K1_DH⊕K1_KEM or K1=Hash(K1_DH||K1_KEM)).
[0044] In step 4, the client performs classical DH key exchange and quantum-resistant KEM decapsulation respectively, generating the corresponding shared key components and combining them into K1'.
[0045] The remaining steps are the same as in Example 1 or Example 2. This hybrid parallel scheme possesses both classical cryptographic security and quantum security resistant to quantum cryptography.
[0046] The above technical solutions are merely exemplary embodiments of the present invention. For those skilled in the art, based on the application methods and principles disclosed in the present invention, it is easy to make various types of improvements or modifications, and not limited to the methods described in the specific embodiments of the present invention. Therefore, the methods described above are merely preferred and not restrictive.
Claims
1. A method for applying PAKE to SSH protocol key exchange, characterized in that, Includes the following steps: S1, Offline Registration Stage: The client and server interact based on a shared password to generate derived hashes H1 and H2 based on the password. H1 is used for symmetric encryption in the password authentication key exchange process, and H2 is used as a seed to generate a client authentication key pair. The client does not store any materials generated during the registration stage, and the server stores H1 and the generated client authentication public key PK. S2, Online Key Exchange Phase: S21, the client generates a temporary key pair for key exchange, and exchanges keys with the server based on the temporary key pair to generate the first shared key respectively; S22, the client uses the same method as the offline registration phase to re-derive H2 based on the shared password and generate a client authentication key pair; The server uses the stored client authentication public key PK for encapsulation, and the client uses the newly derived authentication private key for decapsulation, each generating a second shared key. S23, the client generates a message authentication code based on its first and second shared keys and sends it to the server; S24, the server generates a message authentication code based on its local first and second shared keys, and compares it with the message authentication code received from the client. If they match, the key exchange is considered successful and the client's identity authentication is successful.
2. The method according to claim 1, characterized in that, In step S1, the derived hashes H1 and H2 are generated by combining a password-based key derivation function PBKDF or a cryptographic hash function with a salt value, which is provided by the server or determined by negotiation between the client and the server.
3. The method according to claim 1, characterized in that, Step S21 is completed using the classic Diffie-Hellman key exchange, specifically including: The client generates a temporary key pair (SK1,PK1), encrypts the temporary public key PK1 using H1 to generate ciphertext C1=Enc(H1,PK1), and sends C1 to the server. The server generates a temporary key pair (SK2, PK2), decrypts it using H1 to obtain the client's temporary public key PK1, and uses SK2 and PK1 to perform a classic DH key exchange to generate the first shared key. The server sends its own temporary public key PK2 to the client; The client uses SK1 and PK2 to perform a classic DH key exchange to generate its first shared key.
4. The method according to claim 1, characterized in that, Step S21 is completed using a quantum-resistant key encapsulation mechanism, specifically including: The client generates a temporary key pair (SK1,PK1), encrypts the temporary public key PK1 using H1, generates ciphertext C1=Enc(H1,PK1), and sends C1 to the server. The server uses H1 to decrypt and obtains the client's temporary public key PK1. PK1 is then used for quantum-resistant encapsulation to generate the encapsulated ciphertext C1' and the first shared key. The server sends the encapsulated ciphertext C1' to the client; The client uses SK1 to perform quantum-resistant de-encapsulation of the encapsulated ciphertext C1', generating a first shared key.
5. The method according to claim 1, characterized in that, Step S21 employs a hybrid parallel key exchange based on classical cryptography and quantum-resistant cryptography, specifically as follows: During a single key exchange, the client and server perform classical DH key exchange and quantum-resistant KEM key exchange in parallel, generating classical shared key components and quantum-resistant shared key components respectively, which are then combined as their respective first shared keys.
6. The method according to claim 1, characterized in that, In step S22, the server uses the stored client authentication public key PK for encapsulation, and the client uses the newly derived private key for decapsulation, each generating a second shared key, specifically including: The server uses the stored client authentication public key PK to encapsulate the data, generating encapsulated ciphertext C2 and a second shared key, and then sends C2 to the client. The client uses the private key from the re-derived client authentication key pair to decapsulate C2 and generate its second shared key.
7. The method according to claim 1, characterized in that, In steps S23 and S24, the method by which the client or server generates a MAC based on the first shared key K1 and the second shared key K2 includes: MAC = Hash(K1 || K2) or MAC = Hash(K1) ⊕ Hash(K2), Hash is a cryptographically secure hash function.
8. The method according to any one of claims 1-7, characterized in that, It also includes the following steps: Based on the algorithm extension design in the SSH protocol framework, the method described in any one of claims 1-7 is defined as a password-based online key exchange method, and this method is added to the list of key exchange algorithms supported by the SSH protocol.
9. The method according to claim 8, characterized in that, The password-based online key exchange method also completes user authentication during the key exchange phase. After the key exchange is completed, it directly enters the encrypted transmission phase and no longer executes the user authentication interaction process after key exchange in the original SSH protocol framework.
