summaryrefslogtreecommitdiff
path: root/doc/dev/notes/state-management-cli.md
blob: 9b61eebc6aca6f350d0a56628637ca05892acbf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
# State and key management CLI

Arti will need the following new subcommands:

  * `arti-keys`, porcelain key management commands, for general key management
  * `arti-keys-raw`, plumbing key management commands
  * `arti-hss`, for managing the state (including keys) of hidden services
  * `arti-hsc`, for managing the state (including keys) of hidden service
    clients

Initially, `arti-hss` and `arti-hsc` will be only used for listing,
manipulating, and verifying the contents of Arti key stores (they are frontends
to Arti's [`KeyMgr`]). In the future, they will be extended to support
manipulatating other types of persistent state too (for example, `arti hss` will
also be used for manipulating the on-disk IPT records of the service).

NOTE: The subcommands documented here do not exist yet. Rather than being the
documentation for a finished product, this document is
  * a design document describing what needs to be implemented (which implicitly
    highlights what `KeyMgr` features we are missing)
  * a starting point for the CLI docs (although it might require some
    amendments, depending on how much the implementation deviates from what is
    described here)

This document illustrates what the rendered man pages for the future state
management CLIs might look like. The actual documentation/man pages will be be
generated by rendering the [ROFF] obtained from the documentation of Arti's
`clap::Command` (which will include the new `hsc` and `hss` subcommands).

NOTE: This document talks about "keys and certificates", but the `KeyMgr` does not
currently support certificates (but it will in the future. See [arti#955])

NOTE: `arti-keys`, `arti-keys-raw`, `arti-hsc` and `arti-hss` will be
implemented as arti subcommands (`arti keys`, `arti hsc`, `arti hss`).

TODO HSS: Design commands for converting C Tor HS service state to an Arti
keystore and associated state (calling it something like `arti-hss migrate` or
`arti-hss ctor-migrate`)

## `arti-keys`
```
NAME
       arti-keys - Command-line key management tools for Arti

DESCRIPTION
       A CLI for accessing, manipulating and validating the contents of Arti key
       stores.

       As with arti, keystores are configured through Arti's TOML config
       (specified using the --config flag).

       The key management functionality is exposed as a collection of
       subcommands, each subcommand supporting a different set of options.

       This command provides high-level subcommands ("porcelain"), suitable for
       most use cases. Its subcommands implement high-level operations,
       manipulating either individual keys or key bundles, as applicable. They
       also provide guardrails preventing users from corrupting the key stores,
       and are suitable for routine key management tasks. Moreover, they don't
       require familiarity with the implementation details of Arti's key stores.

       TODO: explain what an ArtiPath is (ArtiPaths are mentioned throughout
       the manual)

OPTIONS
       -c, --config <FILE>
               Specify which config file(s) to read. Defaults to
               [File("$HOME/.config/arti/arti.toml"),
               Dir("$HOME/.config/arti/arti.d/")]

           --disable-fs-permission-checks
               Don't check permissions on the files we use.

       --keystore-dir <ARTI_KEYSTORE>
          Use the keystore from the specified directory, which should be an Arti
          format keystore. This is a convenience alias for
          -o storage.keystore.path=<ARTI_KEYSTORE>

       -h, --help
               Print help information

       -l, --log-level <LEVEL>
               Override the log level (usually one of 'trace', 'debug', 'info', 'warn', 'error').

       -o <KEY=VALUE>
               Override config file parameters, using TOML-like syntax.

       -V, --version
            Print version information

SUBCOMMANDS
       help               Print this message or the help of the given subcommand(s)
       list               List keys and certificates from the configured key stores
       describe           Print information about a specific key
       verify             Perform validity and consistency checks
```

### `arti-keys-list`

```
NAME
       arti-keys-list - List keys and certificates from the configured key
       stores

SYNOPSIS
       arti keys list [OPTIONS]

DESCRIPTION
       List the keys and certificates from the specified key stores. If no key
       stores are specified, this command lists the keys and certificates from
       all stores.

       In the pretty-printed output:
          * expired keys and certificates are annotated with (exp).
          * unrecognized keys and certificates (i.e. keys that have an unknown
            purpose) are annotated with (unk)
          * the keys and certificates that are not associated with one of the
            configured identities (i.e. keys with an unrecognized client/service
            nickname) are also annotated with (unk)

OPTIONS
       --keystore all
            List the keys and certificates from all key stores. This is the
            default behavior if the --keystore flag is omitted
       --keystore default
            List the keys and certificates from the default keystore.
       --keystore [<kid>...]
            Specifies the IDs of the keystores to list keys and certificates
            from. The IDs must be associated with keystores from the Arti TOML
            config. It is an error to specify a key store ID not associated with
            any of the configured key stores.
        --output [pretty|json]
            The output format. Defaults to 'pretty', a pretty-printed,
            human-friendly format.
       --verbose
           Print more information about each listed key. This includes a
           description of the key, the ID of the key store it is located in, and
           whether the key is unrecognized or expired. This flag is disregarded
           if --output=json, because the JSON output always contains the full
           description of the key

       TODO: in the future we might want an option for only listing certs or
       only listing a type of key
       TODO: maybe this needs an option for listing keys that match a given
       ArtiPath pattern?

EXAMPLES
       To pretty-print all the keys and certificates from keystores foo
       and bar:

         arti keys --config arti.toml list   \
           --keystore foo,bar                \
           --output pretty

       Sample output:

         ===== foo =====
           client/alice/abc.onion/KS_hsc_desc_enc.x25519_private
           client/alice/xyz.onion/KS_hsc_desc_enc.x25519_private
           client/alice/xyz.onion/KS_hsc_desc_not_a_valid_name.x25519_private (unk)
           hs/carol/KS_hs_id.expanded_ed25519_private
           hs/carol/KS_hs_blind_id+19666_1440_43200.ed25519_expanded_private (exp)
           hs/carol/KS_hs_blind_id+19667_1440_43200.ed25519_expanded_private
           hs/carol/KS_hs_desc_sign+19666_1440_43200.ed25519_expanded_private (exp)
           hs/carol/KS_hs_desc_sign+19667_1440_43200.ed25519_expanded_private
           hs/dan/KS_hs_id.expanded_ed25519_private
           hs/eve/KS_hs_blind_id+19666_1440_43200.ed25519_expanded_private (unk)
           hs/eve/KS_hs_desc_sign+19667_1440_43200.ed25519_expanded_private (unk)
         ===== bar =====
           client/bob/def.onion/KS_hsc_desc_enc.x25519_private

       To include more information about each key, use --verbose:

         arti keys --config arti.toml list   \
           --keystore foo,bar                \
           --output pretty                   \
           --verbose

       Sample output:

         ===== client/alice/abc.onion/KS_hsc_desc_enc.x25519_private =====
           purpose: Client authorization key, used for onion descriptor decryption
           client: alice
           keystore ID: foo
           expired: no

         ===== client/alice/xyz.onion/KS_hsc_desc_not_a_valid_name.x25519_private =====
           purpose: unknown
           client: alice
           keystore ID: foo

         ===== hs/eve/KS_hs_desc_sign+19666_1440_43200.ed25519_expanded_private =====
           purpose: descriptor signing key
           service: unknown
           keystore ID: foo
           expired: unknown

         ===== hs/eve/KS_hs_desc_sign+19667_1440_43200.ed25519_expanded_private =====
           purpose: descriptor signing key
           service: unknown
           keystore ID: foo
           expired: unknown
          ...


       With --output=json, the command prints the same information in JSON format.

       TODO: Add JSON output sample
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::list_matching`
  * `KeyMgr::describe`

TODO: we might want to add a `KeyMgr::list_all` for listing all the keys from a
given store (today this can be achieved by calling `list_matching` with a `"*"`
`KeyPathPattern`).

This command will be implemented by an API that uses `KeyMgr::list_matching` and
`KeyMgr::describe` under the hood. Note: `KeyMgr::list_matching` lists the keys
from all keystores. It will need to be modified to accept a `KeystoreSelector`
argument to support only listing the keys from a given keystore (otherwise we
can't implement the `--keystore` option). We'll also need some way of detecting
which keys are expired: given a valid `KeyPath`, the API will:
  * parse it back into its corresponding `KeySpecifier`
  * check if the `TimePeriod` stored in the `KeySpecifier` is "relevant". If it
    is not, it will declare the key expired. Checking if the `TimePeriod` is
    relevant or not can be done by checking if it's one of the
    `NetDir::hs_all_time_periods()` returned by a recent `NetDir`.
    Alternatively, the API could try to "guess" which time periods are relevant
    based on the current wallclock time

### `arti-keys-verify`

```
NAME
       arti-keys-verify - perform consistency, validity, and integrity checks
       on the specified stores

SYNOPSIS
       arti keys verify [OPTIONS]

DESCRIPTION
       The key vality checks fail if there are any
         * keys and certificates not associated with any current identity
         * unrecognized keys
         * expired keys
         * ... (TODO)

       If --fix is not specified, this command lists the keys and
       certificates that failed the validity checks from each key store,
       along with the reason for the failure.

       Note:
          * expired keys and certificates are annotated with (exp).
          * unrecognized keys and certificates (i.e. keys that have an unknown
            purpose) are annotated with (unk)
          * the keys and certificates that are not associated with one of the
            configured identities (i.e. keys with an unrecognized client/service
            nickname) are also annotated with (unk)

OPTIONS
       --keystore default
            Perform checks on the default keystore. This is the default
            behavior if the --keystore flag is omitted
       --keystore [<kid>...]
            Specifies the IDs of the keystores to check. The IDs must
            be associated with keystores from the Arti TOML config. It is an
            error to specify a key store ID not associated with any of the
            configured key stores.
       --fix
            Attempt to fix the problems detected. Any expired or unrecognized
            keys and certificates are removed. Prompts before every removal
        --output [pretty|json]
            The output format. Defaults to 'pretty', a pretty-printed,
            human-friendly format
       --verbose
            Print more information about each reported problem. This flag is
            disregarded if --output=json, because the JSON output always
            contains the full error report

EXAMPLES
       Perform validity checks on keystores foo and bar:

         arti keys verify --config arti.toml \
           --keystore foo,bar                \
           --output pretty

       Sample output:

         verifying 2 keystores
         bar ... OK
         foo ... FAILED

         failures:

         ====== foo ======
         client/alice/xyz.onion/KS_hsc_desc_not_a_valid_name.x25519_private (unk)
         hs/carol/KS_hs_blind_id+19666_1440_43200.ed25519_expanded_private (exp)
         hs/carol/KS_hs_desc_sign+19666_1440_43200.ed25519_expanded_private (exp)

       Perform validity checks on keystores foo and bar, removing any invalid keys:

        arti kets verify --config arti.toml \
          --keystore foo,bar                \
          --fix

       Sample output:

         verifying 2 keystores
         bar ... OK
         foo ... FAILED

         failures:

         ====== foo ======
         client/alice/xyz.onion/KS_hsc_desc_not_a_valid_name.x25519_private (unk) Remove? [y/N]: y
         hs/carol/KS_hs_blind_id+19666_1440_43200.ed25519_expanded_private (exp) Remove? [y/N]: y
         hs/carol/KS_hs_desc_sign+19666_1440_43200.ed25519_expanded_private (exp) Remove? [y/N]: N
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::list_matching`
  * `KeyMgr::describe`
  * `KeyMgr::remove`

This command is exactly like `arti-keys-list`, except it also removes the
invalid keys if prompted to do so.

### `arti-keys-describe`

```
NAME
       arti-keys-describe - print information about a specific key

SYNOPSIS
       arti keys describe [OPTIONS] <ARTI_PATH>

DESCRIPTION
       Given the ArtiPath of a key, print a description of what the key is used
       for.
OPTIONS
       --output [pretty|json]
           The output format. Defaults to 'pretty', a pretty-printed,
           human-friendly format
       --verbose
           Print more information about the key. This includes a description of
           the key, the ID of the key store it is located in, and whether the
           key is unrecognized or expired. This flag is disregarded if
           --output=json, because the JSON output always contains the full
           description of the key

       TODO: maybe this needs an option for describing keys that match a given
       ArtiPath pattern?

EXAMPLES
       Describe the ArtiPath of a hidden service identity key:

         arti keys describe hs/carol/KS_hs_id.expanded_ed25519_private

       Sample output:

         ===== hs/carol/KS_hs_id.expanded_ed25519_private =====
           purpose: The long-term identity keypair of the service.
           type: ed25519 keypair
           service: carol
           expired: no

       Describe a malformed client ArtiPath:

         arti keys describe \
             client/alice/xyz.onion/KS_hsc_desc_not_a_valid_name.x25519_private

       Sample output:
         ===== client/alice/xyz.onion/KS_hsc_desc_not_a_valid_name.x25519_private =====
           purpose: unknown
           type: x25519 keypair
           expired: unknown

       Describe a malformed ArtiPath:

         arti keys describe abc.xyz

       Sample output:
         ===== abc.xyz =====
           purpose: unknown
           type: unknown
           expired: unknown
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::describe`

This will be implemented by an API based on `KeyMgr::describe`. As mentioned
under `arti-keys-list`, the API will also need to be able to detect if the
specified key is expired or not (this is not something `KeyMgr` can do. See
`KeystoreSweeper` for an example of how key expiration is detected and handled
today. The key expiration logic will need to be factored out of
`KeystoreSweeper`, because we'll need it for the CLI APIs too).

## `arti-keys-raw`

```
NAME
       arti-keys-raw - Command-line key management plumbing tools for Arti

DESCRIPTION
       A CLI for accessing and manipulating the contents of Arti key stores.

       As with arti, keystores are configured through Arti's TOML config
       (specified using the --config flag).

       The key management functionality is exposed as a collection of "plumbing"
       subcommands, each subcommand supporting a different set of options.

       The arti-keys-raw commands operate at a lower level than the arti-keys(1)
       commands. They operate on individual keys, specified as `ArtiPath`s. As
       such, their misuse can lead to key store corruption.

       You most likely do **not** need to use these: all common/routine use
       cases *should* be covered by the higher level arti-keys(1) subcommands.
       If you find yourself needing these commands for routine key management
       tasks, it means we are missing a porcelain wrapper for your workflow.

       TODO: explain what an ArtiPath is (ArtiPaths are mentioned throughout
       the manual)

OPTIONS
       -c, --config <FILE>
               Specify which config file(s) to read. Defaults to
               [File("$HOME/.config/arti/arti.toml"),
               Dir("$HOME/.config/arti/arti.d/")]

           --disable-fs-permission-checks
               Don't check permissions on the files we use.

       --keystore-dir <ARTI_KEYSTORE>
          Use the keystore from the specified directory, which should be an Arti
          format keystore. This is a convenience alias for
          -o storage.keystore.path=<ARTI_KEYSTORE>

       -h, --help
               Print help information

       -l, --log-level <LEVEL>
               Override the log level (usually one of 'trace', 'debug', 'info', 'warn', 'error').

       -o <KEY=VALUE>
               Override config file parameters, using TOML-like syntax.

       -V, --version
            Print version information

SUBCOMMANDS
       list            Plumbing subcommand for listing the files from key stores
       remove-by-path  Plumbing subcommand for removing files from key stores

```

### `arti-keys-raw-list` (plumbing)


```
NAME
       arti-keys-raw-list - List all available keys, without interpreting their
       meaning

SYNOPSIS
       arti keys-raw list [OPTIONS]

DESCRIPTION
       List the keys and certificates from the specified key stores. If no key
       stores are specified, this command lists the keys and certificates from
       all stores.

OPTIONS
       --keystore all
            List the keys and certificates from all key stores. This is the
            default behavior if the --keystore flag is omitted
       --keystore default
            List the keys and certificates from the default keystore.
       --keystore [<kid>...]
            Specifies the IDs of the keystores to list keys and certificates
            from. The IDs must be associated with keystores from the Arti TOML
            config. It is an error to specify a key store ID not associated with
            any of the configured key stores.

EXAMPLES
       List the keys in keystores foo and bar:

         arti keys-raw list --config arti.toml \
           --keystore foo,bar

       Sample output:
         ===== foo =====
           abc/not-a-key.txt
           client/alice/abc.onion/ks_hsc_desc_enc.x25519_private
           client/alice/xyz.onion/KS_hsc_desc_enc.x25519_private
           client/alice/xyz.onion/KS_hsc_desc_not_a_valid_name.x25519_private
           hs/carol/KS_hs_id.expanded_ed25519_private
           hs/carol/KS_hs_blind_id+19666_1440_43200.ed25519_expanded_private
           hs/carol/KS_hs_blind_id+19667_1440_43200.ed25519_expanded_private
           hs/carol/KS_hs_desc_sign+19666_1440_43200.ed25519_expanded_private
           hs/carol/KS_hs_desc_sign+19667_1440_43200.ed25519_expanded_private
           hs/dan/KS_hs_id.expanded_ed25519_private
           hs/eve/KS_hs_blind_id+19666_1440_43200.ed25519_expanded_private
           hs/eve/KS_hs_desc_sign+19667_1440_43200.ed25519_expanded_private
         ===== bar =====
           client/bob/def.onion/KS_hsc_desc_enc.x25519_private
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::list_matching`

### `arti-keys-raw-remove-by-path` (plumbing)

```
NAME
       arti-keys-raw-remove-by-path - Remove a key, given its ArtiPath

SYNOPSIS
       arti keys-raw remove-by-path [OPTIONS] <RAW_PATH>

DESCRIPTION
      Remove the specified file from the key store.

      The specified RAW_PATH is in the format of an ArtiPath, and so it is
      relative to the key store root.

      TODO: warn about misuse

OPTIONS
       --keystore default
            Remove the key from the default keystore. This is the default
            behavior if the --keystore flag is omitted
       --keystore <kid>
            Specifies the ID of the keystore to remove the key from. The ID must
            match one of the key store IDs configured in the specified config. It
            is an error to specify an unrecognized key store ID.
      --remove-all
            Remove **all** the keys and certificates of this key from all
            keystores. This is a dangerous option and should be used with care.
            Prompts before removal. Cannot be used with --keystore

EXAMPLES

       Remove a file from keystore foo:

         arti keys-raw --config arti.toml remove-by-path            \
             --keystore foo                                         \
             client/alice/abc.onion/ks_hsc_desc_enc.x25519_private


       Remove a file that is probably not a key from keystore foo:

         arti keys-raw --config arti.toml remove-by-path            \
             --keystore foo                                         \
             foo/some-file.txt
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::remove`

## `arti-hsc`

```
NAME
       arti-hsc - Command-line tool for managing the state of Arti hidden
       service clients

SYNOPSIS
       arti hsc [OPTIONS] <SUBCOMMAND> [SUBCOMMAND-OPTIONS]

DESCRIPTION
       A CLI for accessing, manipulating and validating the contents of Arti key
       stores and other peristent state.

       As with arti, keystores are configured through Arti's TOML config
       (specified using the --config flag).

       The state management functionality is exposed as a collection of
       subcommands, each subcommand supporting a different set of options.

       TODO: explain what an ArtiPath is (ArtiPaths are mentioned throughout
       the manual)

OPTIONS
       -c, --config <FILE>
               Specify which config file(s) to read. Defaults to
               [File("$HOME/.config/arti/arti.toml"),
               Dir("$HOME/.config/arti/arti.d/")]

           --disable-fs-permission-checks
               Don't check permissions on the files we use.

       --keystore-dir <ARTI_KEYSTORE>
          Use the keystore from the specified directory, which should be an Arti
          format keystore. This is a convenience alias for
          -o storage.keystore.path=<ARTI_KEYSTORE>

       -h, --help
               Print help information

       -l, --log-level <LEVEL>
               Override the log level (usually one of 'trace', 'debug', 'info', 'warn', 'error').

       -o <KEY=VALUE>
               Override config file parameters, using TOML-like syntax.

       -V, --version
            Print version information

SUBCOMMANDS
       help           Print this message or the help of the given subcommand(s)
       generate-key   Generate a key in one of the configured key stores
       remove-key     Remove a key from one of the configured key stores
```

### `arti-hsc-generate-key`

```
NAME
       arti-hsc-generate-key-auth - Generate a hidden service client authorization key

SYNOPSIS
       arti hsc generate-key auth [OPTIONS]

DESCRIPTION
       NOTE: while generate-key currently has only one subcommand ("auth"), in
       the future we might need to extend it with additional subcommands (if we
       extend the protocol to support other forms of client auth, for example)

       Generate a hidden service client authorization key, placing the keypair
       in the specified key store.

       This generates an x25519 descriptor encryption keypair and prints the
       corresponding public key to stdout in the format specified via the
       --pub-format option.

       This command should be run by clients who want to connect to a hidden
       service that requires client authorization.

       To connect to a hidden service that has client authorization enabled,
       clients need to share the public part of the key with the hidden service
       through a secure channel. The hidden service can then authorize the
       client to connect by encrypting its descriptor with the client's public
       key. The client uses the generated x25519 keypair to compute the keys for
       decrypting the superencrypted layer of the descriptor.

OPTIONS
       --keystore default
            Generate the key in the default keystore. This is the default
            behavior if the --keystore flag is omitted
       --keystore <kid>
            Specifies the ID of the keystore to generate the key into. The ID
            must match one of the key store IDs configured in the specified
            config. It is an error to specify an unrecognized key store ID.
       --nickname
            The nickname of the client for which to generate the key
       --hsid
            The hidden service for which to generate the key
       --pub-format [arti|ctor]
            The format to print the public part of the key in
            TODO: decide what the arti format looks like
       --force
            Whether to overwrite the key if it already exists

EXAMPLES
       Generate a client authorization key for service xyz.onion in keystore foo:

         arti hsc --config arti.toml generate-key auth --keystore foo  \
             --nickname alice                                          \
             --hsid xyz.onion                                          \
             --pub-format ctor

      Stdout:

         descriptor:x25519:dz4q5xqlb4ldnbs72iarrml4ephk3du4i7o2cgiva5lwr6wkquja

      TODO: update this section and document the arti --pub-format after we
      reach a conclusion in #1028
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::generate`

### `arti-hsc-remove-key`

```
NAME
       arti-hsc-remove-key - remove a client authorization key from the specified
       key store

SYNOPSIS
       arti hsc remove-key auth [OPTIONS]

DESCRIPTION
       NOTE: like generate-key, remove-key currently has only one subcommand
       ("auth").

       Remove a hidden service client authorization key from the specified key
       store.

       After removing the key, the client will no longer be able to connect to
       the service specified via --hsid, if the service has enabled client
       authorization.

OPTIONS
       --nickname
            The nickname of the client for which to remove the key
       --hsid
            The hidden service the key is associated with

EXAMPLES
       Remove the client authorization key for service xyz.onion from keystore foo:

         arti hsc --config arti.toml remove-key auth --keystore foo    \
             --type desc-enc                                           \
             --nickname alice                                          \
             --hsid xyz.onion
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::remove`

## `arti-hss`

```
NAME
       arti-hss - Command-line tool for managing the state of Arti hidden
       services

SYNOPSIS
       arti hss [OPTIONS] <SUBCOMMAND> [SUBCOMMAND-OPTIONS]

DESCRIPTION
      A state management tool for Arti hidden services.

      The managed state includes:
         * the IPT state of the service stored on disk
         * the keys associated with the service

OPTIONS
       -c, --config <FILE>
               Specify which config file(s) to read. Defaults to
               [File("$HOME/.config/arti/arti.toml"),
               Dir("$HOME/.config/arti/arti.d/")]

           --disable-fs-permission-checks
               Don't check permissions on the files we use.

       --keystore-dir <ARTI_KEYSTORE>
          Use the keystore from the specified directory, which should be an Arti
          format keystore. This is a convenience alias for
          -o storage.keystore.path=<ARTI_KEYSTORE>

       -h, --help
               Print help information

       -l, --log-level <LEVEL>
               Override the log level (usually one of 'trace', 'debug', 'info', 'warn', 'error').

       -o <KEY=VALUE>
               Override config file parameters, using TOML-like syntax.

       -V, --version
            Print version information

SUBCOMMANDS
       help                  Print this message or the help of the given subcommand(s)
       new-service           Initialize a new hidden service
       generate-online-keys  Generate all the keys necessary to run a hidden service
       destroy               Remove all the keys and state of a hidden service
       print-onion           Print the .onion address of a service
       auth-clients          Manage the authorized clients of this hidden service
       destroy-and-recreate  Generate a new identity keypair for a hidden service
```

### `arti-hss-new-service`

```
NAME
       arti-hss-new-service - initialize a new hidden service

SYNOPSIS
       arti hss new-service [OPTIONS]

DESCRIPTION
      Initializes a new hidden service by generating a new identity keypair and
      placing it in the specified key store.

      Users wanting to create a new service that will run in offline mode should
      run this command on a secure offline host to create its identity keys, and
      then run arti-hss-generate-online-keys(1) to generate the keys needed to
      run the service.

      Before running this command, ensure the hidden service you are
      initializing is configured in the Arti config (specified via --config).

      If Arti is already running using a config that contains an entry for the
      hidden service, its identity key has likely already been automatically
      generated by Arti. If that is the case, this command will report that an
      identity key already exists for the service, and exit with an error.

      TODO: make Arti support watching for keystore changes. Decide what happens
      if a new service is configured while Arti is running

OPTIONS
       --keystore default
            Place the identity key in the default keystore. This is the default
            behavior if the --keystore flag is omitted
       --keystore <kid>
            Specifies the ID of the keystore to generate the identity key into.
            The ID must match one of the key store IDs configured in the
            specified config. It is an error to specify an unrecognized key
            store ID.
       --nickname
            The nickname of the service

EXAMPLES
       Initialize a new hidden service with nickname "shallot" in the default
       key store:

         arti hss --config arti.toml new-service \
             --nickname shallot

       Sample output:

         Generated a new hidden service using nickname "shallot":
           wrxdvcaqpuzakbfww5sxs6r2uybczwijzfn2ezy2osaj7iox7kl7nhad.onion

       If any of the configured keystores contain any entries for service
       "shallot", a new identity key pair will **not** be generated:

         Cannot generate a new service with nickname "shallot": keystores foo and
         bar contain keys associated with a pre-existing hidden service with the
         same nickname

            Hint: use a different nickname.

            Alternatively, if you want to erase the service with nickname
            "shallot", run:

               arti hss --config arti.toml destroy \
                   --nickname shallot

            before retrying the operation

       If the public part of the identity key is available, this command also
       prints the corresponding .onion address before exiting:

         Cannot generate new hidden service with nickname "shallot": an identity key
         already exists
           wrxdvcaqpuzakbfww5sxs6r2uybczwijzfn2ezy2osaj7iox7kl7nhad.onion

```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::generate`

### `arti-hss-generate-online-keys`

```
NAME
       arti-hss-generate-online-keys - generate the keys needed to run a hidden service in offline mode

SYNOPSIS
       arti hss generate-online-keys [OPTIONS]

DESCRIPTION
      Generates all the keys required for a hidden service to operate without
      needing access to its identity key, up to a given time period.

      You do **not** need to run this command unless you want to run a hidden
      service in offline mode (where the identity key of the service is kept
      offline). If the identity keys are "online" (i.e. available on the host
      running the hidden service), you do not need to run this command, as Arti
      will automatically generate all the necessary keys and certificates.

      This command should be run on a secure offline system where the secret
      identity key of the service is available. It generates keys inside an
      "online" keystore, specified via --online-keystore-dir. Because the
      "online" keystore is a directory on disk, it can be copied from the
      offline system to the (online) hidden service host using the file-copying
      utilities available on your system. On the online system, the
      storage.keystore.path from the TOML config of the hidden service should
      point to the path the "online" keystore was copied to.

      The service will be able to operate without its secret identity key until
      the time specified via --up-to. After that, additional keys will
      need to be generated.

      This command assumes the hidden service has already been initialized,
      either manually, using arti-hss-new-service(1), or implicitly,
      by starting arti as a hidden service,
      and that the identity keypair is available in one
      of the configured key stores.

      Generates the following keys and certificates for each time period
      starting from the current time period up until the time specified
      via --up-to:

        * blinded identity keypair
        * descriptor signing key
        * descriptor signing certificate (obtained by signing the descriptor
          signing key with the blinded identity key)

OPTIONS
       --online-keystore-dir
            The root of the online keystore, where the keys will be generated.
            The keystore directory will be created if it does not already exist.
       --nickname
            The nickname of the service for which to generate the keys
       --up-to {<TIMESTAMP>|<DURATION>}
            A timestamp or duration representing the validity interval of
            the generated keys. The service will be able to run using the
            generated keys until the specified <TIMESTAMP>, or for the specified
            <DURATION>. after which new keys will need to be generated.
            Timestamps represent an absolute date/time given in RFC3339 format.
            Durations are relative to the current time (i.e. the time when this
            command was run), and represent a number of hours, minutes, or days
            (for example "--up-to 48h", --up-to 48 hours", "--up-to 10 days").

EXAMPLES
       Initialize a new "online" keystore at $HOME/foo with the keys needed in
       order for hidden service "shallot" to run in offline mode until
       2023-02-09T12:00:00Z (the identity key of the service must be in one of
       the keystores configured in arti.toml):

         arti hss --config arti.toml generate-online-keys \
             --online-keystore-dir $HOME/foo              \
             --nickname shallot                           \
             --up-to 2023-02-09T12:00:00Z

       Keystore foo can be exported to the online system by copying the
       $HOME/foo directory. On the online system, in the TOML config of the
       hidden service, storage.keystore.path should point to the parent directory
       of foo (TODO: make the keystore ID part of the config).
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::generate`

### `arti-hss-destroy`

```
NAME
       arti-hss-destroy - remove the persistent state and all the keys of a hidden service

SYNOPSIS
       arti hss destroy [OPTIONS]

DESCRIPTION
       Remove the persistent state and all the keys of a hidden service.

       This removes
         * the IPT state of the service stored on disk
         * any the keys associated with the service, from all key stores

OPTIONS
       --nickname
            The nickname of the service to erase

EXAMPLES
       Erase all the keys and state hidden service with nickname "shallot":

         arti hss --config arti.toml destroy \
             --nickname shallot
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::remove`

### `arti-hss-print-onion`

```
NAME
       arti-hss-print-onion - print the .onion address of a service

SYNOPSIS
       arti hss print-onion [OPTIONS]

DESCRIPTION
      Print the .onion address of a service.

OPTIONS
       --nickname
            The nickname of the service to display

EXAMPLES
      Print the .onion address of the service with nickname allium from the
      default keystore:

        arti hss --nickname allium print-onion-name

     Sample output:
        wrxdvcaqpuzakbfww5sxs6r2uybczwijzfn2ezy2osaj7iox7kl7nhad.onion
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::get`

### `arti-hss-auth-clients`

```
NAME
       arti-hss-auth-clients - Manage the authorized clients of this hidden service

SYNOPSIS
       arti hss auth-clients [SUBCOMMAND]

DESCRIPTION
      A command for managing the authorized clients of an Arti hidden service.

      TODO: document how these commands are supposed to work after we reach a
      conclusion in #1028

SUBCOMMANDS
       help                  Print this message or the help of the given subcommand(s)
       import                Import the public keys of a client
       disable               Un-authorize a previously authorized client
       enable                Authorize a new client
```

### `arti-hss-destroy-and-recreate`

```
NAME
       arti-hss-destroy-and-recreate - Generate a new identity keypair for a hidden service

SYNOPSIS
       arti hss destroy-and-recreate [OPTIONS]

DESCRIPTION
       A command for generating a new set of keys for an existing hidden
       service.

       This command deletes all the keys, including identity key, of the
       specified sevice and generates a fresh identity keypair.

       This command preserves the nickname of the service and its configuration
       (including the authorized clients).

       TODO: Expand on the description, add an example

OPTIONS
       --nickname
            The nickname of the service to destroy and recreate
```

#### Implementation

Required `KeyMgr` APIs:

  * `KeyMgr::remove`
  * `KeyMgr::generate`



[`KeyMgr`]: https://docs.rs/tor-keymgr/0.4.0/tor_keymgr/struct.KeyMgr.html
[ROFF]: https://crates.io/crates/clap_mangen
[arti#955]: https://gitlab.torproject.org/tpo/core/arti/-/issues/955