CSCI 780: Spring 2026
Distributed System Security
Project 3: swp

Due: Tue, May 12, 11:59pm


In this project, you will implement a client (client) and server (server) that implement the searchable encryption scheme of Song et al. in the paper Practical Techniques for Searches on Encrypted Data. Specifically, you will implement the paper's final scheme as described in Section 4.4.

Word Size and Padding

To simplify the project, we will encrypt only ASCII text (no commas or periods). The word size is 32 bytes; if a word is less than 32 bytes, it is first padded to 32 bytes with trailing space characters before pre-encrypting it. On decryption, these trailing spaces are removed, and each word is separated from the next word by a single space.

Parameters and Cryptographic Schemes

For our pseudorandom generator (the paper's G stream cipher that generates the S values), we will use AES-256 in CTR mode. The size of each S value is 24-bytes.

For our pseudorandom function (the paper's F function), we will use an HMAC parameterized with SHA256 and a 32-byte key, truncating the output to 8 bytes.

For our pseudorandom permutation (the paper's block cipher E), we will use AES-256 in ECB mode. When pre-encrypting the word, we consider the left portion (the paper's L value) to be the first 24-bytes.

Requests

The client communicates with the server over plain HTTP. There are two types of requests: search and fetch

Searching by Keyword

When searching for the documents that matcha given keyword, the client makes an HTTP GET request to http://ip:port/search?x=...k=.... The x query parameter is the pre-encrypted word to search for, and k is the PRF key. The client should use base64.RawURLEncoding.EncodeToString to encode both values.

Upon receiving the request, the server searches the encrypted files under its static directory. If the server find matching files, it replies with an HTTP status code of 200 and a plaintext (Context-Type: text/plain) containing the matching file names (e.g., a.enc), one per-line.

If the server does not find a matching file, it should return the HTTP status code 404.

If the server detects that the client's request is malformed (e.g., missing a query parameter), it should return the HTTP status code 400.

Fetching Content

If the client wants to fetch an encrypted file (e.g., a.enc), it makes a GET request to http://ip:port/static/a.enc. Upon receiving the file, the client decrypts, separates each word by a space, and prints the plaintext to stdout.

If the file does not exist, the server should return the HTTP status code 404.

Skeleton Code

To help get started, please use the following swp.zip skeleton module.

client


Name

client - search and fetch files over the SWP protocol.

Synopsis

client [options] HOST:PORT

Positional Arguments

HOST:PORT

The host:port of the server to connect to. HOST can be an IP address or a domain name.

Options

-prg-key KEY_FILE

The client's PRG (stream cipher) key.

-prf-key KEY_FILE

The client's PRF (HMAC key) key.

-search SEARCH_WORD

The plaintext word to search.

-get ENCRYPTED_FILE

The encrypted file to fetch and decrypt. (The client must specify exactly one of -search or -get)

-help

Show this usage statement and exit.

server


Name

server - encrypted file server

Synopsis

server [HOST]:PORT

Positional Arguments

[HOST]:PORT

A "host:port" address to listen on for connections.

-help

Display this usage statement and exit.

Submitting

Submit your project as a zip file via gradescope. Your project must include a Makefile that builds two executables: sget and sgetd. Please refer to the instructions for submitting an assignment for details on how to login to gradescope and properly zip your project.

Rubric

Server

1.1 server requested to lookup 'happy' (10 pts)


        ./server 127.0.0.1:12345
        

        ./instructor/client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -search happy 127.0.0.1:12345
(out)b.enc
        

1.2 server requested to lookup 'fly' (10 pts)


        ./server 127.0.0.1:12345
        

        ./instructor/client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -search fly 127.0.0.1:12345
(out)a.enc
(out)c.enc
        

1.3 server requested to lookup 'green' (10 pts)


        ./server 127.0.0.1:12345
        

        ./instructor/client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -search green 127.0.0.1:12345
(out)no files found
        
This is printed to stderr.

1.4 server requested to get 'a.enc' (10 pts)


        ./server 127.0.0.1:12345
        

        ./instructor/client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -get a.enc 127.0.0.1:12345
(out)Somewhere over the rainbow Bluebirds fly Birds fly over the rainbox Why then oh why can't I
        

1.5 server requested to get 'd.enc' (10 pts)


        ./server 127.0.0.1:12345
        

        ./instructor/client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -get d.enc 127.0.0.1:12345
(out)file not found
        
This is printed to stderr.

Client

2.1 client looks up 'happy' (10 pts)


        ./instructor/server 127.0.0.1:12345
        

        ./client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -search happy 127.0.0.1:12345
(out)b.enc
        

2.2 client looks up 'fly' (10 pts)


        ./instructor/server 127.0.0.1:12345
        

        ./client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -search fly 127.0.0.1:12345
(out)a.enc
(out)c.enc
        

2.3 client looks up 'green' (10 pts)


        ./instructor/server 127.0.0.1:12345
        

        ./client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -search green 127.0.0.1:12345
(out)no files found
        
This is printed to stderr.

2.4 client gets 'a.enc' (10 pts)


        ./instructor/server 127.0.0.1:12345
        

        ./client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -get a.enc 127.0.0.1:12345
(out)Somewhere over the rainbow Bluebirds fly Birds fly over the rainbox Why then oh why can't I
        

2.5 client gets 'd.enc' (10 pts)


        ./instructor/server 127.0.0.1:12345
        

        ./client -prg-key keys/prg.key -prf-key keys/prf.key -prp-key keys/prp.key -get d.enc 127.0.0.1:12345
(out)file not found
        
This is printed to stderr.