My progress through the book Implementing SSL/TLS Using Cryptography and PKI by Joshua Davies.
Tip
Decode hex with CyberChef.
Build the whole project with CMake
# generate the build system
cmake -S ./ -B ./build
# build the main project
cmake --build ./build
# build just one target
cmake --build ./build [-t <webserver|http|base64|hex|des|aes>]-g: https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Debugging-Options.html#index-g-I: https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Directory-Options.html#index-I-o: https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/Overall-Options.html#index-output-file-option
# linux can omit linking ws2_32
gcc -o webserver.exe ./src/webserver/webserver.c -lws2_32
gcc -o http.exe ./src/http/http.c -lws2_32- Start the webserver listening on port 80
./build/ssl-tls/webserver/Debug/webserver.exe- In a new terminal make a request with the http client to
http://localhost/test
./build/ssl-tls/http/Debug/http.exe http://localhost/test
# Connecting to host 'localhost'
# Retrieving document: 'test'
# HTTP/1.1 200 Success
# Connection: Close
# Content-Type:text/html
# <html><head><title>Test Page</title></head><body>Nothing here</body></html>
# shutting down.- Quit the webserver
CTRL[CMD]+C
Note
DES is intended to be used as a library. Yet, a test routine is included that can be enabled with the compiler option -DTEST_DES.
# Manual compilation
gcc -DTEST_DES -g -o des -Isrc/lib/hex -Isrc/lib/utility src/lib/hex/hex.c src/lib/utility/utility.c src/lib/des/des.cImportant
DES is an 8 byte block cipher. Hence, the key and initialization vector (iv) must be 8 bytes and the input must be a multiple of 8 bytes.
# DES
# ./des.exe [-e|-d] <key> <iv> <input>
./des.exe -e password initialz abcdefgh
# 71828547387b18e5
./des.exe -d password initialz 0x71828547387b18e5
# 6162636465666768Note
DES3 uses a 24 byte (key.
# DES3
./des -e twentyfourcharacterinput initialz abcdefgh
# c0c48bc47e87ce17
./des -d twentyfourcharacterinput initialz 0xc0c48bc47e87ce17
# 6162636465666768# Manual compilation
gcc -DTEST_AES -g -o aes -Isrc/lib/hex -Isrc/lib/utility src/lib/aes/aes.c src/lib/utility/utility.c src/lib/hex/hex.c# encrypt
./aes -e passwordpassword initialzinitialz abcdefghabcdefgh
# eb4703ae3d8212c64c5a91ccc2c4078f
# decrypt
./aes -d passwordpassword initialzinitialz 0xeb4703ae3d8212c64c5a91ccc2c4078f
# 61626364656667686162636465666768# encryption
printf 'abcdefghabcdefgh' | openssl enc -aes-128-cbc -K 70617373776f726470617373776f7264 -iv 696e697469616c7a696e697469616c7a -nopad -nosalt | xxd -p
# eb4703ae3d8212c64c5a91ccc2c4078f
# decryption
printf 'eb4703ae3d8212c64c5a91ccc2c4078f' | xxd -r -p | openssl enc -d -aes-128-cbc -K 70617373776f726470617373776f7264 -iv 696e697469616c7a696e697469616c7a -nopad -nosalt | xxd -p
# 61626364656667686162636465666768- blowfish
- twofish
- FEAL
- LOKI
- Camelia