Skip to content

Latest commit

 

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OTP Module Manager

Overview

This project implements an HMAC (Hash-based Message Authentication Code) algorithm using the Linux Kernel Crypto API.

It demonstrates how to:

  • Implement a kernel module
  • Register a device for user-space communication
  • Use the Crypto API for cryptographic operations

This project is designed for kernel module development and should be compiled within a Linux kernel environment.

Features

  • Uses HMAC-SHA1 to compute message authentication codes
  • ...

Installation & Usage

Prerequisites

Ensure you have:

  • A Linux system with kernel headers installed
  • make and gcc for building kernel modules
  • Root privileges for loading/unloading kernel modules

Makefile script

The Makefile contains the following targets:

  • all - Builds the kernel module into an .ko file
  • load - Builds and loads the kernel module
  • unload - Unloads the kernel module
  • reload - Unloads and loads the kernel module
  • clean - Cleans the build directory
  • info - Displays information about the kernel module
  • log - Displays the kernel log
  • logx - Displays the kernel log continuously
  • help - Displays the Makefile help

Procedure

  1. Clone the repository:
$ git clone https://github.com/NicolasReboule/OTPKernelModule.git
  1. Go inside the module folder
$ cd OTPKernelModule/module
  1. Run the make load command to build and load the kernel module:
$ make load
  1. Check the kernel log for module information:
$ make log
  1. Use the devices interfaces to interact with the module:
$ cat /dev/otp-hotp
$ 123456
  1. Use the generatad otp to use the client
$ cd client
$ ./client 123456 upper bonjour
$ BONJOUR

Available commands

otp-hotp

  • cat /dev/otp-hotp : Generate a hotp code

Using echo:

  • update -a <algo> -s <secret> : Update the device's algorihm and secret
  • info : Shows devices current algorihm and secret
  • default : Shows usage

where:

  • <algo> : SHA1 or SHA256
  • <secret> : Any string

otp-totp

  • cat /dev/otp-totp : Generate a totp code

Using echo:

  • update -a <algo> -s <secret> -t : Update the device's algorihm and secret
  • info : Shows devices current algorihm and secret
  • default : Shows usage

where:

  • <algo> : SHA1 or SHA256
  • <secret> : Any string
  • <timestep>: Number of seconds a TOTP code should be valid

otp-validator

  • cat /dev/otp-validator : Returns last validation result

Using echo:

  • <otp> : Validate an otp
  • help : Shows usage

where:

  • <otp> : OTP code generated by this module

Debugfs

With admin rights, you can use debugfs tu modify the list of hotp codes.

The list can be found at /sys/kernel/debug/otp_manager/otp_list

Usage

  • cat /sys/kernel/debug/otp_manager/otp_list : Shows list of hotp codes

Using echo:

  • add <code> : Adds code to hotp list
  • delete <index> : Removes code at specified index from the list

where:

  • <code> : Any number (less than 16 characters)
  • <index> : Index number in the list

File Structure

.
├── crypto.c        # Main implementation of HMAC using Crypto API
├── Makefile        # Build script for compiling the module
├── module.c        # Kernel module initialization and cleanup
├── module.d/       # Directory for kernel module source files
│   └──  *          # Object files generated during compilation
├── ...             # ...
├── ...             # ...
└── README.md       # User Documentation

Authors

Fazanwolf - GitHub

Salocin - GitHub

Nekomay - GitHub

License

This project is licensed under the GPLv3 License - see the LICENSE file for details.

References

About

OTP module for Linux kernel

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages