summaryrefslogtreecommitdiff
path: root/doc/rfc/rfc9642.txt
blob: ce11df8e4b25c872513ce344b86e3e3a32cf0b52 (plain) (blame)
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
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
Internet Engineering Task Force (IETF)                         K. Watsen
Request for Comments: 9642                               Watsen Networks
Category: Standards Track                                   October 2024
ISSN: 2070-1721


                    A YANG Data Model for a Keystore

Abstract

   This document presents a YANG module called "ietf-keystore" that
   enables centralized configuration of both symmetric and asymmetric
   keys.  The secret value for both key types may be encrypted or
   hidden.  Asymmetric keys may be associated with certificates.
   Notifications are sent when certificates are about to expire.

Status of This Memo

   This is an Internet Standards Track document.

   This document is a product of the Internet Engineering Task Force
   (IETF).  It represents the consensus of the IETF community.  It has
   received public review and has been approved for publication by the
   Internet Engineering Steering Group (IESG).  Further information on
   Internet Standards is available in Section 2 of RFC 7841.

   Information about the current status of this document, any errata,
   and how to provide feedback on it may be obtained at
   https://www.rfc-editor.org/info/rfc9642.

Copyright Notice

   Copyright (c) 2024 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents
   (https://trustee.ietf.org/license-info) in effect on the date of
   publication of this document.  Please review these documents
   carefully, as they describe your rights and restrictions with respect
   to this document.  Code Components extracted from this document must
   include Revised BSD License text as described in Section 4.e of the
   Trust Legal Provisions and are provided without warranty as described
   in the Revised BSD License.

Table of Contents

   1.  Introduction
     1.1.  Relation to Other RFCs
     1.2.  Specification Language
     1.3.  Terminology
     1.4.  Adherence to the NMDA
     1.5.  Conventions
   2.  The "ietf-keystore" Module
     2.1.  Data Model Overview
     2.2.  Example Usage
     2.3.  YANG Module
   3.  Support for Built-In Keys
   4.  Encrypting Keys in Configuration
   5.  Security Considerations
     5.1.  Security of Data at Rest and in Motion
     5.2.  Unconstrained Private Key Usage
     5.3.  Security Considerations for the "ietf-keystore" YANG Module
   6.  IANA Considerations
     6.1.  The IETF XML Registry
     6.2.  The YANG Module Names Registry
   7.  References
     7.1.  Normative References
     7.2.  Informative References
   Acknowledgements
   Author's Address

1.  Introduction

   This document presents a YANG 1.1 [RFC7950] module called "ietf-
   keystore" that enables centralized configuration of both symmetric
   and asymmetric keys.  The secret value for both key types may be
   encrypted or hidden (see [RFC9640]).  Asymmetric keys may be
   associated with certificates.  Notifications are sent when
   certificates are about to expire.

   The "ietf-keystore" module defines many "grouping" statements
   intended for use by other modules that may import it.  For instance,
   there are groupings that define enabling a key to be configured
   either inline (within the defining data model) or as a reference to a
   key in the central keystore.

   Special consideration has been given for servers that have
   cryptographic hardware, such as a trusted platform module (TPM).
   These servers are unique in that the cryptographic hardware hides the
   secret key values.  Additionally, such hardware is commonly
   initialized when manufactured to protect a "built-in" asymmetric key
   for which its public half is conveyed in an identity certificate
   (e.g., an Initial Device Identifier (IDevID) [Std-802.1AR-2018]
   certificate).  See how built-in keys are supported in Section 3.

   This document is intended to reflect existing practices that many
   server implementations support at the time of writing.  To simplify
   implementation, advanced key formats may be selectively implemented.

   Implementations may utilize operating-system level keystore utilities
   (e.g., "Keychain Access" on MacOS) and/or cryptographic hardware
   (e.g., TPMs).

1.1.  Relation to Other RFCs

   This document presents a YANG module [RFC7950] that is part of a
   collection of RFCs that work together to ultimately support the
   configuration of both the clients and servers of the Network
   Configuration Protocol (NETCONF) [RFC6241] and RESTCONF [RFC8040].

   The dependency relationship between the primary YANG groupings
   defined in the various RFCs is presented in the diagram below.  In
   some cases, a document may define secondary groupings that introduce
   dependencies not illustrated in the diagram.  The labels in the
   diagram are shorthand names for the defining RFCs.  The citation
   references for the shorthand names are provided below the diagram.

   Please note that the arrows in the diagram point from referencer to
   referenced.  For example, the "crypto-types" RFC does not have any
   dependencies, whilst the "keystore" RFC depends on the "crypto-types"
   RFC.

                                  crypto-types
                                    ^      ^
                                   /        \
                                  /          \
                         truststore         keystore
                          ^     ^             ^  ^
                          |     +---------+   |  |
                          |               |   |  |
                          |      +------------+  |
   tcp-client-server      |     /         |      |
      ^    ^        ssh-client-server     |      |
      |    |           ^            tls-client-server
      |    |           |              ^     ^        http-client-server
      |    |           |              |     |                 ^
      |    |           |        +-----+     +---------+       |
      |    |           |        |                     |       |
      |    +-----------|--------|--------------+      |       |
      |                |        |              |      |       |
      +-----------+    |        |              |      |       |
                  |    |        |              |      |       |
                  |    |        |              |      |       |
               netconf-client-server       restconf-client-server

   +========================+==========================+
   | Label in Diagram       | Originating RFC          |
   +========================+==========================+
   | crypto-types           | [RFC9640]                |
   +------------------------+--------------------------+
   | truststore             | [RFC9641]                |
   +------------------------+--------------------------+
   | keystore               | RFC 9642                 |
   +------------------------+--------------------------+
   | tcp-client-server      | [RFC9643]                |
   +------------------------+--------------------------+
   | ssh-client-server      | [RFC9644]                |
   +------------------------+--------------------------+
   | tls-client-server      | [RFC9645]                |
   +------------------------+--------------------------+
   | http-client-server     | [HTTP-CLIENT-SERVER]     |
   +------------------------+--------------------------+
   | netconf-client-server  | [NETCONF-CLIENT-SERVER]  |
   +------------------------+--------------------------+
   | restconf-client-server | [RESTCONF-CLIENT-SERVER] |
   +------------------------+--------------------------+

         Table 1: Labels in Diagram to RFC Mapping

1.2.  Specification Language

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
   "OPTIONAL" in this document are to be interpreted as described in
   BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all
   capitals, as shown here.

1.3.  Terminology

   The terms "client" and "server" are defined in [RFC6241] and are not
   redefined here.

   The term "keystore" is defined in this document as a mechanism that
   intends to safeguard secrets.

   The nomenclatures "<running>" and "<operational>" are defined in
   [RFC8342].

   The sentence fragments "augmented" and "augmented in" are used herein
   as the past tense verbified form of the "augment" statement defined
   in Section 7.17 of [RFC7950].

   The term "key" may be used to mean one of three things in this
   document: 1) the YANG-defined "asymmetric-key" or "symmetric-key"
   node defined in this document, 2) the raw key data possessed by the
   aforementioned key nodes, or 3) the "key" of a YANG "list" statement.
   This document qualifies types '2' and '3' using "raw key value" and
   "YANG list key" where needed.  In all other cases, an unqualified
   "key" refers to a YANG-defined "asymmetric-key" or "symmetric-key"
   node.

1.4.  Adherence to the NMDA

   This document is compliant with Network Management Datastore
   Architecture (NMDA) [RFC8342].  For instance, keys and associated
   certificates installed during manufacturing (e.g., for an IDevID
   certificate) are expected to appear in <operational> (see Section 3).

1.5.  Conventions

   Various examples in this document use "BASE64VALUE=" as a placeholder
   value for binary data that has been base64 encoded (per Section 9.8
   of [RFC7950]).  This placeholder value is used because real
   base64-encoded structures are often many lines long and hence
   distracting to the example being presented.

   Various examples in this document use the XML [W3C.REC-xml-20081126]
   encoding.  Other encodings, such as JSON [RFC8259], could
   alternatively be used.

   Various examples in this document contain long lines that may be
   folded, as described in [RFC8792].

   This document uses the adjective "central" to the word "keystore" to
   refer to the top-level instance of the "keystore-grouping", when the
   "central-keystore-supported" feature is enabled.  Please be aware
   that consuming YANG modules MAY instantiate the "keystore-grouping"
   in other locations.  All such other instances are not the "central"
   instance.

2.  The "ietf-keystore" Module

   This section defines a YANG 1.1 [RFC7950] module called "ietf-
   keystore".  A high-level overview of the module is provided in
   Section 2.1.  Examples illustrating the module's use are provided in
   Section 2.2.  The YANG module itself is defined in Section 2.3.

2.1.  Data Model Overview

   This section provides an overview of the "ietf-keystore" module in
   terms of its features, typedefs, groupings, and protocol-accessible
   nodes.

2.1.1.  Features

   The following diagram lists all the "feature" statements defined in
   the "ietf-keystore" module:

   Features:
     +-- central-keystore-supported
     +-- inline-definitions-supported
     +-- asymmetric-keys
     +-- symmetric-keys

   The diagram above uses syntax that is similar to but not defined in
   [RFC8340].

2.1.2.  Typedefs

   The following diagram lists the "typedef" statements defined in the
   "ietf-keystore" module:

   Typedefs:
     leafref
       +-- central-symmetric-key-ref
       +-- central-asymmetric-key-ref

   The diagram above uses syntax that is similar to but not defined in
   [RFC8340].

   Comments:

   *  All the typedefs defined in the "ietf-keystore" module extend the
      base "leafref" type defined in [RFC7950].

   *  The leafrefs refer to symmetric and asymmetric keys in the central
      keystore when this module is implemented.

   *  These typedefs are provided as an aid to consuming modules that
      import the "ietf-keystore" module.

2.1.3.  Groupings

   The "ietf-keystore" module defines the following "grouping"
   statements:

   *  encrypted-by-grouping
   *  central-asymmetric-key-certificate-ref-grouping
   *  inline-or-keystore-symmetric-key-grouping
   *  inline-or-keystore-asymmetric-key-grouping
   *  inline-or-keystore-asymmetric-key-with-certs-grouping
   *  inline-or-keystore-end-entity-cert-with-key-grouping
   *  keystore-grouping

   Each of these groupings are presented in the following subsections.

2.1.3.1.  The "encrypted-by-grouping" Grouping

   The following tree diagram [RFC8340] illustrates the "encrypted-by-
   grouping" grouping:

     grouping encrypted-by-grouping:
       +-- (encrypted-by)
          +--:(central-symmetric-key-ref)
          |        {central-keystore-supported,symmetric-keys}?
          |  +-- symmetric-key-ref?    ks:central-symmetric-key-ref
          +--:(central-asymmetric-key-ref)
                   {central-keystore-supported,asymmetric-keys}?
             +-- asymmetric-key-ref?   ks:central-asymmetric-key-ref

   Comments:

   *  This grouping defines a "choice" statement with options to
      reference either a symmetric or an asymmetric key configured in
      the keystore.

   *  This grouping is usable only when the keystore module is
      implemented.  Servers defining custom keystore locations MUST
      augment in alternate "encrypted-by" references to the alternate
      locations.

2.1.3.2.  The "central-asymmetric-key-certificate-ref-grouping" Grouping

   The following tree diagram [RFC8340] illustrates the "central-
   asymmetric-key-certificate-ref-grouping" grouping:

     grouping central-asymmetric-key-certificate-ref-grouping:
       +-- asymmetric-key?   ks:central-asymmetric-key-ref
       |       {central-keystore-supported,asymmetric-keys}?
       +-- certificate?      leafref

   Comments:

   *  This grouping defines a reference to a certificate in two parts:
      the first being the name of the asymmetric key the certificate is
      associated with, and the second being the name of the certificate
      itself.

   *  This grouping is usable only when the keystore module is
      implemented.  Servers defining custom keystore locations can
      define an alternate grouping for references to the alternate
      locations.

2.1.3.3.  The "inline-or-keystore-symmetric-key-grouping" Grouping

   The following tree diagram [RFC8340] illustrates the "inline-or-
   keystore-symmetric-key-grouping" grouping:

     grouping inline-or-keystore-symmetric-key-grouping:
       +-- (inline-or-keystore)
          +--:(inline) {inline-definitions-supported}?
          |  +-- inline-definition
          |     +---u ct:symmetric-key-grouping
          +--:(central-keystore)
                   {central-keystore-supported,symmetric-keys}?
             +-- central-keystore-reference?
                     ks:central-symmetric-key-ref

   Comments:

   *  The "inline-or-keystore-symmetric-key-grouping" grouping is
      provided solely as convenience to consuming modules that wish to
      offer an option for a symmetric key that is defined either inline
      or as a reference to a symmetric key in the keystore.

   *  A "choice" statement is used to expose the various options.  Each
      option is enabled by a "feature" statement.  Additional "case"
      statements MAY be augmented in if, e.g., there is a need to
      reference a symmetric key in an alternate location.

   *  For the "inline-definition" option, the definition uses the
      "symmetric-key-grouping" grouping discussed in Section 2.1.4.3 of
      [RFC9640].

   *  For the "central-keystore" option, the "central-keystore-
      reference" is an instance of the "symmetric-key-ref" discussed in
      Section 2.1.2.

2.1.3.4.  The "inline-or-keystore-asymmetric-key-grouping" Grouping

   The following tree diagram [RFC8340] illustrates the "inline-or-
   keystore-asymmetric-key-grouping" grouping:

     grouping inline-or-keystore-asymmetric-key-grouping:
       +-- (inline-or-keystore)
          +--:(inline) {inline-definitions-supported}?
          |  +-- inline-definition
          |     +---u ct:asymmetric-key-pair-grouping
          +--:(central-keystore)
                   {central-keystore-supported,asymmetric-keys}?
             +-- central-keystore-reference?
                     ks:central-asymmetric-key-ref

   Comments:

   *  The "inline-or-keystore-asymmetric-key-grouping" grouping is
      provided solely as convenience to consuming modules that wish to
      offer an option for an asymmetric key that is defined either
      inline or as a reference to an asymmetric key in the keystore.

   *  A "choice" statement is used to expose the various options.  Each
      option is enabled by a "feature" statement.  Additional "case"
      statements MAY be augmented in if, e.g., there is a need to
      reference an asymmetric key in an alternate location.

   *  For the "inline-definition" option, the definition uses the
      "asymmetric-key-pair-grouping" grouping discussed in
      Section 2.1.4.6 of [RFC9640].

   *  For the "central-keystore" option, the "central-keystore-
      reference" is an instance of the "asymmetric-key-ref" typedef
      discussed in Section 2.1.2.

2.1.3.5.  The "inline-or-keystore-asymmetric-key-with-certs-grouping"
          Grouping

   The following tree diagram [RFC8340] illustrates the "inline-or-
   keystore-asymmetric-key-with-certs-grouping" grouping:

     grouping inline-or-keystore-asymmetric-key-with-certs-grouping:
       +-- (inline-or-keystore)
          +--:(inline) {inline-definitions-supported}?
          |  +-- inline-definition
          |     +---u ct:asymmetric-key-pair-with-certs-grouping
          +--:(central-keystore)
                   {central-keystore-supported,asymmetric-keys}?
             +-- central-keystore-reference?
                     ks:central-asymmetric-key-ref

   Comments:

   *  The "inline-or-keystore-asymmetric-key-with-certs-grouping"
      grouping is provided solely as convenience to consuming modules
      that wish to offer an option for an asymmetric key that is defined
      either inline or as a reference to an asymmetric key in the
      keystore.

   *  A "choice" statement is used to expose the various options.  Each
      option is enabled by a "feature" statement.  Additional "case"
      statements MAY be augmented in if, e.g., there is a need to
      reference an asymmetric key in an alternate location.

   *  For the "inline-definition" option, the definition uses the
      "asymmetric-key-pair-with-certs-grouping" grouping discussed in
      Section 2.1.4.12 of [RFC9640].

   *  For the "central-keystore" option, the "central-keystore-
      reference" is an instance of the "asymmetric-key-ref" typedef
      discussed in Section 2.1.2.

2.1.3.6.  The "inline-or-keystore-end-entity-cert-with-key-grouping"
          Grouping

   The following tree diagram [RFC8340] illustrates the "inline-or-
   keystore-end-entity-cert-with-key-grouping" grouping:

     grouping inline-or-keystore-end-entity-cert-with-key-grouping:
       +-- (inline-or-keystore)
          +--:(inline) {inline-definitions-supported}?
          |  +-- inline-definition
          |     +---u ct:asymmetric-key-pair-with-cert-grouping
          +--:(central-keystore)
                   {central-keystore-supported,asymmetric-keys}?
             +-- central-keystore-reference
                +---u central-asymmetric-key-certificate-ref-grouping

   Comments:

   *  The "inline-or-keystore-end-entity-cert-with-key-grouping"
      grouping is provided solely as convenience to consuming modules
      that wish to offer an option for a symmetric key that is defined
      either inline or as a reference to a symmetric key in the
      keystore.

   *  A "choice" statement is used to expose the various options.  Each
      option is enabled by a "feature" statement.  Additional "case"
      statements MAY be augmented in if, e.g., there is a need to
      reference a symmetric key in an alternate location.

   *  For the "inline-definition" option, the definition uses the
      "asymmetric-key-pair-with-certs-grouping" grouping discussed in
      Section 2.1.4.12 of [RFC9640].

   *  For the "central-keystore" option, the "central-keystore-
      reference" uses the "central-asymmetric-key-certificate-ref-
      grouping" grouping discussed in Section 2.1.3.2.

2.1.3.7.  The "keystore-grouping" Grouping

   The following tree diagram [RFC8340] illustrates the "keystore-
   grouping" grouping:

     grouping keystore-grouping:
       +-- asymmetric-keys {asymmetric-keys}?
       |  +-- asymmetric-key* [name]
       |     +-- name                                          string
       |     +---u ct:asymmetric-key-pair-with-certs-grouping
       +-- symmetric-keys {symmetric-keys}?
          +-- symmetric-key* [name]
             +-- name                         string
             +---u ct:symmetric-key-grouping

   Comments:

   *  The "keystore-grouping" grouping defines a keystore instance as
      being composed of symmetric and asymmetric keys.  The structure
      for the symmetric and asymmetric keys is essentially the same: a
      "list" inside a "container".

   *  For asymmetric keys, each "asymmetric-key" uses the "asymmetric-
      key-pair-with-certs-grouping" grouping discussed in
      Section 2.1.4.12 of [RFC9640].

   *  For symmetric keys, each "symmetric-key" uses the "symmetric-key-
      grouping" grouping discussed in Section 2.1.4.3 of [RFC9640].

