- Introduction
- Prerequisites
- Installation
- Makefile
- Usage
- Module Parameters
- File Operations
- Security Considerations
- License
- Authors
Caesar cipher is a basic substitution cipher where each character in the plaintext is shifted by a certain number of positions in the alphabet. In this driver, we use the English alphabet including spaces, totaling 53 characters.
The kernel module allows dynamic encryption and decryption of text accessed through the /dev/encrypt
and /dev/decrypt
device files.
- Linux operating system (tested on Ubuntu 24.04 LTS)
- Basic knowledge of using kernel modules and device files in Linux
- Clone the repository:
git clone https://github.com/amaldoror/CaesarLKM cd CaesarLKM
- Install libraries:
sudo apt-get update apt-cache search linux-headers-$(uname -r) sudo apt-get install linux-headers-[VERSION]
- Compile the Kernel Module:
make
- Clean up:
make clean
- Load the Kernel Module:
make load
- Unload the Kernel Module:
make unload
- View Kernel Logs:
make log
- Help:
make help
To use the module, it has to be compiled and loaded.
Once the module is loaded, the device files /dev/encrypt
and /dev/decrypt
are available.
- Encryption:
echo "Hello hello!" > /dev/encrypt cat /dev/encrypt # Outputs "Khoor khoor!"
- Decryption:
echo "Khoor khoor!" > /dev/decrypt cat /dev/decrypt # Outputs "Hello hello!"
The module supports the translate_shift parameter to specify the number of characters to shift for encryption.
By default, this is set to 3.
Example of loading the module with a different shift value: ```bash sudo insmod caesar_cipher.ko translate_shift=5
The module implements the following file operations for the device files:
- open: Opens the device file and locks the corresponding mutex.
- release: Closes the device file and unlocks the mutex.
- read: Reads from the device file and copies data to user space.
- write: Writes to the device file and performs Caesar cipher encryption or decryption.
The driver uses mutexes to ensure that only one process can access the device files at a time.
It's recommended to encrypt only ASCII characters that are part of the defined alphabet (ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz).
Non-included characters are passed through unchanged.
This project is licensed under the GNU General Public License (GPL) v2. For more details, see the LICENSE file.
Adrian Morgenthal www.github.com/amaldoror