Compare commits

..

11 Commits

6 changed files with 472 additions and 336 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
otp
pads/ pads/
Gemini.md Gemini.md

View File

@@ -1,7 +1,7 @@
CC = gcc CC = gcc
CFLAGS = -Wall -Wextra -std=c99 CFLAGS = -Wall -Wextra -std=c99
LIBS = -lssl -lcrypto LIBS =
LIBS_STATIC = -static -lssl -lcrypto -ldl -lpthread LIBS_STATIC = -static
TARGET = otp TARGET = otp
SOURCE = otp.c SOURCE = otp.c
VERSION_SOURCE = src/version.c VERSION_SOURCE = src/version.c

View File

@@ -1,4 +1,4 @@
# OTP Cipher - One Time Pad Implementation r# OTP Cipher - One Time Pad Implementation
A secure one-time pad (OTP) cipher implementation in C with automatic versioning system. A secure one-time pad (OTP) cipher implementation in C with automatic versioning system.
@@ -25,10 +25,11 @@ Current version can be viewed with: `./otp --help` or by running the interactive
### Prerequisites ### Prerequisites
- GCC compiler - GCC compiler
- OpenSSL development libraries (`libssl-dev` on Ubuntu/Debian)
- Git (for version tracking) - Git (for version tracking)
- Make - Make
**Note: OpenSSL is no longer required! This implementation is now completely self-contained.**
### Build Commands ### Build Commands
Use the included build script for automatic versioning: Use the included build script for automatic versioning:
@@ -125,10 +126,11 @@ These files are excluded from git (.gitignore) and regenerated on each build.
## Security Features ## Security Features
- Uses `/dev/urandom` for cryptographically secure random number generation - Uses `/dev/urandom` for cryptographically secure random number generation
- Optional keyboard entropy mixing using HKDF (Hash-based Key Derivation Function) - Optional keyboard entropy mixing using simple XOR operations
- SHA-256 pad integrity verification - Custom 256-bit XOR checksum for pad identification (encrypted with pad data)
- Read-only pad files to prevent accidental modification - Read-only pad files to prevent accidental modification
- State tracking to prevent pad reuse - State tracking to prevent pad reuse
- **Zero external crypto dependencies** - completely self-contained implementation
## File Structure ## File Structure
@@ -197,3 +199,5 @@ When contributing:
1. The version will automatically increment on builds 1. The version will automatically increment on builds
2. For major features, consider manually creating minor version tags 2. For major features, consider manually creating minor version tags
3. Generated version files (`src/version.*`, `VERSION`) should not be committed 3. Generated version files (`src/version.*`, `VERSION`) should not be committed
# Test change
# Testing -m flag

View File

@@ -13,6 +13,23 @@ print_success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; } print_warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
print_error() { echo -e "${RED}[ERROR]${NC} $1"; } print_error() { echo -e "${RED}[ERROR]${NC} $1"; }
# Global variable for commit message
COMMIT_MESSAGE=""
# Parse command line arguments for -m flag
while [[ $# -gt 0 ]]; do
case $1 in
-m|--message)
COMMIT_MESSAGE="$2"
shift 2
;;
*)
# Keep other arguments for main logic
break
;;
esac
done
# Function to automatically increment version # Function to automatically increment version
increment_version() { increment_version() {
print_status "Incrementing version..." print_status "Incrementing version..."
@@ -50,9 +67,50 @@ increment_version() {
print_status "Current version: $LATEST_TAG" print_status "Current version: $LATEST_TAG"
print_status "New version: $NEW_VERSION" print_status "New version: $NEW_VERSION"
# Stage all changes
if git add . 2>/dev/null; then
print_success "Staged all changes"
else
print_warning "Failed to stage changes (maybe not a git repository)"
fi
# Handle commit message - use global variable if set, otherwise prompt
if [[ -z "$COMMIT_MESSAGE" ]]; then
echo ""
print_status "Please enter a meaningful commit message for version $NEW_VERSION:"
echo -n "> "
read -r COMMIT_MESSAGE
fi
# Check if user provided a message
if [[ -z "$COMMIT_MESSAGE" ]]; then
print_warning "No commit message provided. Using default message."
COMMIT_MESSAGE="Automatic version increment"
fi
# Commit changes with user-provided message
if git commit -m "Version $NEW_VERSION - $COMMIT_MESSAGE" 2>/dev/null; then
print_success "Committed changes for version $NEW_VERSION"
else
print_warning "Failed to commit changes (maybe no changes to commit or not a git repository)"
fi
# Create new git tag # Create new git tag
if git tag "$NEW_VERSION" 2>/dev/null; then if git tag "$NEW_VERSION" 2>/dev/null; then
print_success "Created new version tag: $NEW_VERSION" print_success "Created new version tag: $NEW_VERSION"
# Push changes and tags to remote repository
if git push ssh://ubuntu@laantungir.net:/home/ubuntu/git_repos/otp 2>/dev/null; then
print_success "Pushed changes to remote repository"
else
print_warning "Failed to push changes to remote repository"
fi
if git push ssh://ubuntu@laantungir.net:/home/ubuntu/git_repos/otp --tags 2>/dev/null; then
print_success "Pushed tags to remote repository"
else
print_warning "Failed to push tags to remote repository"
fi
else else
print_warning "Tag $NEW_VERSION already exists - using existing version" print_warning "Tag $NEW_VERSION already exists - using existing version"
NEW_VERSION=$LATEST_TAG NEW_VERSION=$LATEST_TAG
@@ -213,7 +271,10 @@ case "${1:-build}" in
;; ;;
*) *)
echo "OTP Cipher Build Script" echo "OTP Cipher Build Script"
echo "Usage: $0 {build|static|clean|install|uninstall|version}" echo "Usage: $0 [-m \"commit message\"] {build|static|clean|install|uninstall|version}"
echo ""
echo "Options:"
echo " -m, --message \"text\" - Specify commit message (skips interactive prompt)"
echo "" echo ""
echo "Commands:" echo "Commands:"
echo " build - Build project with automatic version increment (default)" echo " build - Build project with automatic version increment (default)"
@@ -222,6 +283,11 @@ case "${1:-build}" in
echo " install - Install to system (requires build first)" echo " install - Install to system (requires build first)"
echo " uninstall - Remove from system" echo " uninstall - Remove from system"
echo " version - Generate version files only" echo " version - Generate version files only"
echo ""
echo "Examples:"
echo " $0 build"
echo " $0 -m \"Fixed checksum parsing bug\" build"
echo " $0 --message \"Added new feature\" static"
exit 1 exit 1
;; ;;
esac esac

BIN
otp

Binary file not shown.

605
otp.c

File diff suppressed because it is too large Load Diff