Experiment setup for measuring TLS resource consumption
Find a file
2025-12-01 17:02:32 +01:00
records Plots, fixes 2025-11-14 11:49:22 +01:00
.gitignore Profile graphs 2025-11-26 17:05:05 +01:00
exp.py CertVerify 2025-12-01 17:02:32 +01:00
exp_proxies.py Initial commit 2025-11-05 14:28:26 +01:00
install-certs-arch.sh Initial commit 2025-11-05 14:28:26 +01:00
install-certs-debian.sh Initial commit 2025-11-05 14:28:26 +01:00
mkcacert.sh Initial commit 2025-11-05 14:28:26 +01:00
mkcert.sh Initial commit 2025-11-05 14:28:26 +01:00
mkcerts.sh Initial commit 2025-11-05 14:28:26 +01:00
plots.py CertVerify 2025-12-01 17:02:32 +01:00
profile.py CertVerify 2025-12-01 17:02:32 +01:00
README.md CertVerify 2025-12-01 17:02:32 +01:00
run.sh Initial commit 2025-11-05 14:28:26 +01:00

TLS power measure benchmark

Goal: measure the power overhead of adding TLS to a client or a server, on realistic loads.

Realistic load implies using a real-world client (such as a web browser on a low-end device) and server (such as a video streaming platform on a typical server).

Problem: realistic clients have complex behaviors that go beyond a simple OpenSSL example code, and modern browsers and website won't work without HTTPS.

Assumption: most of the load added by the security layers is decoupled from the application (in both web browsers and web servers).

Experiments:
1: (Client) <=[TLS]=> (Proxy 1) <-[plain]-> (Proxy 2) <-[plain]-> (Proxy 3) <=[TLS]=> (Server)
2: (Client) <=[TLS]=> (Proxy 1) <==[TLS]==> (Proxy 2) <-[plain]-> (Proxy 3) <=[TLS]=> (Server)
3: (Client) <=[TLS]=> (Proxy 1) <-[plain]-> (Proxy 2) <==[TLS]==> (Proxy 3) <=[TLS]=> (Server)
                                            ^measure^

Client and server are identical in all experiments. The only modification made to the client is to add a trusted certificate owned by Proxy 1.

Only Proxy 2 must be a dedicated machine. The other parties may be placed on the same machine.

Call E1, E2, E3 the energy measured for Proxy 2 in experiments 1, 2, 3.

E2-E1 is the energy used to operate the server's half of a TLS connection.

E3-E1 is the energy used to operate the client's half of a TLS connection.

Client:

  • Web browser trusting a certificate owned by Proxy 1

Things to experiment

  • Implementations
    • OpenSSL 1.0.2
    • OpenSSL 1.1.1
    • OpenSSL 3.0
    • OpenSSL 3.2
    • OpenSSL 3.3
    • OpenSSL 3.4
    • OpenSSL 3.5
    • OpenSSL 3.6
    • WolfSSL
    • GnuTLS
    • NSS (used by Firefox) (?)
    • opencryptoki (?)
    • AWS-LC
    • BoringSSL (Chrome, Android)
    • LibreSSL
    • SymCrypt (used by Windows) (install manually)
  • Versions
    • TLS 1.2
    • TLS 1.3
  • Features
    • TLS
      • Ciphers
        • TLS_AES_128_GCM_SHA256
        • TLS_AES_256_GCM_SHA384
        • TLS_CHACHA20_POLY1305_SHA256
        • TLS_AES_128_CCM_SHA256
        • TLS_AES_128_CCM_8_SHA256
      • Key exchange groups
        • secp256r1
        • secp384r1
        • secp521r1
        • x25519
        • x448
        • ffdhe2048
        • ffdhe3072
        • ffdhe4096
        • ffdhe6144
        • ffdhe8192
      • Signatures
        • rsa_pkcs1_sha256
        • rsa_pkcs1_sha384
        • rsa_pkcs1_sha512
        • ecdsa_secp256r1_sha256
        • ecdsa_secp384r1_sha384
        • ecdsa_secp521r1_sha512
        • rsa_pss_rsae_sha256
        • rsa_pss_rsae_sha384
        • rsa_pss_rsae_sha512
        • ed25519
        • ed448
        • rsa_pss_pss_sha256
        • rsa_pss_pss_sha384
        • rsa_pss_pss_sha512
        • rsa_pkcs1_sha1
        • ecdsa_sha1
    • X.509
      • Signature algorithm
        • RSA2048
        • RSA3072
        • RSA4096
        • EC 256
        • EC 384
      • SCT
        • TODO !!!
  • Usages
    • Video streaming
    • Full-speed download
    • Real-time video call
    • Mostly text browsing
    • With or without ads

Most of the implementations can be used through RusTLS.

However RusTLS clients won't enable to force TLS1.2 if 1.3 is available.

  • séparer conso crypto / trafic
  • mesure avec debugger : quelles fonctions consomment
  • mesure mémoire
  • mesure overhead

WolfSSL

git clone https://github.com/wolfSSL/wolfssl --depth 1
cd wolfssl
sh autogen.sh
./configure --enable-all --enable-all-crypto --disable-shared --prefix=/opt/wolfssl-rs/
make
sudo make install

State of the art

Sources

Reproduce

Record

Authorize rpxy and netreplay to bind to ports 80 and 443:

sudo setcap CAP_NET_BIND_SERVICE=+eip netreplay

Open Firefox with a dedicated profile: (create the profile using the GUI if it doesn't exist)

firefox -P tlsbench

In settings, disable DNS security.

In about:config, set devtools.chrome.enabled to true.

In the about:config tab, open the console, execute this script to override DNS for the selected names, and redirect them to localhost:

const gOverride = Cc["@mozilla.org/network/native-dns-override;1"].getService(Ci.nsINativeDNSResolverOverride);
gOverride.clearOverrides();
var names = [
	"apple.com", "www.apple.com",
	"yt3.ggpht.com",
	"accounts.google.com", "www.google.com",
	"fonts.gstatic.com", "www.gstatic.com",
	"mzstatic.com",
	"wikimedia.org", "intake-analytics.wikimedia.org", "meta.wikimedia.org", "upload.wikimedia.org",
	"wikipedia.org", "fr.wikipedia.org",
	"youtube.com", "www.youtube.com",
	"i.ytimg.com"
];
for(var i in names) {
	gOverride.addIPOverride(names[i], "127.0.0.1");
}

Stop anything running on ports 80 or 443.

Start the record proxy:

./netreplay records/mynewrecord record

Just browse. Any traffic to and from the selected names will be recorded. Terminate netplayer with CTRL+C when finished.

Measure

Measure resource cost on a different machine.

Add p2 the /etc/hosts:

192.168.3.14	p2

Install sa on p2:

sudo apt install acct
sudo chmod +s /sbin/sa

Run:

python exp.py make pi -c
python exp.py send pi
python exp.py update-certs # also do this command on p2
python exp.py run pi --idle

On Debian, update-certs says 0 certs added even if it has actually updated some certs. This step is still needed.

Profile

Profile code execution on the local machine.

Add the domains the /etc/hosts:

127.0.0.1	google.com.localhost
127.0.0.1	www.google.com.localhost
# etc.

Install sa:

sudo apt install acct
sudo chmod +s /sbin/sa

Install OpenSSL with debug symbols:

#./Configure --release -g
# Options from Debian build
# Debian package libssl3t64 -> Developer Information -> buildd reproducibility -> trixie rbuild
# https://tests.reproducible-builds.org/debian/rb-pkg/trixie/amd64/openssl.html
/usr/bin/perl ./Configure --release -g --prefix=/usr --openssldir=/usr/lib/ssl --libdir=lib/x86_64-linux-gnu shared no-idea no-mdc2 no-rc5 no-ssl3 no-ssl3-method enable-rfc3779 enable-cms no-capieng no-rdrand enable-tfo enable-zstd enable-zlib enable-fips enable-ec_nistp_64_gcc_128

Backup your system's libcrypto.so and libssl.so and replace them with the new ones. It would be simpler with LD_PRELOAD but Rust loads dynamic libraries in a particuliar way so it doesn't work.

Authorize non-root users to use perf:

sudo sysctl kernel.perf_event_paranoid=-1

Run:

python exp.py make local -c
python exp.py send local
python exp.py update-certs
python exp.py run local
python plots.py prof <path/to/log>

Problems

Youtube

Youtube utilise des trucs aléatoires en RANDOM.googlevideo.com pour la vidéo. Cependant il y a quelques domaines utilisés qui ne changent pas, du moins sur un même navigateur avec la même vidéo et sur une courte période. Avant d'enregistrer le trafic, il faut observer les domaines utilisés puis générer les certificats et les redirections en fonction.

Notes

CertVerify

CertVerify est l'extension dans le ServerHello qui signe la discussion passée avec la clé secrète du certificat.

Il a fallu désactiver la réutilisation de session, qui en TLS1.3 passe par le PSK, pour pouvoir mesurer le CertVerify.