Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: formal verification #5

Merged
merged 30 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cc81bd5
Simple model of encryption and communication user <-> keystore, 3 ass…
kibasaur Apr 1, 2024
019ad4d
Changed Markdown
kibasaur Apr 1, 2024
8ad6886
Added Access Control Component
kibasaur Apr 4, 2024
951bc6d
Fixed indexation error in Access Control - Decrypt
kibasaur Apr 4, 2024
699ff68
database component created, support for additional user in the works,…
kibasaur Apr 18, 2024
648295b
assertion violation fixed
kibasaur Apr 18, 2024
5abd84a
KMS now delegates KEKs to tenants. Added alternative clock component.…
kibasaur Apr 23, 2024
019cd03
User changed to Tenant
kibasaur Apr 24, 2024
43bd627
Model is mostly done with an alternative model that only uses a singl…
kibasaur May 2, 2024
323a3f5
removed some global vars
kibasaur May 2, 2024
ede879b
changed process id check to simply passed id parameter in proctype Te…
kibasaur May 2, 2024
fd161d3
Formatting and edited comments
kibasaur May 2, 2024
9dddc38
Added some information in README.md
kibasaur May 2, 2024
f21e16d
Formatting in README.md
kibasaur May 2, 2024
f765133
Reduced memory usage significantly
kibasaur May 3, 2024
5e0a755
New model_c which is asynch and can handle 2 requests and be run in a…
kibasaur May 13, 2024
95f62a1
Safety v1 for model 1 verified
kibasaur May 18, 2024
abd6dab
model_c contains assign, encrypt and decrypt and ready to be verifie…
kibasaur May 23, 2024
1c7ddaa
changes weren't added to model_c, so recommit
kibasaur May 23, 2024
72dac4f
Refactored model_c and renamed it model.pml
kibasaur May 27, 2024
f31e139
Models A-D verified
kibasaur Jun 4, 2024
4d4dbb1
Verified
kibasaur Jun 4, 2024
91b9e02
edited README
kibasaur Jun 4, 2024
5187adc
typo in README
kibasaur Jun 4, 2024
00b7f20
changed names of liveness claims
kibasaur Jun 4, 2024
603ce57
model 2 and 4 reverified
kibasaur Jun 8, 2024
5fbdff6
Message vocabulary changed, cache exclusive or added, keystore databa…
kibasaur Jul 26, 2024
4c39bfe
added some documentation to README
kibasaur Aug 9, 2024
a829f47
fix: this file shouldnt be committed
bittermandel Oct 2, 2024
614d3e5
docs: rename and correction of docs
bittermandel Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions formal-verification/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Sebastian Owuya

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the Software), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
87 changes: 87 additions & 0 deletions formal-verification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# A Functional Verification of the KMS in SPIN

Verification in SPIN that verifies the functionality of KEK assignment, encryption, decryption and re-encryption.

There are 4 different models that each verify different operations.

## Models

Model can be set by changing the MODEL constant.

1=A 2=B 3=C 4=D In the paper.

1: Assignemnt and Encryption.
2: Decryption after assignment and encryption has been finalized.
3: Re-Encryption of envelopes after assignment and encryption has been finalized.
4: Tenant 1 assignment and encryption then invalid credentials, Tenant 2 only Decrypts envelopes received from Tenant 1 with different grants.

If MODEL == 1 then IS_MODEL_1 == 1
If MODEL != 1 then IS_MODEL_1 == 0

## To Run and Verify

Most of this can be done with an external tool such as iSPIN, additional information found [here](https://spinroot.com/spin/Man/README.html).

**Run Code**
spin -T model.pml - Regular run that will halt on error and print any statements in the code.
spin -a model.pml - generates pan.c for verification.

**Compile pan.c**
gcc -DMEMLIM=N -O2 -DXUSAFE -DCOLLAPSE -DNFAIR=3 (-DSAFETY) -w -o pan pan.c

-DSAFETY used when verifying safety.

**Verify**
./pan -mN (-a -f) (-N claim)
In -mN, N is an integer for max depth, however -N is a flag to specify which claim to verify, e.g ./pan -m1000000 -N safety
-a -f used when verifying liveness.

# Additional Documentation

This project implements a key management service (KMS) based on the design and formal verification described in the master's thesis "Formally Verifying a Key Management Service" by Sebastian Owuya. While the implementation is still in progress, it aims to realize key concepts from the thesis.

## Current Implementation Status

### Architecture

The current implementation in the Valv repository does not yet fully reflect the layered architecture described in the thesis. Instead, it implements a single-layer structure with envelope encryption, where a KEK is used to encrypt data or a DEK (see encrypt() in `crates/valv/src/lib.rs`).

### Protocol Operations

The verified protocol operations are partially implemented:

1. **KEK Assignment**: Implemented in `crates/valv/src/lib.rs` in the `create_crypto_key()` function of the `ValvAPI` trait. The `API` struct in `crates/valv/src/api/server.rs` exposes this functionality.

2. **Encryption**: Core encryption logic is in `crates/valv/src/lib.rs` in the `encrypt()` function of the `ValvAPI` trait. The `API` struct in `crates/valv/src/api/server.rs` exposes this functionality.

3. **Decryption**: Implemented in `crates/valv/src/lib.rs` in the `decrypt()` function of the `ValvAPI` trait. The `API` struct in `crates/valv/src/api/server.rs` exposes this functionality.

4. **Re-encryption**: Not explicitly implemented yet, but the foundation exists within the encryption and decryption functions.

### Components

The implementation separates the following components:

- Tenant
- Keystore
- Database

However, the Access Control component is currently missing. The assumptions around the tenant and the inductivity of how a keystore can be seen as a tenant would benefit from a more fleshed out implementation where tests can be constructed to simulate a "layered" structure.

### Message Passing

Message passing between components is implemented through function calls. For example, any call to `self.db` is treated as an asynchronously passed message. However, the storage of `self.master_key` directly within the Keystore may need reconsideration to better align with the thesis design.

## Alignment with Thesis and Future Work

While the current implementation incorporates key concepts from the thesis, there are areas that require further development to fully realize the verified design:

1. **Layered Architecture**: Implement the full layered structure as described in the thesis.
2. **Access Control**: Add the missing Access Control component.
3. **Complete Protocol Operations**: Fully implement all operations, including re-encryption.
4. **Refine Component Separation**: Ensure clear separation of concerns, especially regarding key storage.
5. **Testing**: Develop tests to verify the "layered" structure and component interactions.

It's important to note that while the implemented protocol is based on the verified model from the thesis, the current implementation may not yet fully adhere to all the requirements verified in the thesis. Further work is needed to ensure that the implementation preserves all the properties proven in the formal verification.

As development continues, this documentation should be updated to reflect progress and maintain traceability to the thesis. Any deviations from or extensions to the verified design should be carefully considered and documented.
Loading
Loading