CHARRA comes with a Docker environment and helper scripts to quickly test CHARRA interactively. It is also possible to build and run CHARRA manually. All commands are to be executed in Bash.
The following describes how to run CHARRA in Docker and Docker Compose.
First, Docker and Docker Compose must be installed and . The following command are intended for an Ubuntu (amd64) system.
-
Install Docker (and Docker Compose):
sudo apt update sudo apt install docker.io docker-compose
-
Set group membership to run containers as non-root user:
sudo groupadd docker sudo usermod -aG docker "${USER}"
-
Restart system (to activate group membership):
sudo reboot
Running CHARRA in Docker is the prefered way of running it. This way, you do not need to install all the dependencies into your system just to try CHARRA.
-
Build CHARRA container image(s):
./docker/build.sh
-
Run the CHARRA interactive development environment container:
./docker/run.sh
-
Build the CHARRA container image(s):
docker-compose build --build-arg uid="${UID}" --build-arg gid="${UID}"
-
Run the CHARRA interactive development environment container:
docker-compose run --rm charra-dev-env
Please follow the steps in the Dockerfile
to build and install dependencies manually directly into your system.
Once all dependencies are installed, or you have the container running, change to the root folder of your local copy of CHARRA (in the container do a cd ~/charra/
).
-
Compile CHARRA:
make -j
-
Run CHARRA:
(bin/attester &); sleep .2 ; bin/verifier ; sleep 1 ; pkill -SIGINT attester
If you see a message "ATTESTATION SUCCESSFUL", it worked.
CHARRA comes with some build arguments that you find in the following.
Argument | Default | Available Options | Description |
---|---|---|---|
TCTI_MODULE |
tctildr |
tcti-default , tcti-cmd , tcti-device , tcti-libtpms , tcti-mssim , tcti-pcap , tcti-swtpm , tctildr (and other implementations ) |
Configure the TCTI module for the TPM |
ENABLE_LOGGING |
1 (enabled) |
0 (disabled), != 0 (enabled) |
Enable/disable log output |
ENABLE_LOGGING_COLOR |
1 (enabled) |
0 (disabled), != 0 (enabled) |
Enable/disable colored log output |
ENABLE_ADDRESS_SANITIZER |
0 (disabled) |
0 (disabled), != 0 (enabled) |
Enable/disable AddressSanitizer (ASan) |
ENABLE_LEAK_SANITIZER |
0 (disabled) |
0 (disabled), != 0 (enabled) |
Enable/disable LeakSanitizer (LSan) |
ENABLE_PIC |
1 (enabled) |
0 (disabled), != 0 (enabled) |
Emit position-independent code |
ENABLE_STRIPPING |
1 (enabled) |
0 (disabled), != 0 (enabled) |
Remove all symbols that are not needed for relocation processing |
LINK_MODE |
dynamic |
dynamic , static (currently not working) |
Link executables statically or dynamically |
Example invocation:
make TCTI_MODULE=tcti-mssim ENABLE_LOGGING_COLOR=0 ENABLE_STRIPPING=0
If you're interested in delving further and modifying the building and operational conditions of CHARRA, this section provides valuable information.
-
Start the TPM Simulator (and remove the state file
NVChip
):(cd /tmp ; pkill tpm_server ; rm -f NVChip; /usr/local/bin/tpm_server > /dev/null &)
-
Send TPM startup command:
/usr/local/bin/tpm2_startup -Tmssim --clear
-
Run Attester and Verifier:
(bin/attester &); sleep .2 ; bin/verifier ; sleep 1 ; pkill -SIGINT -f bin/attester
If you see a message "ATTESTATION SUCCESSFUL", it worked.
-
Clang
scan-build
:make clean ; scan-build make
-
Valgrind:
(valgrind --leak-check=full \ --show-leak-kinds=all -v \ bin/attester \ 2> attester-valgrind-stderr.log &); \ sleep .2 ; \ (valgrind --leak-check=full \ --show-leak-kinds=all -v \ bin/verifier\ 2> verifier-valgrind-stderr.log) ;\ sleep 1 ; \ pkill -SIGINT -f bin/attester
-
AddressSanitizer (ASan):
make clean ; make ENABLE_ADDRESS_SANITIZER=1 (bin/attester &); sleep .2 ; bin/verifier ; sleep 1 ; pkill -SIGINT -f bin/attester
The attester and verifier can be used on two different devices. To do that, you have to provide an external network for the attester Docker container.
-
Create macvlan network for attester Docker container (check your gateway address and replace
x
with the correct number):docker network create -d macvlan \ --subnet=192.168.x.0/24 \ --gateway=192.168.x.1 \ -o parent=eth0 pub_net
-
Add
--network
parameter to thedocker run
command in thedocker/run.sh
on the attester device:## run (transient) Docker container /usr/bin/docker run --rm -it \ -v "${PWD}/:/home/bob/charra" \ --network=pub_net \ "${docker_image_fullname}" \ "$@"
-
Run the attester Docker container and check the IP address.
-
Put the attester address to the
DST_HOST
insrc/verifier.c
on the verifier device. Rebuild the verifier in the verifier Docker container:cd charra make -j
-
Go to
charra
directory and run attester binary in the attester Docker container:cd charra bin/attester
-
Run the verifier binary in the verifier docker container:
/bin/verifier
If you see a message "ATTESTATION SUCCESSFUL", it worked.