2.1.4.  Protocol-Accessible Nodes

   The following tree diagram [RFC8340] lists all the protocol-
   accessible nodes defined in the "ietf-keystore" module without
   expanding the "grouping" statements:

   module: ietf-keystore
     +--rw keystore {central-keystore-supported}?
        +---u keystore-grouping

   The following tree diagram [RFC8340] lists all the protocol-
   accessible nodes defined in the "ietf-keystore" module, with all
   "grouping" statements expanded, enabling the keystore's full
   structure to be seen.

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   module: ietf-keystore
     +--rw keystore {central-keystore-supported}?
        +--rw asymmetric-keys {asymmetric-keys}?
        |  +--rw asymmetric-key* [name]
        |     +--rw name                           string
        |     +--rw public-key-format?             identityref
        |     +--rw public-key?                    binary
        |     +--rw private-key-format?            identityref
        |     +--rw (private-key-type)
        |     |  +--:(cleartext-private-key) {cleartext-private-keys}?
        |     |  |  +--rw cleartext-private-key?   binary
        |     |  +--:(hidden-private-key) {hidden-private-keys}?
        |     |  |  +--rw hidden-private-key?      empty
        |     |  +--:(encrypted-private-key) {encrypted-private-keys}?
        |     |     +--rw encrypted-private-key
        |     |        +--rw encrypted-by
        |     |        |  +--rw (encrypted-by)
        |     |        |     +--:(central-symmetric-key-ref)
        |     |        |     |        {central-keystore-supported,symme\
   tric-keys}?
        |     |        |     |  +--rw symmetric-key-ref?
        |     |        |     |          ks:central-symmetric-key-ref
        |     |        |     +--:(central-asymmetric-key-ref)
        |     |        |              {central-keystore-supported,asymm\
   etric-keys}?
        |     |        |        +--rw asymmetric-key-ref?
        |     |        |                ks:central-asymmetric-key-ref
        |     |        +--rw encrypted-value-format    identityref
        |     |        +--rw encrypted-value           binary
        |     +--rw certificates
        |     |  +--rw certificate* [name]
        |     |     +--rw name                      string
        |     |     +--rw cert-data                 end-entity-cert-cms
        |     |     +---n certificate-expiration
        |     |             {certificate-expiration-notification}?
        |     |        +-- expiration-date    yang:date-and-time
        |     +---x generate-csr {csr-generation}?
        |        +---w input
        |        |  +---w csr-format    identityref
        |        |  +---w csr-info      csr-info
        |        +--ro output
        |           +--ro (csr-type)
        |              +--:(p10-csr)
        |                 +--ro p10-csr?   p10-csr
        +--rw symmetric-keys {symmetric-keys}?
           +--rw symmetric-key* [name]
              +--rw name                             string
              +--rw key-format?                      identityref
              +--rw (key-type)
                 +--:(cleartext-symmetric-key)
                 |  +--rw cleartext-symmetric-key?   binary
                 |          {cleartext-symmetric-keys}?
                 +--:(hidden-symmetric-key) {hidden-symmetric-keys}?
                 |  +--rw hidden-symmetric-key?      empty
                 +--:(encrypted-symmetric-key)
                          {encrypted-symmetric-keys}?
                    +--rw encrypted-symmetric-key
                       +--rw encrypted-by
                       |  +--rw (encrypted-by)
                       |     +--:(central-symmetric-key-ref)
                       |     |        {central-keystore-supported,symme\
   tric-keys}?
                       |     |  +--rw symmetric-key-ref?
                       |     |          ks:central-symmetric-key-ref
                       |     +--:(central-asymmetric-key-ref)
                       |              {central-keystore-supported,asymm\
   etric-keys}?
                       |        +--rw asymmetric-key-ref?
                       |                ks:central-asymmetric-key-ref
                       +--rw encrypted-value-format    identityref
                       +--rw encrypted-value           binary

   Comments:

   *  Protocol-accessible nodes are those nodes that are accessible when
      the module is "implemented", as described in Section 5.6.5 of
      [RFC7950].

   *  The protocol-accessible nodes for the "ietf-keystore" module are
      instances of the "keystore-grouping" grouping discussed in
      Section 2.1.3.7.

   *  The top-level node "keystore" is additionally constrained by the
      feature "central-keystore-supported".

   *  The "keystore-grouping" grouping is discussed in Section 2.1.3.7.

   *  The reason for why "keystore-grouping" exists separate from the
      protocol-accessible nodes definition is to enable instances of the
      keystore to be instantiated in other locations, as may be needed
      or desired by some modules.

2.2.  Example Usage

   The examples in this section are encoded using XML, such as might be
   the case when using the NETCONF protocol.  Other encodings MAY be
   used, such as JSON when using the RESTCONF protocol.

2.2.1.  A Keystore Instance

   The following example illustrates keys in <running>.  Please see
   Section 3 for an example illustrating built-in values in
   <operational>.

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   <keystore
      xmlns="urn:ietf:params:xml:ns:yang:ietf-keystore"
      xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-crypto-types">

      <symmetric-keys>
         <symmetric-key>
            <name>cleartext-symmetric-key</name>
            <key-format>ct:octet-string-key-format</key-format>
            <cleartext-symmetric-key>BASE64VALUE=</cleartext-symmetric-\
   key>
         </symmetric-key>
         <symmetric-key>
            <name>hidden-symmetric-key</name>
            <hidden-symmetric-key/>
         </symmetric-key>
         <symmetric-key>
            <name>encrypted-symmetric-key</name>
            <key-format>ct:one-symmetric-key-format</key-format>
            <encrypted-symmetric-key>
              <encrypted-by>
                <asymmetric-key-ref>hidden-asymmetric-key</asymmetric-k\
   ey-ref>
              </encrypted-by>
              <encrypted-value-format>ct:cms-enveloped-data-format</enc\
   rypted-value-format>
              <encrypted-value>BASE64VALUE=</encrypted-value>
            </encrypted-symmetric-key>
         </symmetric-key>
      </symmetric-keys>

      <asymmetric-keys>
         <asymmetric-key>
            <name>ssh-rsa-key</name>
            <private-key-format>ct:rsa-private-key-format</private-key-\
   format>
            <cleartext-private-key>BASE64VALUE=</cleartext-private-key>
         </asymmetric-key>
         <asymmetric-key>
            <name>ssh-rsa-key-with-cert</name>
            <private-key-format>ct:rsa-private-key-format</private-key-\
   format>
            <cleartext-private-key>BASE64VALUE=</cleartext-private-key>
            <certificates>
               <certificate>
                  <name>ex-rsa-cert2</name>
                  <cert-data>BASE64VALUE=</cert-data>
               </certificate>
            </certificates>
         </asymmetric-key>
         <asymmetric-key>
            <name>raw-private-key</name>
            <private-key-format>ct:rsa-private-key-format</private-key-\
   format>
            <cleartext-private-key>BASE64VALUE=</cleartext-private-key>
         </asymmetric-key>
         <asymmetric-key>
            <name>rsa-asymmetric-key</name>
            <private-key-format>ct:rsa-private-key-format</private-key-\
   format>
            <cleartext-private-key>BASE64VALUE=</cleartext-private-key>
            <certificates>
               <certificate>
                  <name>ex-rsa-cert</name>
                  <cert-data>BASE64VALUE=</cert-data>
               </certificate>
            </certificates>
         </asymmetric-key>
         <asymmetric-key>
            <name>ec-asymmetric-key</name>
            <private-key-format>ct:ec-private-key-format</private-key-f\
   ormat>
            <cleartext-private-key>BASE64VALUE=</cleartext-private-key>
            <certificates>
               <certificate>
                  <name>ex-ec-cert</name>
                  <cert-data>BASE64VALUE=</cert-data>
               </certificate>
            </certificates>
         </asymmetric-key>
         <asymmetric-key>
            <name>hidden-asymmetric-key</name>
            <public-key-format>ct:subject-public-key-info-format</publi\
   c-key-format>
            <public-key>BASE64VALUE=</public-key>
            <hidden-private-key/>
            <certificates>
               <certificate>
                  <name>builtin-idevid-cert</name>
                  <cert-data>BASE64VALUE=</cert-data>
               </certificate>
               <certificate>
                  <name>my-ldevid-cert</name>
                  <cert-data>BASE64VALUE=</cert-data>
               </certificate>
            </certificates>
         </asymmetric-key>
         <asymmetric-key>
            <name>encrypted-asymmetric-key</name>
            <private-key-format>ct:one-asymmetric-key-format</private-k\
   ey-format>
            <encrypted-private-key>
              <encrypted-by>
                <symmetric-key-ref>encrypted-symmetric-key</symmetric-k\
   ey-ref>
              </encrypted-by>
              <encrypted-value-format>ct:cms-encrypted-data-format</enc\
   rypted-value-format>
              <encrypted-value>BASE64VALUE=</encrypted-value>
            </encrypted-private-key>
         </asymmetric-key>
      </asymmetric-keys>
   </keystore>

2.2.2.  A Certificate Expiration Notification

   The following example illustrates a "certificate-expiration"
   notification for a certificate associated with an asymmetric key
   configured in the keystore.

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   <notification
     xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
     <eventTime>2018-05-25T00:01:00Z</eventTime>
     <keystore xmlns="urn:ietf:params:xml:ns:yang:ietf-keystore">
       <asymmetric-keys>
         <asymmetric-key>
           <name>hidden-asymmetric-key</name>
           <certificates>
             <certificate>
               <name>my-ldevid-cert</name>
               <certificate-expiration>
                 <expiration-date>2018-08-05T14:18:53-05:00</expiration\
   -date>
               </certificate-expiration>
             </certificate>
           </certificates>
         </asymmetric-key>
       </asymmetric-keys>
     </keystore>
   </notification>

