So, I configure my VPN (let say which uses PPTP protocol), enter the server name, username and password. Then, I visit a website. Before that, my request is encrypted using AES with some key. That request is sent to the VPN. How does that VPN decrypt data? How can it know what the key is? How is that key obtained between two parties? Or is the first request is sent with my username and password, VPN checks if user exists, generates the key, and sends it back to the user? But it would be insecure to do that. Also, a different key should be created when I login via mobile.

  • 1
    PPTP doesn't use encryption - it relies on being tunneled within another protocol for security.
    – Nick ODell
    Commented Aug 29, 2013 at 3:51

2 Answers 2


The precise details will depend upon the specific VPN software you use, but generally, the same cryptographic key will be pre-loaded into both ends of the VPN. It may be specified in a configuration file, or derived from a passphrase, or in some other way made available to both endpoints. That's how the VPN software on your machine encrypts data and how the VPN software on the end end can decrypt the encrypted data.


PPTP itself, as specified, does not include any encryption; but the most widely used PPTP implementation, shipped with Windows, includes a non-standard encryption layer, which turned out to be quite poorly done and thus crackable in many ways, some of them generically deadly. In this specific case, the key used for encryption was computed deterministically (through a simple hash function invocation) over the concatenation of the hashed user password, and a random nonce which was exchanged (as cleartext) during the initial authentication step.

In general, for a symmetric key to be shared between two systems, there are two choices:

  • The key is derived from an initial shared secret, which was set through some initialization procedure. This is what Microsoft was doing with PPTP, the "initial secret" being the (hash of) the user's password. The derivation can include some random values (which must be sent from one system to the other) so that a different key is generated each time.

  • A key is generated dynamically with a key agreement protocol. This is the model of SSL, and, indeed, there are VPN implementation which use SSL (e.g. OpenVPN). In order to prevent Man-in-the-Middle attacks, some sort of authentication must occur; SSL uses X.509 certificates. See this answer for some explications on how such a thing as created a shared secret out of thin air can actually work. Differences between a VPN, and a browser-to-Web-server HTTPS connection, are not relevant here: the same concepts apply.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .