(Very) Basic Intro To White-Box Cryptography
Tags: cryptography, security, crypto
Published: 2020-04-27 13:08:32

---
title: (Very) Basic Intro To White-Box Cryptography
published: true
date: 2020-04-27 13:07:06 UTC
tags: Cryptography,Security,crypto,cryptography
canonical_url: https://qvault.io/2020/04/27/very-basic-intro-to-white-box-cryptography/
---

![](https://qvault.io/wp-content/uploads/2020/04/depositphotos_233639070-stock-video-abstract-3d-monochrom-cube-rotating.jpg?x19005)

White-box cryptography combines methods of encryption and obfuscation to embed secret keys within application code. The goal is to combine code and keys in such a way that the two are indistinguishable to an attacker, and the new “white-box” program can be safely run in an insecure environment.

## What Does “White-Box” Mean?

In penetration testing, white-box testing is where the testers (or attackers) have access to the source code and internal workings of the system.

* * *

_Passing a "white-box" test is harder and requires a higher standard of security than a "black-box" test where the attacker only gets a look at the system from the outside. #whitebox #hacking_  
[Click To Tweet](https://twitter.com/intent/tweet?url=https%3A%2F%2Fwp.me%2Fpb7Qei-i2&text=Passing%20a%20%22white-box%22%20test%20is%20harder%20and%20requires%20a%20higher%20standard%20of%20security%20than%20a%20%22black-box%22%20test%20where%20the%20attacker%20only%20gets%20a%20look%20at%20the%20system%20from%20the%20outside.%20%23whitebox%20%23hacking&via=wagslane&related=wagslane)

* * *

White-box cryptography is appropriately named because attackers have access to the compiled code where the keys exist. The difficult problem that it aims to solve is how to keep those keys safe while using them in execution.

## Kerckhoffs’s Principle

[Kerckhoffs’s principle](https://en.wikipedia.org/wiki/Kerckhoffs%27s_principle) revolutionized the way we think about cryptography. It states that we should allow the attacker to know everything about a crypto implementation, except the key. If a cryptosystem can stand up to that level of scrutiny it will be the better for it.

White-box crypto _kind-of_ takes this one step further. That is, we technically give the attacker access to the key, we just hide/encrypt it well enough that they can’t find it.

## How Does It Work?

In order to secure a program using white-box cryptography, we assume the attacker has complete access to the system. This includes:

- Access to executable binary
- Access to execution memory
- CPU call intercepts

In order to successfully hide the keys given this scenario, according to [Brecht Wyseur](https://www.esat.kuleuven.be/cosic/publications/thesis-152.pdf), we can take the following steps assuming we are trying to white-box a block cipher:

1. **Partial Evaluation** : When performing an operation, we alter the operation based on the key. For example, in the [substitution phase of a block cipher](https://qvault.io/2020/01/02/very-basic-intro-to-aes-256-cipher/), we would change the [lookup table](https://en.wikipedia.org/wiki/S-box) to be dependent on the key. Note that if someone were to see this table, they could derive the key (solved in step 3)
2. **Tabularizing** : Transform all other operations to also use lookup tables. This is possible because lookup tables can describe any function.
3. **Randomization and Delinearization** : We create an encoded chain of lookup tables that has the same functionality as the original chain, but hides the key. Now, using this new chain, we have an obfuscated algorithm. For reading on the details of this operation, see [here](https://www.esat.kuleuven.be/cosic/publications/thesis-152.pdf#page=74).

## Is White-Box Secure In Practice?

Well, it depends. Security through obscurity is a well-known bad-practice in the cryptography industry, but there is an argument to be made that white-box crypto is more than just obfuscation. A recent [2018 paper](https://eprint.iacr.org/2018/098.pdf) on cracking white-box may be insightful.

White box practices have certainly been used, but not many time-tested open-source solutions currently exist. That said, you may be interested in one of the larger (still small) repositories on Github which white-boxes AES in C++: [https://github.com/ph4r05/Whitebox-crypto-AES](https://github.com/ph4r05/Whitebox-crypto-AES)

Intertrust recently claimed to launch the first [enterprise-ready solution](https://www.businesswire.com/news/home/20200224005912/en/Intertrust-Launches-Enterprise-Ready-White-Box-Cryptography-Solution-Web). Reading more on that may give some insight.

Hopefully this gives you a basic understanding of the purpose of white-box crypto, and even a spoiler of how it works from a 1,000 foot level.

Brecht Wyseur’s Thesis on White-Box Crypto: [https://www.esat.kuleuven.be/cosic/publications/thesis-152.pdf](https://www.esat.kuleuven.be/cosic/publications/thesis-152.pdf)

## Thanks For Reading

Hit me up on twitter [@wagslane](https://twitter.com/wagslane) if you have any questions or comments.

Follow me on Dev.to: [wagslane](https://dev.to/wagslane)

The post [(Very) Basic Intro To White-Box Cryptography](https://qvault.io/2020/04/27/very-basic-intro-to-white-box-cryptography/) appeared first on [Qvault](https://qvault.io).