Skip to content

hop 28 of 32 · 5 min

Why the padlock is there

Everything so far assumed nobody is listening or interfering. On a shared network both assumptions are wrong.

Three properties

Confidentiality: nobody else can read it. Integrity: nobody changed it in transit. Authentication: it really is who it claims to be.

Encryption alone gives only the first. All three matter, and a system with two of them is broken in a way that is easy to miss.

Two kinds of key

SymmetricAsymmetric
KeysOne, sharedTwo, public and private
SpeedFastAbout 1000x slower
The problem it hasAgreeing the key safelyCost per byte
ExampleAESRSA, elliptic curve

Symmetric uses one shared key for both directions. Fast, and it has a chicken and egg problem: how do you agree the key over a channel you cannot yet trust?

Asymmetric uses a public key anyone may have and a private key only you have. Anyone can encrypt to you; only you can decrypt.

TLS uses both, and this is the important part: asymmetric only at the start, to agree a symmetric key, then symmetric for everything after. You get the key exchange of one and the speed of the other.

Certificates

Asymmetric solves eavesdropping and not impersonation: how do you know the public key you received is really the bank's?

A certificate is that public key, signed by an authority your browser already trusts. The padlock means the certificate is valid, matches the domain, and has not expired. It does not mean the site is honest.

Common attacks

  • Man in the middle: sits between and relays, reading everything. TLS certificates are the defence.
  • Denial of service: overwhelms with traffic. Rate limits and filtering.
  • SQL injection: input treated as code. Parameterised queries, always.
  • Cross-site scripting: someone else's script running on your page. Escape everything you render.