| Crates.io | dhcache |
| lib.rs | dhcache |
| version | 0.0.2 |
| created_at | 2023-03-24 04:08:50.5624+00 |
| updated_at | 2025-03-13 02:18:20.784242+00 |
| description | A micro Diffie-Hellman parameter generation web-service |
| homepage | |
| repository | https://github.com/brianewell/dhcache |
| max_upload_size | |
| id | 819030 |
| size | 30,165 |
DHCache is a micro Diffie-Hellman parameter generation web service. It provides a lightweight and efficient way to concurrently pre-generate and maintain an ephemeral cache of unique DH parameters in various sizes for secure key exchange operations.
DHCache is available on crates.io, and can be installed using cargo:
cargo install dhcache
If you prefer to experiment with the latest version from the source repository, you can directly clone and build it manually.
# Clone the repository
git clone https://github.com/brianewell/dhcache.git
cd dhcache
# Optionally run tests
cargo test
# Build the project
cargo build --release
# Run the service
./target/release/dhcache
All configuration is performed through command-line parameters, available by calling the program with the --help flag:
dhcache --help
A micro Diffie-Hellman parameter generation web service
Usage: dhcache [OPTIONS] <count>:<bits>...
Arguments:
<count>:<bits>...
Options:
-b, --bind <address> [default: 0.0.0.0]
-p, --port <port> [default: 4000]
-w, --workers <workers> [default: 1]
-h, --help Print help
-V, --version Print version
The listening address, port, and worker count have configurable defaults. The cache behavior is defined by a collection of <count>:<bits> pairs, where <count> represents the number of DH parameters of size <bits> to cache.
The following command starts DHCache on its default listening address, port 80, and uses two worker threads to maintain a cache of eight 1024-bit DH parameters, four 2048-bit DH parameters, and two 4096-bit DH parameters:
dhcache -w 2 8:1024 4:2048 2:4096
All interactions with DHCache occur via the configured web service.
GET /
GET /status
Returns the overall status of the cache.
Example Response:
{
"1024": {
"path": "/1024",
"available": 6,
"max": 8
},
"2048": {
"path": "/2048",
"available": 4,
"max": 4
},
"4096": {
"path": "/4096",
"available": 2,
"max": 2
}
}
GET /<bits>
Returns a set of DH parameters.
<bits> (integer): Specifies the key size of DH parameters to retrieve from the cache.DELETE /<bits>
Clears and regenerates all DH parameters for a given size.
<bits> (integer): Specifies the key size of DH parameters to clear from the cache.Contributions are welcome! Please open an issue or submit a pull request to improve DHCache.
This project is licensed under the MIT License. See LICENSE for details.
For questions or issues, feel free to open an issue on GitHub.