UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS
Information Technology Security
Vasileios Evangelos Athanasiou
Student ID: 19390005
Supervision
Supervisor: Ioanna Kantzavelou, Associate Professor
Co-supervisor: Angelos Georgoulas, Assistant Professor
Athens, May 2023
This project explores fundamental cryptographic operations using the OpenSSL BIGNUM (BN) library. It focuses on the practical implementation of RSA cryptography, including key generation, encryption, decryption, digital signatures, and certificate verification.
All implementations are written in C and utilize the OpenSSL BN library to handle large integer arithmetic beyond standard machine limits.
| Section | Path / File | Description |
|---|---|---|
| 1 | assign/ |
Official laboratory exercise specifications |
| 1.1 | assign/Exercise 2 (Cryptography)_2023.pdf |
Assignment description (English) |
| 1.2 | assign/Ασκηση 2 (Cryptography)_2023.pdf |
Assignment description (Greek) |
| 2 | docs/ |
Project reports and theoretical analysis |
| 2.1 | docs/Cryptography.pdf |
Technical report (English) |
| 2.2 | docs/Κρυπτογραφία.pdf |
Technical report (Greek) |
| 3 | src/ |
Cryptographic implementations and verification tools |
| 3.1 | src/private_key.c |
RSA private key generation |
| 3.2 | src/public_key |
RSA public key extraction |
| 3.3 | src/crypto_msg.c |
Message encryption using public key |
| 3.4 | src/decrypto_msg.c |
Message decryption using private key |
| 3.5 | src/sign_msg.c |
Digital signature generation |
| 3.6 | src/verify_sign.c |
Digital signature verification |
| 3.7 | src/verify_sign_cert.c |
Signature verification using X.509 certificates |
| 3.8 | src/bn_sample.c |
Big number (BN) operations example |
| 3.9 | src/c0.pem, src/c1.pem |
RSA certificates |
| 3.10 | src/c0_body.bin |
Binary certificate body |
| 3.11 | src/cert_info.txt |
Certificate metadata and inspection output |
| 4 | screens/ |
Experimental evidence and execution results |
| 4.1 | screens/Activity1–6/ |
Step-by-step screenshots for each cryptographic activity |
| 5 | README.md |
Repository overview and usage instructions |
The laboratory work is divided into independent activities, each targeting a specific cryptographic concept:
-
Private Key Generation (
private_key.c)
Calculates the RSA private keydusing prime numbersp,q, and the public exponente. -
Message Encryption (
crypto_msg.c)
Encrypts a plaintext message (e.g., a student's name) using the RSA encryption formula:$$ C = M^e \pmod{N} $$ -
Message Decryption (
decrypto_msg.c)
Decrypts an encrypted hexadecimal ciphertext back into readable text using:$$ D = C^d \pmod{N} $$
-
Digital Signature Creation (
sign_msg.c)
Generates a digital signature for a given message using the RSA private key. -
Signature Verification (
verify_sign_msg.c)
Verifies message authenticity by comparing the decrypted signature with the original message. -
X.509 Certificate Verification (
verify_sign_cert.c)
Manually extracts and verifies the digital signature of a real-world web server certificate
(e.g., apachefriends.org).
- Modulo (RSA modulus):
- Euler’s Totient Function:
- Private Key Calculation:
- Encryption:
- Decryption:
Even a single-bit change in a message or signature produces a completely different result, ensuring data integrity.
The OpenSSL BN library efficiently manages large integers required for secure RSA operations.
The same RSA principles implemented in this lab are used in X.509 certificate verification for secure web communications.
This laboratory project demonstrates how theoretical cryptographic principles are applied in practice using professional-grade libraries. It bridges the gap between academic RSA concepts and their real-world security applications, such as encrypted communication and digital certificate validation.
This guide explains how to install prerequisites, compile, and execute the Cryptography laboratory project, which implements RSA cryptographic operations using the OpenSSL BIGNUM (BN) library in C.
The project is intended for academic and laboratory use within the context of the Information Technology Security course at the University of West Attica (UNIWA).
- Linux-based OS (recommended)
- Ubuntu 16.04 / 18.04 / 20.04
- SEED Ubuntu VM (fully compatible)
- GCC
Verify installation:
gcc --versionIf not installed:
sudo apt update
sudo apt install -y build-essentialThe project relies on the OpenSSL crypto (BN) library. Install OpenSSL development headers:
sudo apt install -y libssl-devVerify installation:
openssl versionUsed for hexadecimal encoding/decoding and verification steps.
python3 --versionInstall if missing:
sudo apt install -y python3git clone https://github.com/Information-Technology-Security/Cryptography.git
cd Cryptography/srcAll programs must be linked against the OpenSSL crypto library -lcrypto.
Compile each file individually, as each source file represents a separate cryptographic activity.
gcc bn_sample.c -o bn_sample -lcrypto
./bn_samplegcc private_key.c -o private_key -lcrypto
./private_keyThis program:
- Computes RSA modulus N
- Calculates Euler’s totient φ(N)
- Derives the private exponent d
gcc public_key.c -o public_key -lcrypto
./public_keygcc crypto_msg.c -o crypto_msg -lcrypto
./crypto_msgEncrypts a plaintext message using:
gcc decrypto_msg.c -o decrypto_msg -lcrypto
./decrypto_msgDecrypts ciphertext using:
gcc sign_msg.c -o sign_msg -lcrypto
./sign_msgProduces a digital signature using the RSA private key.
gcc verify_sign.c -o verify_sign -lcrypto
./verify_signValidates message authenticity by comparing hashes.
gcc verify_sign_cert.c -o verify_sign_cert -lcrypto
./verify_sign_certThis program:
- Extracts certificate fields
- Verifies the digital signature of a real-world X.509 certificate
- Confirms authenticity using RSA public key parameters
| Issue | Cause | Solution |
|---|---|---|
openssl/bn.h not found |
Missing OpenSSL headers | Install libssl-dev |
Undefined reference to BN_* |
Missing crypto library | Add -lcrypto to linker flags |
| Compilation fails | Old GCC | Update build tools |
| Incorrect output | Wrong key parameters | Verify p, q, e values |
- Navigate to the
docs/directory - Open the report corresponding to your preferred language:
- English:
Cryptography.pdf - Greek:
Κρυπτογραφία.pdf
- English:
