diff --git a/scapy/layers/tls/keyexchange.py b/scapy/layers/tls/keyexchange.py
index <HASH>..<HASH> 100644
--- a/scapy/layers/tls/keyexchange.py
+++ b/scapy/layers/tls/keyexchange.py
@@ -746,7 +746,7 @@ class ClientDiffieHellmanPublic(_GenericTLSSessionInheritance):
 
         if s.client_kx_privkey and s.server_kx_pubkey:
             pms = s.client_kx_privkey.exchange(s.server_kx_pubkey)
-            s.pre_master_secret = pms
+            s.pre_master_secret = pms.lstrip(b"\x00")
             if not s.extms or s.session_hash:
                 # If extms is set (extended master secret), the key will
                 # need the session hash to be computed. This is provided
@@ -780,7 +780,7 @@ class ClientDiffieHellmanPublic(_GenericTLSSessionInheritance):
 
         if s.server_kx_privkey and s.client_kx_pubkey:
             ZZ = s.server_kx_privkey.exchange(s.client_kx_pubkey)
-            s.pre_master_secret = ZZ
+            s.pre_master_secret = ZZ.lstrip(b"\x00")
             if not s.extms or s.session_hash:
                 s.compute_ms_and_derive_keys()
Fix an error in the PMS derivation for DHE key exchange in TLS.

The RFC states that the leading zero bytes must be stripped when storing the
Pre Master Secret. This is bad practice, since it leads to exploitable timing
attacks such as the Raccoon Attack (<URL>). However, this is the standard and the current
implementation leads to handshake failure with a probability of 1/<I>.

The leading zero injunction does NOT apply to ECDHE.