2.2.3.  The "Inline or Keystore" Groupings

   This section illustrates the various "inline-or-keystore" groupings
   defined in the "ietf-keystore" module, specifically the "inline-or-
   keystore-symmetric-key-grouping" (Section 2.1.3.3), "inline-or-
   keystore-asymmetric-key-grouping" (Section 2.1.3.4), "inline-or-
   keystore-asymmetric-key-with-certs-grouping" (Section 2.1.3.5), and
   "inline-or-keystore-end-entity-cert-with-key-grouping"
   (Section 2.1.3.6) groupings.

   These examples assume the existence of an example module called "ex-
   keystore-usage" that has the namespace "https://example.com/ns/
   example-keystore-usage".

   The ex-keystore-usage module is first presented using tree diagrams
   [RFC8340], followed by an instance example illustrating all the
   "inline-or-keystore" groupings in use, followed by the YANG module
   itself.

2.2.3.1.  Tree Diagrams for the "ex-keystore-usage" Module

   The following tree diagram illustrates "ex-keystore-usage" without
   expanding the "grouping" statements:

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   module: ex-keystore-usage
     +--rw keystore-usage
        +--rw symmetric-key* [name]
        |  +--rw name                                            string
        |  +---u ks:inline-or-keystore-symmetric-key-grouping
        +--rw asymmetric-key* [name]
        |  +--rw name                                             string
        |  +---u ks:inline-or-keystore-asymmetric-key-grouping
        +--rw asymmetric-key-with-certs* [name]
        |  +--rw name
        |  |       string
        |  +---u ks:inline-or-keystore-asymmetric-key-with-certs-groupi\
   ng
        +--rw end-entity-cert-with-key* [name]
           +--rw name
           |       string
           +---u ks:inline-or-keystore-end-entity-cert-with-key-grouping

   The following tree diagram illustrates the "ex-keystore-usage" module
   with all "grouping" statements expanded, enabling the usage's full
   structure to be seen:

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   module: ex-keystore-usage
     +--rw keystore-usage
        +--rw symmetric-key* [name]
        |  +--rw name                                string
        |  +--rw (inline-or-keystore)
        |     +--:(inline) {inline-definitions-supported}?
        |     |  +--rw inline-definition
        |     |     +--rw key-format?                      identityref
        |     |     +--rw (key-type)
        |     |        +--:(cleartext-symmetric-key)
        |     |        |  +--rw cleartext-symmetric-key?   binary
        |     |        |          {cleartext-symmetric-keys}?
        |     |        +--:(hidden-symmetric-key)
        |     |        |        {hidden-symmetric-keys}?
        |     |        |  +--rw hidden-symmetric-key?      empty
        |     |        +--:(encrypted-symmetric-key)
        |     |                 {encrypted-symmetric-keys}?
        |     |           +--rw encrypted-symmetric-key
        |     |              +--rw encrypted-by
        |     |              +--rw encrypted-value-format    identityref
        |     |              +--rw encrypted-value           binary
        |     +--:(central-keystore)
        |              {central-keystore-supported,symmetric-keys}?
        |        +--rw central-keystore-reference?
        |                ks:central-symmetric-key-ref
        +--rw asymmetric-key* [name]
        |  +--rw name                                string
        |  +--rw (inline-or-keystore)
        |     +--:(inline) {inline-definitions-supported}?
        |     |  +--rw inline-definition
        |     |     +--rw public-key-format?             identityref
        |     |     +--rw public-key?                    binary
        |     |     +--rw private-key-format?            identityref
        |     |     +--rw (private-key-type)
        |     |        +--:(cleartext-private-key)
        |     |        |        {cleartext-private-keys}?
        |     |        |  +--rw cleartext-private-key?   binary
        |     |        +--:(hidden-private-key) {hidden-private-keys}?
        |     |        |  +--rw hidden-private-key?      empty
        |     |        +--:(encrypted-private-key)
        |     |                 {encrypted-private-keys}?
        |     |           +--rw encrypted-private-key
        |     |              +--rw encrypted-by
        |     |              +--rw encrypted-value-format    identityref
        |     |              +--rw encrypted-value           binary
        |     +--:(central-keystore)
        |              {central-keystore-supported,asymmetric-keys}?
        |        +--rw central-keystore-reference?
        |                ks:central-asymmetric-key-ref
        +--rw asymmetric-key-with-certs* [name]
        |  +--rw name                                string
        |  +--rw (inline-or-keystore)
        |     +--:(inline) {inline-definitions-supported}?
        |     |  +--rw inline-definition
        |     |     +--rw public-key-format?             identityref
        |     |     +--rw public-key?                    binary
        |     |     +--rw private-key-format?            identityref
        |     |     +--rw (private-key-type)
        |     |     |  +--:(cleartext-private-key)
        |     |     |  |        {cleartext-private-keys}?
        |     |     |  |  +--rw cleartext-private-key?   binary
        |     |     |  +--:(hidden-private-key) {hidden-private-keys}?
        |     |     |  |  +--rw hidden-private-key?      empty
        |     |     |  +--:(encrypted-private-key)
        |     |     |           {encrypted-private-keys}?
        |     |     |     +--rw encrypted-private-key
        |     |     |        +--rw encrypted-by
        |     |     |        +--rw encrypted-value-format    identityref
        |     |     |        +--rw encrypted-value           binary
        |     |     +--rw certificates
        |     |     |  +--rw certificate* [name]
        |     |     |     +--rw name                      string
        |     |     |     +--rw cert-data
        |     |     |     |       end-entity-cert-cms
        |     |     |     +---n certificate-expiration
        |     |     |             {certificate-expiration-notification}?
        |     |     |        +-- expiration-date    yang:date-and-time
        |     |     +---x generate-csr {csr-generation}?
        |     |        +---w input
        |     |        |  +---w csr-format    identityref
        |     |        |  +---w csr-info      csr-info
        |     |        +--ro output
        |     |           +--ro (csr-type)
        |     |              +--:(p10-csr)
        |     |                 +--ro p10-csr?   p10-csr
        |     +--:(central-keystore)
        |              {central-keystore-supported,asymmetric-keys}?
        |        +--rw central-keystore-reference?
        |                ks:central-asymmetric-key-ref
        +--rw end-entity-cert-with-key* [name]
           +--rw name                                string
           +--rw (inline-or-keystore)
              +--:(inline) {inline-definitions-supported}?
              |  +--rw inline-definition
              |     +--rw public-key-format?             identityref
              |     +--rw public-key?                    binary
              |     +--rw private-key-format?            identityref
              |     +--rw (private-key-type)
              |     |  +--:(cleartext-private-key)
              |     |  |        {cleartext-private-keys}?
              |     |  |  +--rw cleartext-private-key?   binary
              |     |  +--:(hidden-private-key) {hidden-private-keys}?
              |     |  |  +--rw hidden-private-key?      empty
              |     |  +--:(encrypted-private-key)
              |     |           {encrypted-private-keys}?
              |     |     +--rw encrypted-private-key
              |     |        +--rw encrypted-by
              |     |        +--rw encrypted-value-format    identityref
              |     |        +--rw encrypted-value           binary
              |     +--rw cert-data?
              |     |       end-entity-cert-cms
              |     +---n certificate-expiration
              |     |       {certificate-expiration-notification}?
              |     |  +-- expiration-date    yang:date-and-time
              |     +---x generate-csr {csr-generation}?
              |        +---w input
              |        |  +---w csr-format    identityref
              |        |  +---w csr-info      csr-info
              |        +--ro output
              |           +--ro (csr-type)
              |              +--:(p10-csr)
              |                 +--ro p10-csr?   p10-csr
              +--:(central-keystore)
                       {central-keystore-supported,asymmetric-keys}?
                 +--rw central-keystore-reference
                    +--rw asymmetric-key?
                    |       ks:central-asymmetric-key-ref
                    |       {central-keystore-supported,asymmetric-keys\
   }?
                    +--rw certificate?      leafref

