Skip to content

A cryptosystem application to implement secure digital envelope exchange between multiple parties. Implemented for NEU's CY5010 Project.

Notifications You must be signed in to change notification settings

pdoffl/SecureEnvelope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

   _____                           ______                __               
  / ___/___  _______  __________  / ____/___ _   _____  / /___  ____  ___ 
  \__ \/ _ \/ ___/ / / / ___/ _ \/ __/ / __ \ | / / _ \/ / __ \/ __ \/ _ \
 ___/ /  __/ /__/ /_/ / /  /  __/ /___/ / / / |/ /  __/ / /_/ / /_/ /  __/
/____/\___/\___/\__,_/_/   \___/_____/_/ /_/|___/\___/_/\____/ .___/\___/ 
                                                            /_/           

A hybrid cryptosystem implementation for secure multi-recipient file encryption using digital envelope techniques. SecureEnvelope combines the efficiency of symmetric encryption with the security of asymmetric key exchange to enable authenticated, confidential file transmission to multiple recipients.

Overview

SecureEnvelope implements a practical digital envelope system that addresses a common challenge in secure communications: how to efficiently encrypt a file once while allowing multiple authorized recipients to decrypt it independently. The system leverages Elliptic Curve Diffie-Hellman (ECDH) key exchange and AES-256 symmetric encryption to create a secure, scalable solution for group file encryption.

Key Features

  • Multi-Recipient Support: Once encrypted, it can decrypt by any of three authorized recipients
  • Hybrid Encryption Architecture: Combines AES-256-CBC symmetric encryption with ECDH key exchange
  • Digital Signature Authentication: Cryptographic verification of sender identity and message integrity
  • Tamper Detection: SHA-256 signature validation prevents unauthorized modifications
  • Efficient Key Distribution: Individual encrypted session keys per recipient using shared secrets
  • Automated Cleanup: Secure removal of intermediate cryptographic materials
  • Comprehensive Error Handling: Validation at each stage with descriptive error messages

Use Cases

SecureEnvelope is designed for scenarios requiring:

  • Confidential Document Distribution: Securely share sensitive files with multiple team members
  • Authenticated Communications: Verify sender identity and message integrity
  • Encrypted Data Exchange: Protect files in transit across untrusted networks
  • Group Encryption Scenarios: Enable selective access without key pre-distribution

This architecture mirrors production systems like PGP/GPG and S/MIME, making it relevant for understanding real-world encrypted communication protocols.

Architecture

Cryptographic Design

SecureEnvelope implements a digital envelope pattern combining:

  1. Symmetric Layer (Data Encryption)

    • Algorithm: AES-256-CBC with PBKDF2 key derivation
    • Purpose: Efficient encryption of arbitrary-sized files
    • Session Key: 128-byte random key generated per message
  2. Asymmetric Layer (Key Exchange)

    • Algorithm: Elliptic Curve Diffie-Hellman (ECDH)
    • Curve: NIST P-256 (prime256v1)
    • Purpose: Secure distribution of symmetric session key
  3. Authentication Layer (Signature)

    • Algorithm: SHA-256 with ECDSA signing
    • Purpose: Sender authentication and integrity verification

Workflow

Sender Operations

1. Generate random AES-256 session key
2. Encrypt plaintext file with session key
3. Sign encrypted file with sender's private key
4. Derive shared secrets with each receiver's public key (ECDH)
5. Encrypt session key with each shared secret
6. Package: [encrypted file, signature, 3 encrypted session keys] → ZIP

Receiver Operations

1. Extract ZIP contents
2. Verify signature using sender's public key (HALT if invalid)
3. Derive shared secret using receiver's private key + sender's public key
4. Attempt decryption of all three encrypted session keys
5. Decrypt file with recovered session key

Security Properties

  • Confidentiality: Only recipients possessing valid private keys can decrypt
  • Authentication: Digital signatures prove sender identity
  • Integrity: Signature verification detects any tampering
  • Forward Secrecy: Each session uses a unique random symmetric key
  • Non-Repudiation: Sender cannot deny creating the signed message

