Skip to content

Commit 3e665e3

Browse files
committed
Add share timeout configuration
1 parent 7ee4e4a commit 3e665e3

File tree

5 files changed

+73
-4
lines changed

5 files changed

+73
-4
lines changed

common/configuration.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
MIN_MIN_NR_SHARES = 1 # We allow 1, which really means the secret is not split at all.
4141
MAX_MIN_NR_SHARES = 128
4242

43+
# Timeout for shares in seconds. Shares stored on hubs will be deleted if the responder SAE does
44+
# not retrieve them by invoking the Get key with key IDs API call within this timeout.
45+
DEFAULT_SHARE_TIMEOUT_SECS = 60 # 1 minute
46+
MIN_SHARE_TIMEOUT_SECS = 1
47+
MAX_SHARE_TIMEOUT_SECS = 86_400 # 1 day
48+
4349

4450
def fatal_error(message: str):
4551
"""
@@ -60,6 +66,7 @@ class Configuration:
6066
stop_request_psrd_threshold: int
6167
get_psrd_block_size: int
6268
min_nr_shares: int
69+
share_timeout_secs: int
6370

6471
def __init__(
6572
self,
@@ -68,13 +75,15 @@ def __init__(
6875
stop_request_psrd_threshold,
6976
get_psrd_block_size,
7077
min_nr_shares,
78+
share_timeout_secs,
7179
nodes,
7280
):
7381
self.base_port = base_port
7482
self.start_request_psrd_threshold = start_request_psrd_threshold
7583
self.stop_request_psrd_threshold = stop_request_psrd_threshold
7684
self.get_psrd_block_size = get_psrd_block_size
7785
self.min_nr_shares = min_nr_shares
86+
self.share_timeout_secs = share_timeout_secs
7887
# Sort nodes by type and name, so that clients are always before hubs (the order matters
7988
# for startup and shutdown).
8089
self.nodes = sorted(nodes)
@@ -144,6 +153,12 @@ def _assign_ports_and_urls(self):
144153
"min": MIN_MIN_NR_SHARES,
145154
"max": MAX_MIN_NR_SHARES,
146155
},
156+
"share_timeout_secs": {
157+
"type": "integer",
158+
"default": DEFAULT_SHARE_TIMEOUT_SECS,
159+
"min": MIN_SHARE_TIMEOUT_SECS,
160+
"max": MAX_SHARE_TIMEOUT_SECS,
161+
},
147162
"hubs": {
148163
"type": "list",
149164
"schema": HUB_SCHEMA,
@@ -199,5 +214,6 @@ def parse_configuration_file(filename: str) -> Configuration:
199214
parsed_config["stop_request_psrd_threshold"],
200215
parsed_config["get_psrd_block_size"],
201216
parsed_config["min_nr_shares"],
217+
parsed_config["share_timeout_secs"],
202218
nodes,
203219
)

docs/user-guide.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ $ <b>cat dske-config.yaml</b>
5959
# from the key shares using Shamir's Secret Sharing (SSS).
6060
# Optional; default value is 3.
6161

62+
# share_timeout_secs: 60 # Timeout for shares in seconds. Shares stored on hubs are
63+
# deleted if the responder SAE does not retrieve them by
64+
# invoking the Get key with key IDs API call within this
65+
# timeout.
66+
# Optional; default value is 60 seconds.
67+
6268
hubs: # List of hubs (aka DSKE security hubs) in the DSKE topology.
6369
- name: hank # Name of the hub.
6470
- name: helen
@@ -310,16 +316,18 @@ Use the `--help` option to see its usage:
310316

311317
<pre>
312318
$ <b>python -m hub --help</b>
313-
usage: hub [-h] [-p PORT] name
319+
usage: hub [-h] [-p PORT] [--share-timeout-secs SHARE_TIMEOUT_SECS] name
314320

315321
DSKE Hub
316322

317323
positional arguments:
318-
name Hub name
324+
name Hub name
319325

320326
options:
321-
-h, --help show this help message and exit
322-
-p, --port PORT Port number
327+
-h, --help show this help message and exit
328+
-p, --port PORT Port number
329+
--share-timeout-secs SHARE_TIMEOUT_SECS
330+
Share timeout in seconds (default: 60)
323331
</pre>
324332

325333
The typical usage is to provide the hub name and the port number.

dske-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
# from the key shares using Shamir's Secret Sharing (SSS).
2525
# Optional; default value is 3.
2626

27+
# share_timeout_secs: 60 # Timeout for shares in seconds. Shares stored on hubs are
28+
# deleted if the responder SAE does not retrieve them by
29+
# invoking the Get key with key IDs API call within this
30+
# timeout.
31+
# Optional; default value is 60 seconds.
32+
33+
# Timeout for shares in seconds. Shares stored on hubs will be deleted if the responder SAE does
34+
# not retrieve them by invoking the Get key with key IDs API call within this timeout.
35+
36+
2737
hubs: # List of hubs (aka DSKE security hubs) in the DSKE topology.
2838
- name: hank # Name of the hub.
2939
- name: helen

hub/cli.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,22 @@
33
"""
44

55
import argparse
6+
from common import configuration
7+
8+
9+
def _check_share_timeout_secs(value):
10+
int_value = int(value)
11+
if (
12+
int_value <= configuration.MIN_SHARE_TIMEOUT_SECS
13+
or int_value > configuration.MAX_SHARE_TIMEOUT_SECS
14+
):
15+
raise argparse.ArgumentTypeError(
16+
f"value {value} is invalid; "
17+
f"it must be between "
18+
f"{configuration.MIN_SHARE_TIMEOUT_SECS} and "
19+
f"{configuration.MAX_SHARE_TIMEOUT_SECS}"
20+
)
21+
return int_value
622

723

824
def parse_command_line_arguments():
@@ -17,5 +33,15 @@ def parse_command_line_arguments():
1733
type=int,
1834
help="Port number",
1935
)
36+
parser.add_argument(
37+
"--share-timeout-secs",
38+
type=_check_share_timeout_secs,
39+
default=configuration.DEFAULT_SHARE_TIMEOUT_SECS,
40+
help=(
41+
f"Share timeout in seconds "
42+
f"(default: {configuration.DEFAULT_SHARE_TIMEOUT_SECS})"
43+
),
44+
)
45+
2046
args = parser.parse_args()
2147
return args

manager.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ def start_node(self, node: Node, extra_args: list | None = None):
219219
]
220220
if node.encryptor_names:
221221
command += ["--encryptors"] + node.encryptor_names
222+
else:
223+
if (
224+
self._config.share_timeout_secs
225+
!= configuration.DEFAULT_SHARE_TIMEOUT_SECS
226+
):
227+
command += [
228+
"--share-timeout-secs",
229+
str(self._config.share_timeout_secs),
230+
]
222231
if extra_args is not None:
223232
command += extra_args
224233
_process = subprocess.Popen(command, stdout=out_file, stderr=out_file)

0 commit comments

Comments
 (0)