2.2.3.2.  Example Usage for the "ex-keystore-usage" Module

   The following example provides two equivalent instances of each
   grouping, the first being a reference to a keystore and the second
   being inlined.  The instance having a reference to a keystore is
   consistent with the keystore defined in Section 2.2.1.  The two
   instances are equivalent, as the inlined instance example contains
   the same values defined by the keystore instance referenced by its
   sibling example.

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   <keystore-usage
     xmlns="https://example.com/ns/example-keystore-usage"
     xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-crypto-types">

     <!-- The following two equivalent examples illustrate the  -->
     <!-- "inline-or-keystore-symmetric-key-grouping" grouping: -->

     <symmetric-key>
       <name>example 1a</name>
       <central-keystore-reference>cleartext-symmetric-key</central-key\
   store-reference>
     </symmetric-key>

     <symmetric-key>
       <name>example 1b</name>
       <inline-definition>
         <key-format>ct:octet-string-key-format</key-format>
         <cleartext-symmetric-key>BASE64VALUE=</cleartext-symmetric-key>
       </inline-definition>
     </symmetric-key>


     <!-- The following two equivalent examples illustrate the   -->
     <!-- "inline-or-keystore-asymmetric-key-grouping" grouping: -->

     <asymmetric-key>
       <name>example 2a</name>
       <central-keystore-reference>rsa-asymmetric-key</central-keystore\
   -reference>
     </asymmetric-key>

     <asymmetric-key>
       <name>example 2b</name>
       <inline-definition>
         <public-key-format>ct:subject-public-key-info-format</public-k\
   ey-format>
         <public-key>BASE64VALUE=</public-key>
         <private-key-format>ct:rsa-private-key-format</private-key-for\
   mat>
         <cleartext-private-key>BASE64VALUE=</cleartext-private-key>
       </inline-definition>
     </asymmetric-key>


     <!-- The following two equivalent examples illustrate the     -->
     <!-- "inline-or-keystore-asymmetric-key-with-certs-grouping"  -->
     <!-- grouping:                                                -->

     <asymmetric-key-with-certs>
       <name>example 3a</name>
       <central-keystore-reference>rsa-asymmetric-key</central-keystore\
   -reference>
     </asymmetric-key-with-certs>

     <asymmetric-key-with-certs>
       <name>example 3b</name>
       <inline-definition>
         <public-key-format>ct:subject-public-key-info-format</public-k\
   ey-format>
         <public-key>BASE64VALUE=</public-key>
         <private-key-format>ct:rsa-private-key-format</private-key-for\
   mat>
         <cleartext-private-key>BASE64VALUE=</cleartext-private-key>
         <certificates>
           <certificate>
             <name>a locally defined cert</name>
             <cert-data>BASE64VALUE=</cert-data>
           </certificate>
         </certificates>
       </inline-definition>
     </asymmetric-key-with-certs>


     <!-- The following two equivalent examples illustrate the    -->
     <!-- "inline-or-keystore-end-entity-cert-with-key-grouping"  -->
     <!-- grouping:                                               -->
     <end-entity-cert-with-key>
       <name>example 4a</name>
       <central-keystore-reference>
         <asymmetric-key>rsa-asymmetric-key</asymmetric-key>
         <certificate>ex-rsa-cert</certificate>
       </central-keystore-reference>
     </end-entity-cert-with-key>

     <end-entity-cert-with-key>
       <name>example 4b</name>
       <inline-definition>
         <public-key-format>ct:subject-public-key-info-format</public-k\
   ey-format>
         <public-key>BASE64VALUE=</public-key>
         <private-key-format>ct:rsa-private-key-format</private-key-for\
   mat>
         <cleartext-private-key>BASE64VALUE=</cleartext-private-key>
         <cert-data>BASE64VALUE=</cert-data>
       </inline-definition>
     </end-entity-cert-with-key>

   </keystore-usage>

2.2.3.3.  The "ex-keystore-usage" YANG Module

   Following is the "ex-keystore-usage" module's YANG definition:

   module ex-keystore-usage {
     yang-version 1.1;
     namespace "https://example.com/ns/example-keystore-usage";
     prefix ex-keystore-usage;

     import ietf-keystore {
       prefix ks;
       reference
         "RFC 9642: A YANG Data Model for a Keystore";
     }

     organization
       "Example Corporation";

     contact
       "Author: YANG Designer <mailto:yang.designer@example.com>";

     description
       "This example module illustrates notable groupings defined
        in the 'ietf-keystore' module.";

     revision 2024-10-10 {
       description
         "Initial version";
       reference
         "RFC 9642: A YANG Data Model for a Keystore";
     }

     container keystore-usage {
       description
         "An illustration of the various keystore groupings.";
       list symmetric-key {
         key "name";
         leaf name {
           type string;
           description
             "An arbitrary name for this key.";
         }
         uses ks:inline-or-keystore-symmetric-key-grouping;
         description
           "An symmetric key that may be configured locally or be a
            reference to a symmetric key in the keystore.";
       }
       list asymmetric-key {
         key "name";
         leaf name {
           type string;
           description
             "An arbitrary name for this key.";
         }
         uses ks:inline-or-keystore-asymmetric-key-grouping;
         description
           "An asymmetric key, with no certs, that may be configured
            locally or be a reference to an asymmetric key in the
            keystore.  The intent is to reference just the asymmetric
            key, not any certificates that may also be associated
            with the asymmetric key.";
       }
       list asymmetric-key-with-certs {
         key "name";
         leaf name {
           type string;
           description
             "An arbitrary name for this key.";
         }
         uses ks:inline-or-keystore-asymmetric-key-with-certs-grouping;
         description
           "An asymmetric key and its associated certs that may be
            configured locally or be a reference to an asymmetric
            key (and its associated certs) in the keystore.";
       }
       list end-entity-cert-with-key {
         key "name";
         leaf name {
           type string;
           description
             "An arbitrary name for this key.";
         }
         uses ks:inline-or-keystore-end-entity-cert-with-key-grouping;
         description
           "An end-entity certificate and its associated asymmetric
            key that may be configured locally or be a reference
            to another certificate (and its associated asymmetric
            key) in the keystore.";
       }
     }
   }

