A command-line application implementing comprehensive security concepts for secure exam paper management, developed as part of FOUNDATIONS OF CYBER SECURITY lab evaluation.
This system demonstrates the practical implementation of core security principles including authentication, authorization, encryption, digital signatures, and secure encoding for managing exam question papers in an academic environment.
- Single-factor authentication using username and password
- Multi-factor authentication with time-limited OTP (One-Time Password)
- Password hashing using bcrypt with custom salt
- SHA-256 pre-hashing to handle unlimited password lengths
- OTP validity period: 5 minutes
- OTP single-use enforcement
- Role-Based Access Control (RBAC) with three roles: Faculty, Exam Cell, Student
- Access Control Matrix implementation with granular permissions
- Permission enforcement before all sensitive operations
- Audit logging for security-critical actions
- AES-256-GCM encryption for question paper content
- RSA-2048 for secure key exchange
- Random AES key generation per document
- AES key encrypted with recipient's RSA public key
- Hybrid encryption combining speed of AES with security of RSA
- SHA-256 hashing of document content
- RSA-based digital signature creation using faculty's private key
- Signature verification using faculty's public key
- Integrity and authenticity verification
- Tamper detection capability
- Base64 encoding for binary-safe database storage
- Encoding applied to encrypted content, keys, and signatures
- Clear distinction between encoding (format conversion) and encryption (confidentiality)
Faculty:
- Upload question papers
- Encrypt papers automatically during upload
- Sign papers with private key
- View own uploaded papers
Exam Cell:
- View all encrypted question papers
- Decrypt papers using private key
- Verify digital signatures
- Manage exam sessions
Student:
- View exam schedule (read-only access)
- No access to question papers
- No decryption capabilities
| Role | Question Paper | Encryption Key | Exam Session |
|---|---|---|---|
| Faculty | Create, Encrypt | Generate | View |
| Exam Cell | Read, Decrypt | Decrypt | Manage |
| Student | None | None | View |
- Language: Go 1.21+
- Database: MySQL 8.0+
- Cryptography: Go standard library (crypto/*)
- Password Hashing: bcrypt with cost factor 12
- Symmetric Encryption: AES-256-GCM
- Asymmetric Encryption: RSA-2048
- Hash Function: SHA-256
- Encoding: Base64 (standard encoding)
- Go 1.21 or higher
- MySQL 8.0 or higher
- GCC (for MySQL driver compilation)
git clone https://github.com/FLASH2332/Secure-Question-Paper-Distribution-Portal.git
cd Secure-Question-Paper-Distribution-Portalgo mod download
go mod tidySetup mysql server and enter the details in the .env file as follows :
DB_USER=userName
DB_PASSWORD=password
DB_HOST=host (i.e, localhost)
DB_PORT=portNo
DB_NAME=databaseName
# optional
# SMTP_HOST=smtp.gmail.com
# SMTP_PORT=587
# SMTP_USER=your-email@gmail.com
# SMTP_PASS=your-app-password
# SMTP_FROM=youremail@gmail.com- Start the application
- Register users for each role:
- Faculty user (receives RSA key pair automatically)
- Exam Cell user (receives RSA key pair automatically)
- Student user (no keys required)
- Login with credentials
- Complete MFA with OTP
- Upload question paper:
- Provide paper title and subject
- Specify exam date
- Enter file path (PDF or TXT)
- System automatically:
- Generates random AES-256 key
- Encrypts paper with AES-GCM
- Encrypts AES key with Exam Cell's RSA public key
- Creates digital signature with faculty's RSA private key
- Encodes all data in Base64
- Stores in database
- Login with credentials
- Complete MFA with OTP
- View all encrypted papers
- Select paper to decrypt
- System automatically:
- Retrieves encrypted paper and key
- Decodes Base64 data
- Decrypts AES key using Exam Cell's RSA private key
- Decrypts paper content using AES key
- Verifies digital signature using faculty's RSA public key
- Displays decrypted content if signature valid
- Login with credentials
- Complete MFA with OTP
- View exam schedule (limited access)
- Access to question papers blocked by ACL
users: Stores user credentials, roles, and RSA keys otp_sessions: Manages OTP tokens for MFA question_papers: Stores encrypted papers, keys, and signatures exam_sessions: Manages exam scheduling access_control: Defines ACL permissions audit_log: Tracks security-relevant actions
- Bcrypt hashing with cost factor 12
- Random 32-byte salt per user
- SHA-256 pre-hashing to bypass bcrypt's 72-byte limit
- No plaintext passwords stored
- RSA-2048 key pairs generated during registration
- Private keys stored in PEM format (in production, encrypt these)
- Public keys distributed for encryption and verification
- Separate key pairs for Faculty and Exam Cell roles
- AES-256-GCM provides authenticated encryption
- Unique AES key per document
- Nonce generated using crypto/rand
- RSA PKCS1v15 for key encryption
- Compute SHA-256 hash of plaintext document
- Sign hash with faculty's RSA private key using PKCS1v15
- Signature verified during decryption
- Failed verification indicates tampering
| Attack Type | Mitigation Strategy |
|---|---|
| Brute Force | bcrypt adaptive cost + MFA |
| Rainbow Tables | Random salt per user |
| Man-in-the-Middle | End-to-end encryption |
| Tampering | Digital signatures with integrity verification |
| Unauthorized Access | ACL enforcement with database-level permissions |
| Key Compromise | Role-based key separation |
| Replay Attacks | OTP expiration and single-use enforcement |
- User registration with password validation
- Login with invalid credentials (should fail)
- Login with correct password but wrong OTP (should fail)
- Faculty paper upload and encryption
- Exam Cell paper decryption and verification
- Student access denial (ACL enforcement)
- Signature verification after data tampering (should fail)
secure-exam-system/
├── cmd/
│ └── main.go # Application entry point
├── internal/
│ ├── auth/
│ │ ├── registration.go # User registration logic
│ │ ├── login.go # Authentication and MFA
│ │ └── otp.go # OTP generation and verification
│ ├── crypto/
│ │ ├── aes.go # AES encryption/decryption
│ │ ├── rsa.go # RSA key operations
│ │ ├── hashing.go # Password hashing
│ │ ├── signature.go # Digital signatures
│ │ └── encoding.go # Base64 encoding
│ ├── acl/
│ │ └── permissions.go # Access control logic
│ ├── models/
│ │ └── user.go # Data models
│ ├── database/
│ │ ├── db.go # Database connection
│ │ └── schema.go # Schema definitions
│ └── services/
│ └── paper_service.go # Business logic
├── pkg/
│ ├── email/
│ │ └── sender.go # Email simulation
│ └── utils/
│ └── input.go # User input utilities
├── storage/
│ ├── keys/ # RSA key storage
│ └── exam.db # Database file
├── .env # Environment configuration
├── .gitignore
├── go.mod
├── go.sum
└── README.md