1
Fork 0

Migrate back to Git LFS

This commit is contained in:
Nadim Kobeissi 2025-06-26 12:19:00 +02:00
parent 6b34b62aa2
commit 4b6498ede3
Signed by: nadim
SSH key fingerprint: SHA256:o0JJHYcP8LVBoARMU+JjVbzJxL3HxW2F+C0yu/5zPgc
237 changed files with 36953 additions and 0 deletions

17
assignments/labs/Makefile Normal file
View file

@ -0,0 +1,17 @@
all:
@make password-manager
@make secure-messenger
@make zk-battleship
@make proverif
password-manager:
@export SOURCE_DATE_EPOCH=1700000000 && tectonic -o ../../website/labs "password-manager.tex"
secure-messenger:
@export SOURCE_DATE_EPOCH=1700000000 && tectonic -o ../../website/labs "secure-messenger.tex"
zk-battleship:
@export SOURCE_DATE_EPOCH=1700000000 && tectonic -o ../../website/labs "zk-battleship.tex"
proverif:
@export SOURCE_DATE_EPOCH=1700000000 && tectonic -o ../../website/labs "proverif.tex"

View file

@ -0,0 +1,9 @@
# Labs
- [x] Password Manager
- [x] Secure Messenger
- [x] [ZK Battleship](https://github.com/nategraf/oscw-zkvms-battleship)
- [ ] [ProofFrog](https://prooffrog.github.io)
- [ ] [Verifpal](https://verifpal.com)
- [x] [ProVerif](https://proverif.inria.fr) or [Tamarin](https://tamarin-prover.com)
- [ ] [CTFs](https://ctftime.org/tasks/?tags=crypto&hidden-tags=crypto) if we have time?

View file

@ -0,0 +1,159 @@
\documentclass[10pt,a4paper,american]{article}
\newcommand{\aublogopath}{../../website/res/img/aub_black.png}
\usepackage{../../misc/macros/joc}
\usepackage{../../misc/fonts/fonts}
\usepackage{../../misc/macros/classhandout}
\begin{document}
\classhandoutheader
\section*{Lab Assignment: Building a Secure Password Manager}
\subsection*{Overview}
In this lab, you will design and implement a secure password manager application from scratch. This represents your first opportunity to apply cryptographic primitives to build a complete security protocol—albeit one that operates locally without network communication. Password managers are essential security tools that help users generate, store, and manage their credentials for various services. By building one, you'll gain practical experience with fundamental cryptographic primitives, secure storage techniques, and security-focused software design principles. Future lab assignments will build upon these skills by incorporating network components as you develop secure messengers, encrypted synchronization protocols, and other networked security applications.
\subsection*{Learning Objectives}
After completing this lab, you should be able to:
\begin{itemize}
\item Apply cryptographic primitives like key derivation functions and authenticated encryption.
\item Implement secure data storage techniques.
\item Design and build a security-critical application with proper threat modeling.
\item Evaluate the security properties of a password management system.
\end{itemize}
\subsection*{Background}
Password managers solve the problem of creating and remembering strong, unique passwords for multiple services. A password manager typically:
\begin{itemize}
\item Generates cryptographically strong random passwords.
\item Encrypts and securely stores passwords using a master password.
\item Provides convenient access to stored credentials.
\item Protects against various attacks including phishing and data breaches.
\end{itemize}
\subsection*{Requirements}
Your password manager must implement the following core functionality:
\begin{enumerate}
\item \textbf{Master Password Handling:}
\begin{itemize}
\item Derive an encryption key from a master password using a suitable KDF (e.g., Argon2, Scrypt).
\item Implement appropriate security parameters (salt, iterations).
\item Correctly handle key rotation in the event of a master password change.
\end{itemize}
\item \textbf{Password Storage:}
\begin{itemize}
\item Store encrypted passwords with appropriate metadata (website, username).
\item Use authenticated encryption (e.g., AES-GCM) to protect confidentiality and integrity.
\item Implement secure serialization and deserialization.
\end{itemize}
\item \textbf{Password Generation:}
\begin{itemize}
\item Generate cryptographically secure random passwords.
\item Allow configuration of password characteristics (length, character sets).
\end{itemize}
\item \textbf{User Interface:}
\begin{itemize}
\item Create a simple CLI or GUI interface for interaction.
\item Implement basic operations: add, retrieve, update, and delete passwords.
\item Include master password verification.
\item Implement clipboard clearing after use.
\item Add timeout for automatic locking.
\item Include proper error handling without leaking sensitive information.
\end{itemize}
\end{enumerate}
\subsection*{Implementation Guidelines}
\subsubsection*{Step 1: Design}
Begin by creating a threat model for your password manager. Consider:
\begin{itemize}
\item Who are the attackers? (Malware, physical access, remote attackers)
\item What assets are you protecting? (Master password, stored credentials)
\item What are the attack vectors? (Memory dumps, disk access, etc.)
\item What cryptographic protections will you employ?
\end{itemize}
Document your design decisions and security assumptions.
\subsubsection*{Step 2: Cryptographic Building Blocks}
Implement or properly use existing libraries for:
\begin{itemize}
\item Key derivation from the master password.
\item Authenticated encryption of the password database.
\item Secure random password generation.
\end{itemize}
\subsubsection*{Step 3: Core Functionality}
Implement the core functionality:
\begin{itemize}
\item Database creation and loading.
\item Password entry management.
\item Password generation with customizable par ameters.
\end{itemize}
\subsubsection*{Step 4: User Interface}
Create an interface that balances security and usability:
\begin{itemize}
\item Master password input (with appropriate masking).
\item Commands for managing entries.
\item Secure display and clipboard operations.
\end{itemize}
\subsubsection*{Step 5: Security Hardening}
Add security features like:
\begin{itemize}
\item Memory protection techniques.
\item Auto-locking functionality.
\item Input validation and error handling.
\end{itemize}
\subsection*{Deliverables}
Submit the following:
\begin{enumerate}
\item Source code for your password manager.
\item Design document including:
\begin{itemize}
\item Threat model and security assumptions.
\item Description of cryptographic mechanisms used.
\item Design decisions and their rationale.
\end{itemize}
\item User manual explaining how to use your password manager
\item Security analysis discussing:
\begin{itemize}
\item Strengths of your implementation.
\item Limitations and potential vulnerabilities.
\item Suggested improvements for a production version.
\end{itemize}
\end{enumerate}
\subsection*{Evaluation Criteria}
Your project will be evaluated based on:
\begin{itemize}
\item Correctness of cryptographic implementations.
\item Security of the overall design.
\item Completeness of required functionality.
\item Quality of code and documentation.
\item Thoughtfulness of security analysis.
\end{itemize}
\subsection*{Resources}
\begin{itemize}
\item The course textbook and materials on symmetric encryption.
\item Libraries: libsodium, OpenSSL, or equivalent based on your language choice.
\item Research papers on password manager security (see course website).
\end{itemize}
\subsection*{Submission Guidelines}
\begin{itemize}
\item Submit your code as a ZIP archive or through a Git repository.
\item Include all documentation in PDF or Markdown format.
\item Presentations: Prepare a 10-minute presentation demonstrating your password manager.
\end{itemize}
\end{document}

167
assignments/labs/proverif.tex Executable file
View file

@ -0,0 +1,167 @@
\documentclass[10pt,a4paper,american]{article}
\newcommand{\aublogopath}{../../website/res/img/aub_black.png}
\usepackage{../../misc/macros/joc}
\usepackage{../../misc/fonts/fonts}
\usepackage{../../misc/macros/classhandout}
\begin{document}
\classhandoutheader
\section*{Lab Assignment: Designing and Verifying a TLS-like Protocol using ProVerif}
\subsection*{Overview}
In this lab, you will design and formally verify a Transport Layer Security (TLS)-like protocol using ProVerif, a formal verification tool for cryptographic protocols. This represents your first opportunity to apply formal methods to verify the security properties of a complete cryptographic protocol—one that provides confidentiality, integrity, and authentication for network communications. By designing and verifying this protocol, you'll gain practical experience with cryptographic protocol design, formal verification, and security property specification. Future lab assignments will build upon these skills by incorporating more complex cryptographic protocols and verification scenarios.
\subsection*{Learning Objectives}
After completing this lab, you should be able to:
\begin{itemize}
\item Apply formal verification to analyze security properties of cryptographic protocols.
\item Understand and use the ProVerif verification tool.
\item Design and specify a cryptographic protocol with proper threat modeling.
\item Evaluate protocol security properties such as secrecy, authentication, and forward secrecy.
\end{itemize}
\subsection*{Background}
Formal verification tools like ProVerif allow protocol designers to mathematically verify security properties. In the context of a TLS-like protocol:
\begin{itemize}
\item ProVerif models attackers who have complete control over the communication network.
\item Security properties can be precisely defined and verified, such as confidentiality of session keys.
\item Verification is performed automatically by exploring all possible protocol executions.
\item ProVerif uses symbolic cryptography to reason about cryptographic primitives.
\end{itemize}
\subsection*{Requirements}
Your TLS-like protocol must implement the following core functionality:
\begin{enumerate}
\item \textbf{Protocol Initialization:}
\begin{itemize}
\item Design a secure handshake procedure between client and server.
\item Incorporate key exchange mechanisms (e.g., Diffie-Hellman).
\item Implement proper authentication through digital signatures or certificates.
\end{itemize}
\item \textbf{Key Exchange:}
\begin{itemize}
\item Establish secure session keys between client and server.
\item Ensure forward secrecy for session communications.
\item Protect against Man-in-the-Middle attacks.
\end{itemize}
\item \textbf{Secure Communication:}
\begin{itemize}
\item Design mechanisms for encrypting and authenticating messages.
\item Implement protection against replay and reordering attacks.
\item Ensure secure session termination.
\end{itemize}
\item \textbf{Formal Specification:}
\begin{itemize}
\item Model the protocol in ProVerif's applied pi calculus.
\item Define security properties to be verified.
\item Design appropriate queries to check security properties.
\item Include proper protocol termination and error handling.
\end{itemize}
\end{enumerate}
\subsection*{Implementation Guidelines}
\subsubsection*{Step 1: Design}
Begin by creating a threat model for your TLS-like protocol. Consider:
\begin{itemize}
\item Who are the attackers? (Network adversaries, malicious endpoints)
\item What assets are you protecting? (Session keys, message confidentiality, authentication)
\item What are the attack vectors? (Man-in-the-Middle, replay, downgrade attacks)
\item What cryptographic protections will you employ?
\end{itemize}
Document your design decisions and security assumptions.
\subsubsection*{Step 2: Protocol Specification}
Design your protocol using formal notation:
\begin{itemize}
\item Define message formats and cryptographic operations.
\item Specify the exact sequence of messages exchanged.
\item Define the security properties you expect your protocol to satisfy.
\end{itemize}
\subsubsection*{Step 3: ProVerif Modeling}
Implement your protocol in ProVerif:
\begin{itemize}
\item Model cryptographic primitives using ProVerif's type system.
\item Define processes for client and server roles.
\item Formalize security properties as queries.
\item Set up the attacker model in ProVerif.
\end{itemize}
\subsubsection*{Step 4: Verification}
Verify your protocol's security properties:
\begin{itemize}
\item Run ProVerif to check for secrecy violations.
\item Verify authentication properties.
\item Test for resistance against replay attacks.
\item Verify forward secrecy.
\end{itemize}
\subsubsection*{Step 5: Protocol Refinement}
Improve your protocol based on verification results:
\begin{itemize}
\item Address any vulnerabilities discovered.
\item Optimize the protocol if possible.
\item Document changes and their justifications.
\end{itemize}
\subsection*{Deliverables}
Submit the following:
\begin{enumerate}
\item Protocol specification including:
\begin{itemize}
\item Formal description of your TLS-like protocol.
\item Message sequence diagrams.
\item Cryptographic primitives used and their roles.
\end{itemize}
\item ProVerif code implementing your protocol.
\item Design document including:
\begin{itemize}
\item Threat model and security assumptions.
\item Formal security properties being verified.
\item Design decisions and their rationale.
\end{itemize}
\item Security analysis discussing:
\begin{itemize}
\item Verification results from ProVerif.
\item Strengths of your protocol design.
\item Limitations and potential vulnerabilities.
\item Suggested improvements for a production version.
\end{itemize}
\end{enumerate}
\subsection*{Evaluation Criteria}
Your project will be evaluated based on:
\begin{itemize}
\item Correctness of ProVerif specifications and queries.
\item Security of the overall protocol design.
\item Completeness of required functionality.
\item Quality of code and documentation.
\item Thoughtfulness of security analysis.
\end{itemize}
\subsection*{Resources}
\begin{itemize}
\item The course textbook and materials on cryptographic protocols.
\item ProVerif documentation and examples.
\item TLS 1.3 specification for reference.
\item Research papers on formal verification of security protocols (see course website).
\end{itemize}
\subsection*{Submission Guidelines}
\begin{itemize}
\item Submit your ProVerif code as a ZIP archive or through a Git repository.
\item Include all documentation in PDF or Markdown format.
\item Presentations: Prepare a 10-minute presentation demonstrating your protocol design and verification results.
\end{itemize}
\end{document}

View file

@ -0,0 +1,169 @@
\documentclass[10pt,a4paper,american]{article}
\newcommand{\aublogopath}{../../website/res/img/aub_black.png}
\usepackage{../../misc/macros/joc}
\usepackage{../../misc/fonts/fonts}
\usepackage{../../misc/macros/classhandout}
\begin{document}
\classhandoutheader
\section*{Lab Assignment: Building a Secure Messenger}
\subsection*{Overview}
In this lab, you will design and implement a secure messaging application from scratch. This represents an opportunity to apply cryptographic primitives to build a complete end-to-end encrypted communication system. Secure messengers enable users to exchange private information over untrusted networks while protecting confidentiality, integrity, and authenticity of messages. By building one, you'll gain practical experience with cryptographic protocols, network security, and security-focused software design principles. This lab will require you to implement secure key exchange, encrypted message transmission, and proper security guarantees such as forward secrecy and deniability.
\subsection*{Learning Objectives}
After completing this lab, you should be able to:
\begin{itemize}
\item Apply cryptographic primitives such as public key cryptography and authenticated encryption.
\item Implement secure communication protocols with proper key exchange.
\item Design and build a security-critical networked application with proper threat modeling.
\item Evaluate the security properties of end-to-end encrypted communication systems.
\end{itemize}
\subsection*{Background}
Secure messaging applications provide private communication over potentially compromised networks. A secure messenger typically:
\begin{itemize}
\item Employs end-to-end encryption to ensure only the intended recipient can read messages.
\item Provides forward secrecy so compromise of current keys doesn't expose previous communications.
\item Authenticates correspondents to prevent message forgery and man-in-the-middle attacks.
\item Protects metadata where possible to minimize surveillance risks.
\item Enables secure group communications and file transfers.
\end{itemize}
\subsection*{Requirements}
Your secure messenger must implement the following core functionality:
\begin{enumerate}
\item \textbf{User Identity and Key Management:}
\begin{itemize}
\item Generate cryptographic identities for users (public/private key pairs).
\item Implement secure storage of private keys.
\item Create a mechanism for key exchange and verification.
\item Support key rotation and revocation.
\end{itemize}
\item \textbf{Message Encryption:}
\begin{itemize}
\item Implement end-to-end encryption using a recognized protocol (e.g., Signal Protocol).
\item Use authenticated encryption for message confidentiality and integrity.
\item Support forward secrecy through proper key ratcheting.
\item Implement a mechanism for secure message serialization and deserialization.
\end{itemize}
\item \textbf{Communication Features:}
\begin{itemize}
\item Support one-to-one messaging.
\item Include basic message delivery notifications.
\item Implement message persistence with proper encryption at rest.
\end{itemize}
\item \textbf{User Interface:}
\begin{itemize}
\item Create a simple CLI or GUI interface for interaction.
\item Implement basic operations: send messages, view conversations, and manage contacts.
\item Include proper authentication and session management.
\item Add timeout for automatic logout.
\item Include proper error handling without leaking sensitive information.
\end{itemize}
\end{enumerate}
\subsection*{Implementation Guidelines}
\subsubsection*{Step 1: Design}
Begin by creating a threat model for your secure messenger. Consider:
\begin{itemize}
\item Who are the attackers? (Network adversaries, server operators, malicious contacts)
\item What assets are you protecting? (Message content, metadata, contact information)
\item What are the attack vectors? (TLS interception, server compromise, client malware)
\item What cryptographic protections will you employ?
\end{itemize}
Document your design decisions and security assumptions.
\subsubsection*{Step 2: Cryptographic Building Blocks}
Implement or properly use existing libraries for:
\begin{itemize}
\item Public-key cryptography for identity and initial key exchange.
\item Symmetric key ratcheting for forward secrecy.
\item Authenticated encryption for message protection.
\item Secure random number generation.
\end{itemize}
\subsubsection*{Step 3: Core Functionality}
Implement the core functionality:
\begin{itemize}
\item User registration and identity establishment.
\item Contact discovery and key exchange.
\item Message encryption, transmission, and decryption.
\item Session management and key ratcheting.
\end{itemize}
\subsubsection*{Step 4: User Interface}
Create an interface that balances security and usability:
\begin{itemize}
\item User authentication flow.
\item Conversation view and message composition.
\item Contact management and verification.
\item Security indicators and warnings.
\end{itemize}
\subsubsection*{Step 5: Security Hardening}
Add security features like:
\begin{itemize}
\item Memory protection techniques for cryptographic material.
\item Protection against replay and message reordering attacks.
\item Input validation and error handling.
\item Secure deletion of messages when requested.
\end{itemize}
\subsection*{Deliverables}
Submit the following:
\begin{enumerate}
\item Source code for your secure messenger.
\item Design document including:
\begin{itemize}
\item Threat model and security assumptions.
\item Description of cryptographic mechanisms used.
\item Network protocol specifications.
\item Design decisions and their rationale.
\end{itemize}
\item User manual explaining how to use your secure messenger.
\item Security analysis discussing:
\begin{itemize}
\item Strengths of your implementation.
\item Limitations and potential vulnerabilities.
\item Suggested improvements for a production version.
\end{itemize}
\end{enumerate}
\subsection*{Evaluation Criteria}
Your project will be evaluated based on:
\begin{itemize}
\item Correctness of cryptographic implementations.
\item Security of the overall design and protocol.
\item Completeness of required functionality.
\item Quality of code and documentation.
\item Thoughtfulness of security analysis.
\item Robustness against the threats identified in your model.
\end{itemize}
\subsection*{Resources}
\begin{itemize}
\item The course textbook and materials on public-key cryptography and secure protocols.
\item Libraries: libsodium, OpenSSL, Signal Protocol libraries based on your language choice.
\item Research papers on secure messaging protocols (see course website).
\item Specifications for Signal Protocol, OTR, or Matrix.
\end{itemize}
\subsection*{Submission Guidelines}
\begin{itemize}
\item Submit your code as a ZIP archive or through a Git repository.
\item Include all documentation in PDF or Markdown format.
\item Presentations: Prepare a 10-minute presentation demonstrating your secure messenger.
\end{itemize}
\end{document}

View file

@ -0,0 +1,159 @@
\documentclass[10pt,a4paper,american]{article}
\newcommand{\aublogopath}{../../website/res/img/aub_black.png}
\usepackage{../../misc/macros/joc}
\usepackage{../../misc/fonts/fonts}
\usepackage{../../misc/macros/classhandout}
\begin{document}
\classhandoutheader
\section*{Lab Assignment: Building a Zero-Knowledge Battleship Game}
\subsection*{Overview}
In this lab, you will design and implement a zero-knowledge battleship game using RISC Zero, a zero-knowledge virtual machine (zkVM). This represents your first opportunity to apply zero-knowledge proofs to build a complete cryptographic protocol—one that allows players to validate their moves without revealing the entire game state. Zero-knowledge battleship demonstrates how players can validate that their guesses produced the correct result (hit vs. no hit) while learning nothing about the opponent's board except what is explicitly revealed through gameplay. By building this game, you'll gain practical experience with zero-knowledge proofs, zkVMs, and cryptographic protocol design. Future lab assignments will build upon these skills by incorporating more complex zero-knowledge applications.
\subsection*{Learning Objectives}
After completing this lab, you should be able to:
\begin{itemize}
\item Apply zero-knowledge proofs to create verifiable computations.
\item Understand and use zkVMs, particularly RISC Zero.
\item Design and build a cryptographic protocol with proper threat modeling.
\item Evaluate the security properties of zero-knowledge applications.
\end{itemize}
\subsection*{Background}
Zero-knowledge proofs allow one party (the prover) to prove to another party (the verifier) that a statement is true without revealing any additional information. In the context of a battleship game:
\begin{itemize}
\item Player 1 can prove whether Player 2's guess hit or missed a ship.
\item The proof is verifiable by Player 2 without revealing the full board layout.
\item The game remains secure against cheating because all moves can be verified.
\item zkVMs like RISC Zero allow developers to generate proofs for arbitrary computations.
\end{itemize}
\subsection*{Requirements}
Your zero-knowledge battleship game must implement the following core functionality:
\begin{enumerate}
\item \textbf{Game Initialization:}
\begin{itemize}
\item Create a secure board setup procedure where players place ships.
\item Generate cryptographic commitments to board layouts.
\item Implement proper validation of initial board configurations.
\end{itemize}
\item \textbf{Game Rounds:}
\begin{itemize}
\item Generate zero-knowledge proofs for hit/miss responses using RISC Zero.
\item Verify proofs to ensure honest gameplay.
\item Track game state securely throughout the game.
\end{itemize}
\item \textbf{Game Logic:}
\begin{itemize}
\item Implement standard battleship rules.
\item Detect when a player has won the game.
\item Ensure all game state transitions are verifiable.
\end{itemize}
\item \textbf{User Interface:}
\begin{itemize}
\item Create a simple CLI interface for gameplay.
\item Display the game boards (with appropriate information hiding).
\item Implement commands for making guesses and viewing game status.
\item Include proper error handling without leaking sensitive information.
\end{itemize}
\end{enumerate}
\subsection*{Implementation Guidelines}
\subsubsection*{Step 1: Design}
Begin by creating a threat model for your zero-knowledge battleship game. Consider:
\begin{itemize}
\item Who are the attackers? (Cheating players, observers)
\item What assets are you protecting? (Board layouts, game integrity)
\item What are the attack vectors? (False claims about hits/misses, board manipulation)
\item What cryptographic protections will you employ?
\end{itemize}
Document your design decisions and security assumptions.
\subsubsection*{Step 2: Cryptographic Building Blocks}
Implement or properly use RISC Zero for:
\begin{itemize}
\item Creating guest programs to verify hits and misses.
\item Generating and verifying zero-knowledge proofs.
\item Securing the game state throughout gameplay.
\end{itemize}
\subsubsection*{Step 3: Core Functionality}
Implement the core functionality:
\begin{itemize}
\item Board initialization and commitment.
\item Move validation with zero-knowledge proofs.
\item Game state management and victory detection.
\end{itemize}
\subsubsection*{Step 4: User Interface}
Create an interface that balances security and usability:
\begin{itemize}
\item Board visualization showing appropriate information.
\item Commands for making guesses.
\item Clear indication of proof validation results.
\end{itemize}
\subsubsection*{Step 5: Security Hardening}
Add security features like:
\begin{itemize}
\item Verification of all cryptographic proofs.
\item Protection against replay and timing attacks.
\item Input validation and error handling.
\end{itemize}
\subsection*{Deliverables}
Submit the following:
\begin{enumerate}
\item Source code for your zero-knowledge battleship game.
\item Design document including:
\begin{itemize}
\item Threat model and security assumptions.
\item Description of zero-knowledge mechanisms used.
\item Design decisions and their rationale.
\end{itemize}
\item User manual explaining how to play your game.
\item Security analysis discussing:
\begin{itemize}
\item Strengths of your implementation.
\item Limitations and potential vulnerabilities.
\item Suggested improvements for a production version.
\end{itemize}
\end{enumerate}
\subsection*{Evaluation Criteria}
Your project will be evaluated based on:
\begin{itemize}
\item Correctness of zero-knowledge proof implementations.
\item Security of the overall design.
\item Completeness of required functionality.
\item Quality of code and documentation.
\item Thoughtfulness of security analysis.
\end{itemize}
\subsection*{Resources}
\begin{itemize}
\item The course textbook and materials on zero-knowledge proofs.
\item RISC Zero documentation and examples.
\item Directory structure and README provided for the project.
\item Research papers on zero-knowledge applications (see course website).
\end{itemize}
\subsection*{Submission Guidelines}
\begin{itemize}
\item Submit your code as a ZIP archive or through a Git repository.
\item Include all documentation in PDF or Markdown format.
\item Presentations: Prepare a 10-minute presentation demonstrating your zero-knowledge battleship game.
\end{itemize}
\end{document}