2.3.  YANG Module

   This YANG module has normative references to [RFC8341] and [RFC9640].

   <CODE BEGINS> file "ietf-keystore@2024-10-10.yang"
   module ietf-keystore {
     yang-version 1.1;
     namespace "urn:ietf:params:xml:ns:yang:ietf-keystore";
     prefix ks;

     import ietf-netconf-acm {
       prefix nacm;
       reference
         "RFC 8341: Network Configuration Access Control Model";
     }

     import ietf-crypto-types {
       prefix ct;
       reference
         "RFC 9640: YANG Data Types and Groupings for Cryptography";
     }

     organization
       "IETF NETCONF (Network Configuration) Working Group";

     contact
       "WG Web:   https://datatracker.ietf.org/wg/netconf
        WG List:  NETCONF WG list <mailto:netconf@ietf.org>
        Author:   Kent Watsen <mailto:kent+ietf@watsen.net>";

     description
       "This module defines a 'keystore' to centralize management
        of security credentials.

        The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL',
        'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED',
        'NOT RECOMMENDED', 'MAY', and 'OPTIONAL' in this document
        are to be interpreted as described in BCP 14 (RFC 2119)
        (RFC 8174) when, and only when, they appear in all
        capitals, as shown here.

        Copyright (c) 2024 IETF Trust and the persons identified
        as authors of the code. All rights reserved.

        Redistribution and use in source and binary forms, with
        or without modification, is permitted pursuant to, and
        subject to the license terms contained in, the Revised
        BSD License set forth in Section 4.c of the IETF Trust's
        Legal Provisions Relating to IETF Documents
        (https://trustee.ietf.org/license-info).

        This version of this YANG module is part of RFC 9642
        (https://www.rfc-editor.org/info/rfc9642); see the RFC
        itself for full legal notices.";

     revision 2024-10-10 {
       description
         "Initial version";
       reference
         "RFC 9642: A YANG Data Model for a Keystore";
     }

     /****************/
     /*   Features   */
     /****************/

     feature central-keystore-supported {
       description
         "The 'central-keystore-supported' feature indicates that
          the server supports the central keystore (i.e., fully
          implements the 'ietf-keystore' module).";
     }

     feature inline-definitions-supported {
       description
         "The 'inline-definitions-supported' feature indicates that
          the server supports locally defined keys.";
     }

     feature asymmetric-keys {
       description
         "The 'asymmetric-keys' feature indicates that the server
          implements the /keystore/asymmetric-keys subtree.";

     }

     feature symmetric-keys {
       description
         "The 'symmetric-keys' feature indicates that the server
          implements the /keystore/symmetric-keys subtree.";
     }

     /****************/
     /*   Typedefs   */
     /****************/

     typedef central-symmetric-key-ref {
       type leafref {
         path "/ks:keystore/ks:symmetric-keys/ks:symmetric-key"
            + "/ks:name";
       }
       description
         "This typedef enables modules to easily define a reference
          to a symmetric key stored in the central keystore.";
     }

     typedef central-asymmetric-key-ref {
       type leafref {
         path "/ks:keystore/ks:asymmetric-keys/ks:asymmetric-key"
            + "/ks:name";
       }
       description
         "This typedef enables modules to easily define a reference
          to an asymmetric key stored in the central keystore.";
     }

     /*****************/
     /*   Groupings   */
     /*****************/

     grouping encrypted-by-grouping {
       description
         "A grouping that defines a 'choice' statement that can be
          augmented into the 'encrypted-by' node, present in the
          'symmetric-key-grouping' and 'asymmetric-key-pair-grouping'
          groupings defined in RFC 9640, enabling references to keys
          in the central keystore.";
       choice encrypted-by {
         nacm:default-deny-write;
         mandatory true;
         description
           "A choice amongst other symmetric or asymmetric keys.";
         case central-symmetric-key-ref {
           if-feature "central-keystore-supported";
           if-feature "symmetric-keys";
           leaf symmetric-key-ref {
             type ks:central-symmetric-key-ref;
             description
               "Identifies the symmetric key used to encrypt the
                associated key.";
           }
         }
         case central-asymmetric-key-ref {
           if-feature "central-keystore-supported";
           if-feature "asymmetric-keys";
           leaf asymmetric-key-ref {
             type ks:central-asymmetric-key-ref;
             description
               "Identifies the asymmetric key whose public key
                encrypted the associated key.";
           }
         }
       }
     }

     // *-ref groupings

     grouping central-asymmetric-key-certificate-ref-grouping {
       description
         "A grouping for the reference to a certificate associated
          with an asymmetric key stored in the central keystore.";
       leaf asymmetric-key {
         nacm:default-deny-write;
         if-feature "central-keystore-supported";
         if-feature "asymmetric-keys";
         type ks:central-asymmetric-key-ref;
         must '../certificate';
         description
           "A reference to an asymmetric key in the keystore.";
       }
       leaf certificate {
         nacm:default-deny-write;
         type leafref {
           path "/ks:keystore/ks:asymmetric-keys/ks:asymmetric-key"
              + "[ks:name = current()/../asymmetric-key]/"
              + "ks:certificates/ks:certificate/ks:name";
         }
         must '../asymmetric-key';
         description
           "A reference to a specific certificate of the
            asymmetric key in the keystore.";
       }
     }

     // inline-or-keystore-* groupings

     grouping inline-or-keystore-symmetric-key-grouping {
       description
         "A grouping for the configuration of a symmetric key.  The
          symmetric key may be defined inline or as a reference to
          a symmetric key stored in the central keystore.

          Servers that wish to define alternate keystore locations
          SHOULD augment in custom 'case' statements enabling
          references to those alternate keystore locations.";
       choice inline-or-keystore {
         nacm:default-deny-write;
         mandatory true;
         description
           "A choice between an inlined definition and a definition
            that exists in the keystore.";
         case inline {
           if-feature "inline-definitions-supported";
           container inline-definition {
             description
               "A container to hold the local key definition.";
             uses ct:symmetric-key-grouping;
           }
         }
         case central-keystore {
           if-feature "central-keystore-supported";
           if-feature "symmetric-keys";
           leaf central-keystore-reference {
             type ks:central-symmetric-key-ref;
             description
               "A reference to a symmetric key that exists in
                the central keystore.";
           }
         }
       }
     }

     grouping inline-or-keystore-asymmetric-key-grouping {
       description
         "A grouping for the configuration of an asymmetric key.  The
          asymmetric key may be defined inline or as a reference to
          an asymmetric key stored in the central keystore.

          Servers that wish to define alternate keystore locations
          SHOULD augment in custom 'case' statements enabling
          references to those alternate keystore locations.";
       choice inline-or-keystore {
         nacm:default-deny-write;
         mandatory true;
         description
           "A choice between an inlined definition and a definition
            that exists in the keystore.";
         case inline {
           if-feature "inline-definitions-supported";
           container inline-definition {
             description
               "A container to hold the local key definition.";
             uses ct:asymmetric-key-pair-grouping;
           }
         }
         case central-keystore {
           if-feature "central-keystore-supported";
           if-feature "asymmetric-keys";
           leaf central-keystore-reference {
             type ks:central-asymmetric-key-ref;
             description
               "A reference to an asymmetric key that exists in
                the central keystore.  The intent is to reference
                just the asymmetric key without any regard for
                any certificates that may be associated with it.";
           }
         }
       }
     }

     grouping inline-or-keystore-asymmetric-key-with-certs-grouping {
       description
         "A grouping for the configuration of an asymmetric key and
          its associated certificates.  The asymmetric key and its
          associated certificates may be defined inline or as a
          reference to an asymmetric key (and its associated
          certificates) in the central keystore.

          Servers that wish to define alternate keystore locations
          SHOULD augment in custom 'case' statements enabling
          references to those alternate keystore locations.";
       choice inline-or-keystore {
         nacm:default-deny-write;
         mandatory true;
         description
           "A choice between an inlined definition and a definition
            that exists in the keystore.";
         case inline {
           if-feature "inline-definitions-supported";
           container inline-definition {
             description
               "A container to hold the local key definition.";
             uses ct:asymmetric-key-pair-with-certs-grouping;
           }
         }
         case central-keystore {
           if-feature "central-keystore-supported";
           if-feature "asymmetric-keys";
           leaf central-keystore-reference {
             type ks:central-asymmetric-key-ref;
             description
               "A reference to an asymmetric key (and all of its
                associated certificates) in the keystore, when
                this module is implemented.";
           }
         }
       }
     }

     grouping inline-or-keystore-end-entity-cert-with-key-grouping {
       description
         "A grouping for the configuration of an asymmetric key and
          its associated end-entity certificate.  The asymmetric key
          and its associated end-entity certificate may be defined
          inline or as a reference to an asymmetric key (and its
          associated end-entity certificate) in the central keystore.

          Servers that wish to define alternate keystore locations
          SHOULD augment in custom 'case' statements enabling
          references to those alternate keystore locations.";
       choice inline-or-keystore {
         nacm:default-deny-write;
         mandatory true;
         description
           "A choice between an inlined definition and a definition
            that exists in the keystore.";
         case inline {
           if-feature "inline-definitions-supported";
           container inline-definition {
             description
               "A container to hold the local key definition.";
             uses ct:asymmetric-key-pair-with-cert-grouping;
           }
         }
         case central-keystore {
           if-feature "central-keystore-supported";
           if-feature "asymmetric-keys";
           container central-keystore-reference {
             uses central-asymmetric-key-certificate-ref-grouping;
             description
               "A reference to a specific certificate associated with
                an asymmetric key stored in the central keystore.";
           }
         }
       }
     }

     // the keystore grouping

     grouping keystore-grouping {
       description
         "A grouping definition enables use in other contexts.  If ever
          done, implementations MUST augment new 'case' statements
          into the various inline-or-keystore 'choice' statements to
          supply leafrefs to the model-specific location(s).";
       container asymmetric-keys {
         nacm:default-deny-write;
         if-feature "asymmetric-keys";
         description
           "A list of asymmetric keys.";
         list asymmetric-key {
           key "name";
           description
             "An asymmetric key.";
           leaf name {
             type string;
             description
               "An arbitrary name for the asymmetric key.";
           }
           uses ct:asymmetric-key-pair-with-certs-grouping;
         }
       }
       container symmetric-keys {
         nacm:default-deny-write;
         if-feature "symmetric-keys";
         description
           "A list of symmetric keys.";
         list symmetric-key {
           key "name";
           description
             "A symmetric key.";
           leaf name {
             type string;
             description
               "An arbitrary name for the symmetric key.";
           }
           uses ct:symmetric-key-grouping;
         }
       }
     }

     /*********************************/
     /*   Protocol accessible nodes   */
     /*********************************/

     container keystore {
       if-feature "central-keystore-supported";
       description
         "A central keystore containing a list of symmetric keys and
          a list of asymmetric keys.";
       nacm:default-deny-write;
       uses keystore-grouping {
         augment "symmetric-keys/symmetric-key/key-type/encrypted-"
               + "symmetric-key/encrypted-symmetric-key/encrypted-by" {
           description
             "Augments in a choice statement enabling the encrypting
              key to be any other symmetric or asymmetric key in the
              central keystore.";
           uses encrypted-by-grouping;
         }
         augment "asymmetric-keys/asymmetric-key/private-key-type/"
               + "encrypted-private-key/encrypted-private-key/"
               + "encrypted-by" {
           description
             "Augments in a choice statement enabling the encrypting
              key to be any other symmetric or asymmetric key in the
              central keystore.";
           uses encrypted-by-grouping;
         }
       }
     }
   }
   <CODE ENDS>

3.  Support for Built-In Keys

   In some implementations, a server may support keys built into the
   server.  Built-in keys MAY be set during the manufacturing process or
   be dynamically generated the first time the server is booted or a
   particular service (e.g., Secure Shell (SSH)) is enabled.

   Built-in keys are "hidden" keys expected to be set by a vendor-
   specific process.  Any ability for operators to set and/or modify
   built-in keys is outside the scope of this document.

   The primary characteristic of the built-in keys is that they are
   provided by the server, as opposed to being configured.  As such,
   they are present in <operational> (Section 5.3 of [RFC8342]) and
   <system> [NETMOD-SYSTEM-CONFIG], if implemented.

   The example below illustrates what the keystore in <operational>
   might look like for a server in its factory default state.  Note that
   the built-in keys have the "or:origin" annotation value "or:system".

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   <keystore xmlns="urn:ietf:params:xml:ns:yang:ietf-keystore"
     xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-crypto-types"
     xmlns:or="urn:ietf:params:xml:ns:yang:ietf-origin"
     or:origin="or:intended">
     <asymmetric-keys>
       <asymmetric-key or:origin="or:system">
         <name>Manufacturer-Generated Hidden Key</name>
         <public-key-format>ct:subject-public-key-info-format</public-k\
   ey-format>
         <public-key>BASE64VALUE=</public-key>
         <hidden-private-key/>
         <certificates>
           <certificate>
             <name>Manufacturer-Generated IDevID Cert</name>
             <cert-data>BASE64VALUE=</cert-data>
           </certificate>
         </certificates>
       </asymmetric-key>
     </asymmetric-keys>
   </keystore>

   The following example illustrates how a single built-in key
   definition from the previous example has been propagated to
   <running>:

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   <keystore xmlns="urn:ietf:params:xml:ns:yang:ietf-keystore"
     xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-crypto-types">
     <asymmetric-keys>
       <asymmetric-key>
         <name>Manufacturer-Generated Hidden Key</name>
         <public-key-format>ct:subject-public-key-info-format</public-k\
   ey-format>
         <public-key>BASE64VALUE=</public-key>
         <hidden-private-key/>
         <certificates>
           <certificate>
             <name>Manufacturer-Generated IDevID Cert</name>
             <cert-data>BASE64VALUE=</cert-data>
           </certificate>
           <certificate>
             <name>Deployment-Specific LDevID Cert</name>
             <cert-data>BASE64VALUE=</cert-data>
           </certificate>
         </certificates>
       </asymmetric-key>
     </asymmetric-keys>
   </keystore>

   After the above configuration is applied, <operational> should appear
   as follows:

   =============== NOTE: '\' line wrapping per RFC 8792 ================

   <keystore xmlns="urn:ietf:params:xml:ns:yang:ietf-keystore"
     xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-crypto-types"
     xmlns:or="urn:ietf:params:xml:ns:yang:ietf-origin"
     or:origin="or:intended">
     <asymmetric-keys>
       <asymmetric-key or:origin="or:system">
         <name>Manufacturer-Generated Hidden Key</name>
         <public-key-format>ct:subject-public-key-info-format</public-k\
   ey-format>
         <public-key>BASE64VALUE=</public-key>
         <hidden-private-key/>
         <certificates>
           <certificate>
             <name>Manufacturer-Generated IDevID Cert</name>
             <cert-data>BASE64VALUE=</cert-data>
           </certificate>
           <certificate or:origin="or:intended">
             <name>Deployment-Specific LDevID Cert</name>
             <cert-data>BASE64VALUE=</cert-data>
           </certificate>
         </certificates>
       </asymmetric-key>
     </asymmetric-keys>
   </keystore>

4.  Encrypting Keys in Configuration

   This section describes an approach that enables both the symmetric
   and asymmetric keys on a server to be encrypted, such that backup/
   restore procedures can be used without concern for raw key data being
   compromised when in transit.

   The approach presented in this section is not normative.  This
   section answers how a configuration containing secrets that are
   encrypted by a built-in key (Section 3) can be backed up from one
   server and restored on a different server when each server has unique
   primary keys.  The API defined by the "ietf-keystore" YANG module
   presented in this document is sufficient to support the workflow
   described in this section.

4.1.  Key Encryption Key

   The ability to encrypt configured keys is predicated on the existence
   of a key encryption key (KEK).  There may be any number of KEKs in a
   server.  A KEK, by its namesake, is a key that is used to encrypt
   other keys.  A KEK MAY be either a symmetric key or an asymmetric
   key.

   If a KEK is a symmetric key, then the server MUST provide an API for
   administrators to encrypt other keys without needing to know the
   symmetric key's value.  If the KEK is an asymmetric key, then the
   server SHOULD provide an API enabling the encryption of other keys
   or, alternatively, assume the administrators can do so themselves
   using the asymmetric key's public half.

   A server MUST possess access to the KEK, or an API using the KEK, so
   that it can decrypt the other keys in the configuration at runtime.

4.2.  Configuring Encrypted Keys

   Each time a new key is configured, it SHOULD be encrypted by a KEK.

   In the "ietf-crypto-types" module [RFC9640], the format for encrypted
   values is described by identity statements derived from the
   "symmetrically-encrypted-value-format" and "asymmetrically-encrypted-
   value-format" identity statements.

   Implementations of servers implementing the "ietf-keystore" module
   SHOULD provide an API that simultaneously generates a key and
   encrypts the generated key using a KEK.  Thus, the cleartext value of
   the newly generated key may never be known to the administrators
   generating the keys.  Such an API is defined in the "ietf-ssh-common"
   and "ietf-tls-common" YANG modules defined in [RFC9644] and
   [RFC9645], respectively.

   In case the server implementation does not provide such an API, then
   the generating and encrypting steps MAY be performed outside the
   server, e.g., by an administrator with special access control rights
   (such as an organization's crypto officer).

   In either case, the encrypted key can be configured into the keystore
   using either the "encrypted-symmetric-key" (for symmetric keys) or
   the "encrypted-private-key" (for asymmetric keys) nodes.  These two
   nodes contain both the encrypted raw key value as well as a reference
   to the KEK that encrypted the key.

4.3.  Migrating Configuration to Another Server

   When a KEK is used to encrypt other keys, migrating the configuration
   to another server is only possible if the second server has the same
   KEK.  How the second server comes to have the same KEK is discussed
   in this section.

   In some deployments, mechanisms outside the scope of this document
   may be used to migrate a KEK from one server to another.  That said,
   beware that the ability to do so typically entails having access to
   the first server; however, in some scenarios, the first server may no
   longer be operational.

   In other deployments, an organization's crypto officer, possessing a
   KEK's cleartext value, configures the same KEK on the second server,
   presumably as a hidden key or a key protected by access control, so
   that the cleartext value is not disclosed to regular administrators.
   However, this approach creates high coupling to and dependency on the
   crypto officers that does not scale in production environments.

   In order to decouple the crypto officers from the regular
   administrators, a special KEK, called the "primary key" (PK), may be
   used.

   A PK is commonly a globally unique built-in (see Section 3)
   asymmetric key.  The private raw key value, due to its long lifetime,
   is hidden (i.e., "hidden-private-key"; see Section 2.1.4.5. of
   [RFC9640]).  The raw public key value is often contained in an
   identity certificate (e.g., IDevID).  How to configure a PK during
   the manufacturing process is outside the scope of this document.

   Assuming the server has a PK, the PK can be used to encrypt a "shared
   KEK", which is then used to encrypt the keys configured by regular
   administrators.

   With this extra level of indirection, it is possible for a crypto
   officer to encrypt the same KEK for a multiplicity of servers offline
   using the public key contained in their identity certificates.  The
   crypto officer can then safely hand off the encrypted KEKs to regular
   administrators responsible for server installations, including
   migrations.

   In order to migrate the configuration from a first server, an
   administrator would need to make just a single modification to the
   configuration before loading it onto a second server, which is to
   replace the encrypted KEK keystore entry from the first server with
   the encrypted KEK for the second server.  Upon doing this, the
   configuration (containing many encrypted keys) can be loaded into the
   second server while enabling the second server to decrypt all the
   encrypted keys in the configuration.

   The following diagram illustrates this idea:

    +-------------+                                 +-------------+
    | shared KEK  |                                 | shared KEK  |
    |(unencrypted)|-------------------------------> | (encrypted) |
    +-------------+     encrypts offline using      +-------------+
           ^            each server's PK                |
           |                                            |
           |                                            |
           |  possesses    \o                           |
           +--------------  |\                          |
                           / \         shares with      |
                         crypto    +--------------------+
                         officer   |
                                   |
                                   |
   +----------------------+        |         +----------------------+
   |       server-1       |        |         |       server-2       |
   |    configuration     |        |         |    configuration     |
   |                      |        |         |                      |
   |                      |        |         |                      |
   |  +----------------+  |        |         |  +----------------+  |
   |  |      PK-1      |  |        |         |  |      PK-2      |  |
   |  |    (hidden)    |  |        |         |  |    (hidden)    |  |
   |  +----------------+  |        |         |  +----------------+  |
   |      ^               |        |         |      ^               |
   |      |               |        |         |      |               |
   |      |               |        |         |      |               |
   |      |  encrypted    |        |         |      |  encrypted    |
   |      |  by           |        |         |      |  by           |
   |      |               |        |         |      |               |
   |      |               |        |         |      |               |
   |  +----------------+  |        |         |  +----------------+  |
   |  |  shared KEK    |  |        |         |  |  shared KEK    |  |
   |  |  (encrypted)   |  |        v         |  |  (encrypted)   |  |
   |  +----------------+  |                  |  +----------------+  |
   |      ^               |     regular      |      ^               |
   |      |               |      admin       |      |               |
   |      |               |                  |      |               |
   |      |  encrypted    |       \o         |      |  encrypted    |
   |      |  by           |        |\        |      |  by           |
   |      |               |       / \        |      |               |
   |      |               |                  |      |               |
   |  +----------------+  |----------------->|  +----------------+  |
   |  | all other keys |  |     migrate      |  | all other keys |  |
   |  |  (encrypted)   |  |  configuration   |  |  (encrypted)   |  |
   |  +----------------+  |                  |  +----------------+  |
   |                      |                  |                      |
   +----------------------+                  +----------------------+

5.  Security Considerations

5.1.  Security of Data at Rest and in Motion

   The YANG module defined in this document defines a mechanism called a
   "keystore" that intends to protect its contents from unauthorized
   disclosure and modification.

   In order to satisfy the expectations of a keystore, it is RECOMMENDED
   that server implementations ensure that the keystore contents are
   encrypted when persisted to non-volatile memory and that the keystore
   contents that have been decrypted in volatile memory are zeroized
   when not in use.

   The keystore contents may be encrypted by either encrypting the
   contents individually (e.g., using the "encrypted" value formats) or
   using persistence-layer-level encryption.  If storing cleartext
   values (which is NOT RECOMMENDED per Section 3.5 of [RFC9640]), then
   persistence-layer-level encryption SHOULD be used to protect the data
   at rest.

   If the keystore contents are not encrypted when persisted, then
   server implementations MUST ensure the persisted storage is
   inaccessible.

5.2.  Unconstrained Private Key Usage

   This module enables the configuration of private keys without
   constraints on their usage, e.g., what operations the key is allowed
   to be used for (such as signature, decryption, or both).

   This module also does not constrain the usage of the associated
   public keys other than in the context of a configured certificate
   (e.g., an identity certificate), in which case the key usage is
   constrained by the certificate.

5.3.  Security Considerations for the "ietf-keystore" YANG Module

   This section is modeled after the template defined in Section 3.7.1
   of [RFC8407].

   The ietf-keystore YANG module defines a data model that is designed
   to be accessed via YANG-based management protocols, such as NETCONF
   [RFC6241] and RESTCONF [RFC8040].  These protocols have mandatory-to-
   implement secure transport layers (e.g., SSH [RFC4252], TLS
   [RFC8446], and QUIC [RFC9000]) and mandatory-to-implement mutual
   authentication.

   The Network Configuration Access Control Model (NACM) [RFC8341]
   provides the means to restrict access for particular users to a
   preconfigured subset of all available protocol operations and
   content.

   Please be aware that this YANG module uses groupings from other YANG
   modules that define nodes that may be considered sensitive or
   vulnerable in network environments.  Please review the Security
   Considerations for dependent YANG modules for information as to which
   nodes may be considered sensitive or vulnerable in network
   environments.

   Some of the readable data nodes in this YANG module may be considered
   sensitive or vulnerable in some network environments.  It is thus
   important to control read access (e.g., via get, get-config, or
   notification) to these data nodes.  These are the subtrees and data
   nodes and their sensitivity/vulnerability:

   The "cleartext-symmetric-key" node:
      This node, imported from the "symmetric-key-grouping" grouping
      defined in [RFC9640], is additionally sensitive to read operations
      such that, in normal use cases, it should never be returned to a
      client.  For this reason, the NACM extension "default-deny-all"
      was applied to it in [RFC9640].

   The "cleartext-private-key" node:
      This node, defined in the "asymmetric-key-pair-grouping" grouping
      in [RFC9640], is additionally sensitive to read operations such
      that, in normal use cases, it should never be returned to a
      client.  For this reason, the NACM extension "default-deny-all" is
      applied to it in [RFC9640].

   All the writable data nodes defined by this YANG module, both in the
   "grouping" statements as well as the protocol-accessible "keystore"
   instance, may be considered sensitive or vulnerable in some network
   environments.  For instance, any modification to a key or reference
   to a key may dramatically alter the implemented security policy.  For
   this reason, the NACM extension "default-deny-write" has been set for
   all data nodes defined in this module.

   This YANG module does not define any "rpc" or "action" statements,
   and thus the security considerations for such is not provided here.

   Built-in key types SHOULD be hidden and/or encrypted (not cleartext).
   If this is not possible, access control mechanisms like NACM SHOULD
   be used to limit access to the key's secret data to only the most
   trusted authorized clients (e.g., belonging to an organization's
   crypto officer).

6.  IANA Considerations

6.1.  The IETF XML Registry

   IANA has registered the following URI in the "ns" registry of the
   "IETF XML Registry" [RFC3688].

   URI:  urn:ietf:params:xml:ns:yang:ietf-keystore
   Registrant Contact:  The IESG
   XML:  N/A; the requested URI is an XML namespace.

6.2.  The YANG Module Names Registry

   IANA has registered the following YANG module in the "YANG Module
   Names" registry defined in [RFC6020].

   Name:  ietf-keystore
   Maintained by IANA:  N
   Namespace:  urn:ietf:params:xml:ns:yang:ietf-keystore
   Prefix:  ks
   Reference:  RFC 9642

7.  References

7.1.  Normative References

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC4252]  Ylonen, T. and C. Lonvick, Ed., "The Secure Shell (SSH)
              Authentication Protocol", RFC 4252, DOI 10.17487/RFC4252,
              January 2006, <https://www.rfc-editor.org/info/rfc4252>.

   [RFC6020]  Bjorklund, M., Ed., "YANG - A Data Modeling Language for
              the Network Configuration Protocol (NETCONF)", RFC 6020,
              DOI 10.17487/RFC6020, October 2010,
              <https://www.rfc-editor.org/info/rfc6020>.

   [RFC6241]  Enns, R., Ed., Bjorklund, M., Ed., Schoenwaelder, J., Ed.,
              and A. Bierman, Ed., "Network Configuration Protocol
              (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011,
              <https://www.rfc-editor.org/info/rfc6241>.

   [RFC7950]  Bjorklund, M., Ed., "The YANG 1.1 Data Modeling Language",
              RFC 7950, DOI 10.17487/RFC7950, August 2016,
              <https://www.rfc-editor.org/info/rfc7950>.

   [RFC8040]  Bierman, A., Bjorklund, M., and K. Watsen, "RESTCONF
              Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017,
              <https://www.rfc-editor.org/info/rfc8040>.

   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
              2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.

   [RFC8341]  Bierman, A. and M. Bjorklund, "Network Configuration
              Access Control Model", STD 91, RFC 8341,
              DOI 10.17487/RFC8341, March 2018,
              <https://www.rfc-editor.org/info/rfc8341>.

   [RFC8446]  Rescorla, E., "The Transport Layer Security (TLS) Protocol
              Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018,
              <https://www.rfc-editor.org/info/rfc8446>.

   [RFC9000]  Iyengar, J., Ed. and M. Thomson, Ed., "QUIC: A UDP-Based
              Multiplexed and Secure Transport", RFC 9000,
              DOI 10.17487/RFC9000, May 2021,
              <https://www.rfc-editor.org/info/rfc9000>.

   [RFC9640]  Watsen, K., "YANG Data Types and Groupings for
              Cryptography", RFC 9640, DOI 10.17487/RFC9640, October
              2024, <https://www.rfc-editor.org/info/rfc9640>.

7.2.  Informative References

   [HTTP-CLIENT-SERVER]
              Watsen, K., "YANG Groupings for HTTP Clients and HTTP
              Servers", Work in Progress, Internet-Draft, draft-ietf-
              netconf-http-client-server-23, 15 August 2024,
              <https://datatracker.ietf.org/doc/html/draft-ietf-netconf-
              http-client-server-23>.

   [NETCONF-CLIENT-SERVER]
              Watsen, K., "NETCONF Client and Server Models", Work in
              Progress, Internet-Draft, draft-ietf-netconf-netconf-
              client-server-37, 14 August 2024,
              <https://datatracker.ietf.org/doc/html/draft-ietf-netconf-
              netconf-client-server-37>.

   [NETMOD-SYSTEM-CONFIG]
              Ma, Q., Ed., Wu, Q., and C. Feng, "System-defined
              Configuration", Work in Progress, Internet-Draft, draft-
              ietf-netmod-system-config-09, 29 September 2024,
              <https://datatracker.ietf.org/doc/html/draft-ietf-netmod-
              system-config-09>.

   [RESTCONF-CLIENT-SERVER]
              Watsen, K., "RESTCONF Client and Server Models", Work in
              Progress, Internet-Draft, draft-ietf-netconf-restconf-
              client-server-38, 14 August 2024,
              <https://datatracker.ietf.org/doc/html/draft-ietf-netconf-
              restconf-client-server-38>.

   [RFC3688]  Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688,
              DOI 10.17487/RFC3688, January 2004,
              <https://www.rfc-editor.org/info/rfc3688>.

   [RFC8259]  Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
              Interchange Format", STD 90, RFC 8259,
              DOI 10.17487/RFC8259, December 2017,
              <https://www.rfc-editor.org/info/rfc8259>.

   [RFC8340]  Bjorklund, M. and L. Berger, Ed., "YANG Tree Diagrams",
              BCP 215, RFC 8340, DOI 10.17487/RFC8340, March 2018,
              <https://www.rfc-editor.org/info/rfc8340>.

   [RFC8342]  Bjorklund, M., Schoenwaelder, J., Shafer, P., Watsen, K.,
              and R. Wilton, "Network Management Datastore Architecture
              (NMDA)", RFC 8342, DOI 10.17487/RFC8342, March 2018,
              <https://www.rfc-editor.org/info/rfc8342>.

   [RFC8407]  Bierman, A., "Guidelines for Authors and Reviewers of
              Documents Containing YANG Data Models", BCP 216, RFC 8407,
              DOI 10.17487/RFC8407, October 2018,
              <https://www.rfc-editor.org/info/rfc8407>.

   [RFC8792]  Watsen, K., Auerswald, E., Farrel, A., and Q. Wu,
              "Handling Long Lines in Content of Internet-Drafts and
              RFCs", RFC 8792, DOI 10.17487/RFC8792, June 2020,
              <https://www.rfc-editor.org/info/rfc8792>.

   [RFC9641]  Watsen, K., "A YANG Data Model for a Truststore",
              RFC 9641, DOI 10.17487/RFC9641, October 2024,
              <https://www.rfc-editor.org/info/rfc9641>.

   [RFC9643]  Watsen, K. and M. Scharf, "YANG Groupings for TCP Clients
              and TCP Servers", RFC 9643, DOI 10.17487/RFC9643, October
              2024, <https://www.rfc-editor.org/info/rfc9643>.

   [RFC9644]  Watsen, K., "YANG Groupings for SSH Clients and SSH
              Servers", RFC 9644, DOI 10.17487/RFC9644, October 2024,
              <https://www.rfc-editor.org/info/rfc9644>.

   [RFC9645]  Watsen, K., "YANG Groupings for TLS Clients and TLS
              Servers", RFC 9645, DOI 10.17487/RFC9645, October 2024,
              <https://www.rfc-editor.org/info/rfc9645>.

   [Std-802.1AR-2018]
              IEEE, "IEEE Standard for Local and Metropolitan Area
              Networks - Secure Device Identity", IEEE Std 802.1AR-2018,
              DOI 10.1109/IEEESTD.2018.8423794, August 2018,
              <https://standards.ieee.org/standard/802_1AR-2018.html>.

   [W3C.REC-xml-20081126]
              Bray, T., Paoli, J., Sperberg-McQueen, C. M., Maler, E.,
              and F. Yergeau, "Extensible Markup Language (XML) 1.0
              (Fifth Edition)", W3C Recommendation REC-xml-20081126,
              November 2008, <https://www.w3.org/TR/xml/>.

Acknowledgements

   The authors would like to thank the following for lively discussions
   on list and in the halls (ordered by first name): Alan Luchuk, Andy
   Bierman, Balázs Kovács, Benoit Claise, Bert Wijnen, David Lamparter,
   Eric Voit, Éric Vyncke, Francesca Palombini, Jürgen Schönwälder,
   Ladislav Lhotka, Liang Xia, Magnus Nyström, Mahesh Jethanandani,
   Martin Björklund, Mehmet Ersue, Murray Kucherawy, Paul Wouters, Phil
   Shafer, Qin Wu, Radek Krejci, Ramkumar Dhanapal, Reese Enghardt,
   Reshad Rahman, Rob Wilton, Roman Danyliw, Sandra Murphy, Sean Turner,
   Tom Petch, Warren Kumari, and Zaheduzzaman Sarker.

Author's Address

   Kent Watsen
   Watsen Networks
   Email: kent+ietf@watsen.net