Installation

Prerequisites

# Debian/Ubuntu
sudo apt-get install openssl gpg zip unzip

# RHEL/CentOS
sudo yum install openssl gnupg2 zip unzip

Setup

# Clone or download the script
chmod +x SecureEnvelope.sh

# Verify dependencies
./SecureEnvelope.sh --help

Usage

Key Generation

Before using SecureEnvelope, generate ECC key pairs for the sender and all receivers:

# Sender keys
openssl ecparam -name prime256v1 -genkey -noout -out sender_private.key
openssl ec -in sender_private.key -pubout -out sender_public.key

# Receiver #1 keys
openssl ecparam -name prime256v1 -genkey -noout -out receiver1_private.key
openssl ec -in receiver1_private.key -pubout -out receiver1_public.key

# Repeat for receiver #2 and #3

Sender Mode

Encrypt and prepare a file for distribution:

./SecureEnvelope.sh -sender \
    receiver1_public.key \
    receiver2_public.key \
    receiver3_public.key \
    sender_private.key \
    plaintext_message.txt \
    encrypted_package.zip

Output: encrypted_package.zip containing:

  • Encrypted file (file.enc)
  • Digital signature (file.enc.sign)
  • Three encrypted session keys (rndsymm_r1.enc, rndsymm_r2.enc, rndsymm_r3.enc)

Receiver Mode

Decrypt a received package:

./SecureEnvelope.sh -receiver \
    receiver1_private.key \
    sender_public.key \
    encrypted_package.zip \
    decrypted_message.txt

Output: decrypted_message.txt containing the original plaintext

Example Workflow

# Alice encrypts a file for Bob, Carol, and Dave
./SecureEnvelope.sh -sender \
    bob_public.key carol_public.key dave_public.key \
    alice_private.key \
    confidential_report.txt \
    secure_package.zip

# Bob receives and decrypts the package
./SecureEnvelope.sh -receiver \
    bob_private.key \
    alice_public.key \
    secure_package.zip \
    decrypted_report.txt

Technical Specifications

Component Specification
Symmetric Cipher AES-256-CBC
Key Derivation PBKDF2
Asymmetric Algorithm ECDH (Elliptic Curve Diffie-Hellman)
Elliptic Curve NIST P-256 (prime256v1)
Signature Algorithm ECDSA with SHA-256
Session Key Size 1024 bits (128 bytes)
Temporary Storage /dev/shm/tmp_sender (sender), configurable (receiver)

Error Handling

SecureEnvelope includes validation for:

  • Missing or invalid input files
  • Incorrect argument counts
  • Dependency verification (OpenSSL, GPG)
  • Signature verification failures
  • Decryption failures (wrong keys)
  • ZIP extraction errors
  • Intermediate file creation issues

All errors are written to STDERR with descriptive messages, and the system ensures cleanup of intermediate files even during error conditions.

Security Considerations

Strengths

  • Industry-standard cryptographic primitives (AES-256, ECC P-256, SHA-256)
  • Proper key derivation with PBKDF2
  • Mandatory signature verification before decryption
  • Secure random key generation via OpenSSL

Limitations

  • Keys must be securely exchanged out-of-band before use
  • No built-in key revocation mechanism
  • Temporary files stored in /dev/shm (RAM disk) - ensure proper permissions
  • Script assumes trusted execution environment

Project Context

SecureEnvelope was developed as part of CY5010: Foundations of Information Assurance coursework at Northeastern University. The implementation demonstrates practical application of cryptosystems, digital signatures, and secure key exchange protocols in a multi-recipient scenario.


Credits

  • Institution: Northeastern University
  • Course: CY5010 (Foundations of Information Assurance)
  • Instructor: Dr. Jose Sierra
  • Date: Spring 2024

About

A cryptosystem application to implement secure digital envelope exchange between multiple parties. Implemented for NEU's CY5010 Project.

Topics

Resources

Stars

Watchers

Forks

Languages