Enforce base64 encoding for netconf-keystore
[netconf.git] / keystore / keystore-legacy / src / main / yang / netconf-keystore.yang
1 module netconf-keystore {
2     namespace "urn:opendaylight:netconf:keystore";
3     prefix "keystore";
4
5     revision "2023-11-09" {
6         description "Using binary type instead of string for base64 leafs.";
7     }
8
9     revision "2017-10-17" {
10         description "Initial revision of the Netconf SBP keystore.";
11     }
12
13     description "Store used for key based Credentials for Netconf SBP. Before a connector with key based authentication
14                  is created it needs to have a record for the key pair it uses. All the records here need to be
15                  encrypted as they contain sensitive data. Therefore NEVER do direct writes and only use the provided
16                  RPCs for adding/removing key entries.";
17
18     grouping keystore-entry {
19         list key-credential {
20             key key-id;
21
22             leaf key-id {
23                 type string;
24             }
25
26             leaf private-key {
27                 description "Binary array of Base64 encoded private key that should be used for authentication with a
28                              netconf device. Do not include a public key as that is calculated from the private key.
29                              Used for writing directly into the data store, encrypted key expected.";
30                 type binary;
31             }
32
33             leaf passphrase {
34                 description "If the provided key is encrypted by a passphrase this needs to be included. Leave empty
35                              if the key does not have a passphrase.
36                              Used for writing directly into the data store, encrypted passphrase expected.";
37                 type binary;
38             }
39         }
40     }
41
42     grouping rpc-keystore-entry {
43         list key-credential {
44             key key-id;
45
46             leaf key-id {
47                 type string;
48             }
49
50             leaf private-key {
51                 description "Base64 encoded private key that should be used for authentication with a netconf device.
52                              Do not include a public key as that is calculated from the private key.
53                              Used for RPCs only. Will encrypt the key before the entry is written into the data store.";
54                 type string;
55             }
56
57             leaf passphrase {
58                 description "If the provided key is encrypted by a passphrase this needs to be included. Leave empty
59                              if the key does not have a passphrase.
60                              Used for RPCs only. Will encrypt the passphrase before the entry is written into the data
61                              store.";
62                 type string;
63             }
64         }
65     }
66
67     grouping private-keys {
68         list private-key {
69             key name;
70             description "A private key.";
71             leaf name {
72                 type string;
73             }
74             leaf data {
75                 description "Binary array of Base64 encoded private key.";
76                 type binary;
77             }
78             leaf-list certificate-chain {
79                 description "A certificate chain for this public key. Each certificate is an X.509 v3 certificate
80                              structure as specified by RFC5280, binary data encoded using the Base64 format.";
81                 type binary;
82                 ordered-by user;
83             }
84         }
85     }
86
87     grouping rpc-private-keys {
88         list private-key {
89             key name;
90             description "A private key.";
91             leaf name {
92                 type string;
93             }
94             leaf data {
95                 description "Base64 encoded private key.";
96                 type string;
97             }
98             leaf-list certificate-chain {
99                 description "A certificate chain for this public key. Each certificate is an X.509 v3 certificate
100                              structure as specified by RFC5280, encoded using the Base64 format.";
101                 type string;
102                 ordered-by user;
103             }
104         }
105     }
106
107     grouping trusted-certificates {
108         list trusted-certificate {
109             key name;
110             description "A list of trusted certificate. These certificates can be used by a server to authenticate
111                          clients, or by clients to authenticate servers.";
112             leaf name {
113                 type string;
114             }
115             leaf certificate {
116                 description "An X.509 v3 certificate structure as specified by RFC5280, binary data encoded using
117                              the Base64 format.";
118                 type binary;
119             }
120         }
121     }
122
123     grouping rpc-trusted-certificates {
124         list trusted-certificate {
125             key name;
126             description "A list of trusted certificate. These certificates can be used by a server to authenticate
127                          clients, or by clients to authenticate servers.";
128             leaf name {
129                 type string;
130             }
131             leaf certificate {
132                 description "An X.509 v3 certificate structure as specified by RFC5280, encoded using
133                              the Base64 format.";
134                 type string;
135           }
136         }
137     }
138
139     container keystore {
140         uses keystore-entry;
141         uses private-keys;
142         uses trusted-certificates;
143     }
144
145     rpc add-keystore-entry {
146         description "Use this rpc to add a single or multiple new keys into the keystore. The private key and passphrase
147                      will both be encrypted before they are written into the data store.";
148         input {
149             uses rpc-keystore-entry;
150         }
151     }
152
153     rpc remove-keystore-entry {
154         description "Use this rpc to remove a single or multiple keys from the data store.";
155         input {
156             leaf-list key-id {
157                 type string;
158             }
159         }
160     }
161
162     rpc add-private-key {
163         description "Add a list of private keys into the keystore.";
164         input {
165             uses rpc-private-keys;
166         }
167     }
168
169     rpc remove-private-key {
170         description "Remove a list of private keys from the data store.";
171         input {
172             leaf-list name {
173                 type string;
174             }
175         }
176     }
177
178     rpc add-trusted-certificate {
179         description "Add a list of trusted certificates into the keystore.";
180         input {
181             uses rpc-trusted-certificates;
182         }
183     }
184
185     rpc remove-trusted-certificate {
186         description "Remove a list of trusted certificates from the data store.";
187         input {
188             leaf-list name {
189                 type string;
190             }
191         }
192     }
193 }