Clean up netconf-{common,client}-mdsal constants
[netconf.git] / model / draft-ietf-netconf-crypto-types / src / main / yang / ietf-crypto-types@2023-04-17.yang
1 module ietf-crypto-types {
2   yang-version 1.1;
3   namespace "urn:ietf:params:xml:ns:yang:ietf-crypto-types";
4   prefix ct;
5
6   import ietf-yang-types {
7     prefix yang;
8     reference
9       "RFC 6991: Common YANG Data Types";
10   }
11
12   import ietf-netconf-acm {
13     prefix nacm;
14     reference
15       "RFC 8341: Network Configuration Access Control Model";
16   }
17
18   organization
19     "IETF NETCONF (Network Configuration) Working Group";
20
21   contact
22     "WG Web:   https://datatracker.ietf.org/wg/netconf
23      WG List:  NETCONF WG list <mailto:netconf@ietf.org>
24      Author:   Kent Watsen <mailto:kent+ietf@watsen.net>";
25
26   description
27     "This module defines common YANG types for cryptographic
28      applications.
29
30      Copyright (c) 2023 IETF Trust and the persons identified
31      as authors of the code. All rights reserved.
32
33      Redistribution and use in source and binary forms, with
34      or without modification, is permitted pursuant to, and
35      subject to the license terms contained in, the Revised
36      BSD License set forth in Section 4.c of the IETF Trust's
37      Legal Provisions Relating to IETF Documents
38      (https://trustee.ietf.org/license-info).
39
40      This version of this YANG module is part of RFC AAAA
41      (https://www.rfc-editor.org/info/rfcAAAA); see the RFC
42      itself for full legal notices.
43
44      The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL',
45      'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED',
46      'NOT RECOMMENDED', 'MAY', and 'OPTIONAL' in this document
47      are to be interpreted as described in BCP 14 (RFC 2119)
48      (RFC 8174) when, and only when, they appear in all
49      capitals, as shown here.";
50
51   revision 2023-04-17 {
52     description
53       "Initial version";
54     reference
55       "RFC AAAA: YANG Data Types and Groupings for Cryptography";
56   }
57
58   /****************/
59   /*   Features   */
60   /****************/
61
62   feature one-symmetric-key-format {
63     description
64       "Indicates that the server supports the
65        'one-symmetric-key-format' identity.";
66   }
67
68   feature one-asymmetric-key-format {
69     description
70       "Indicates that the server supports the
71        'one-asymmetric-key-format' identity.";
72   }
73
74   feature symmetrically-encrypted-value-format {
75     description
76       "Indicates that the server supports the
77        'symmetrically-encrypted-value-format' identity.";
78   }
79
80   feature asymmetrically-encrypted-value-format {
81     description
82       "Indicates that the server supports the
83        'asymmetrically-encrypted-value-format' identity.";
84   }
85
86   feature cms-enveloped-data-format {
87     description
88       "Indicates that the server supports the
89        'cms-enveloped-data-format' identity.";
90   }
91
92   feature cms-encrypted-data-format {
93     description
94       "Indicates that the server supports the
95        'cms-encrypted-data-format' identity.";
96   }
97   feature p10-csr-format {
98     description
99       "Indicates that the server implements support
100        for generating P10-based CSRs, as defined
101        in RFC 2986.";
102     reference
103       "RFC 2986: PKCS #10: Certification Request Syntax
104                  Specification Version 1.7";
105   }
106
107   feature csr-generation {
108     description
109       "Indicates that the server implements the
110        'generate-csr' action.";
111   }
112
113   feature certificate-expiration-notification {
114     description
115       "Indicates that the server implements the
116        'certificate-expiration' notification.";
117   }
118
119   feature cleartext-passwords {
120     description
121       "Indicates that the server supports cleartext
122        passwords.";
123   }
124
125   feature encrypted-passwords {
126     description
127       "Indicates that the server supports password
128        encryption.";
129   }
130
131   feature cleartext-symmetric-keys {
132     description
133       "Indicates that the server supports cleartext
134        symmetric keys.";
135   }
136
137   feature hidden-symmetric-keys {
138     description
139       "Indicates that the server supports hidden keys.";
140   }
141
142   feature encrypted-symmetric-keys {
143     description
144       "Indicates that the server supports encryption
145        of symmetric keys.";
146   }
147
148   feature cleartext-private-keys {
149     description
150       "Indicates that the server supports cleartext
151        private keys.";
152   }
153
154   feature hidden-private-keys {
155     description
156       "Indicates that the server supports hidden keys.";
157   }
158
159   feature encrypted-private-keys {
160     description
161       "Indicates that the server supports encryption
162        of private keys.";
163   }
164
165   /*************************************************/
166   /*   Base Identities for Key Format Structures   */
167   /*************************************************/
168
169   identity symmetric-key-format {
170     description
171       "Base key-format identity for symmetric keys.";
172   }
173
174   identity public-key-format {
175     description
176       "Base key-format identity for public keys.";
177   }
178
179   identity private-key-format {
180     description
181       "Base key-format identity for private keys.";
182   }
183
184   /****************************************************/
185   /*   Identities for Private Key Format Structures   */
186   /****************************************************/
187
188   identity rsa-private-key-format {
189     base private-key-format;
190     description
191       "Indicates that the private key value is encoded as
192        an RSAPrivateKey (from RFC 3447), encoded using ASN.1
193        distinguished encoding rules (DER), as specified in
194        ITU-T X.690.";
195     reference
196       "RFC 3447:
197          PKCS #1: RSA Cryptography Specifications Version 2.2
198        ITU-T X.690:
199          Information technology - ASN.1 encoding rules:
200          Specification of Basic Encoding Rules (BER),
201          Canonical Encoding Rules (CER) and Distinguished
202          Encoding Rules (DER) 02/2021.";
203   }
204
205   identity ec-private-key-format {
206     base private-key-format;
207     description
208       "Indicates that the private key value is encoded as
209        an ECPrivateKey (from RFC 5915), encoded using ASN.1
210        distinguished encoding rules (DER), as specified in
211        ITU-T X.690.";
212     reference
213       "RFC 5915:
214          Elliptic Curve Private Key Structure
215        ITU-T X.690:
216          Information technology - ASN.1 encoding rules:
217          Specification of Basic Encoding Rules (BER),
218          Canonical Encoding Rules (CER) and Distinguished
219          Encoding Rules (DER) 02/2021.";
220   }
221
222   identity one-asymmetric-key-format {
223     if-feature "one-asymmetric-key-format";
224     base private-key-format;
225     description
226       "Indicates that the private key value is a CMS
227        OneAsymmetricKey structure, as defined in RFC 5958,
228        encoded using ASN.1 distinguished encoding rules
229        (DER), as specified in ITU-T X.690.";
230     reference
231       "RFC 5958: Asymmetric Key Packages
232        ITU-T X.690:
233          Information technology - ASN.1 encoding rules:
234          Specification of Basic Encoding Rules (BER),
235          Canonical Encoding Rules (CER) and Distinguished
236          Encoding Rules (DER) 02/2021.";
237   }
238
239   /***************************************************/
240   /*   Identities for Public Key Format Structures   */
241   /***************************************************/
242
243   identity ssh-public-key-format {
244     base public-key-format;
245     description
246       "Indicates that the public key value is an SSH public key,
247        as specified by RFC 4253, Section 6.6, i.e.:
248
249          string    certificate or public key format
250                    identifier
251          byte[n]   key/certificate data.";
252     reference
253       "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
254   }
255
256   identity subject-public-key-info-format {
257     base public-key-format;
258     description
259       "Indicates that the public key value is a SubjectPublicKeyInfo
260        structure, as described in RFC 5280 encoded using ASN.1
261        distinguished encoding rules (DER), as specified in
262        ITU-T X.690.";
263     reference
264       "RFC 5280:
265          Internet X.509 Public Key Infrastructure Certificate
266          and Certificate Revocation List (CRL) Profile
267        ITU-T X.690:
268          Information technology - ASN.1 encoding rules:
269          Specification of Basic Encoding Rules (BER),
270          Canonical Encoding Rules (CER) and Distinguished
271          Encoding Rules (DER) 02/2021.";
272   }
273
274   /******************************************************/
275   /*   Identities for Symmetric Key Format Structures   */
276   /******************************************************/
277
278   identity octet-string-key-format {
279     base symmetric-key-format;
280     description
281       "Indicates that the key is encoded as a raw octet string.
282        The length of the octet string MUST be appropriate for
283        the associated algorithm's block size.
284
285         The identity of the associated algorithm is outside the
286         scope of this specification.  This is also true when
287         the octet string has been encrypted.";
288   }
289   identity one-symmetric-key-format {
290     if-feature "one-symmetric-key-format";
291     base symmetric-key-format;
292     description
293       "Indicates that the private key value is a CMS
294        OneSymmetricKey structure, as defined in RFC 6031,
295        encoded using ASN.1 distinguished encoding rules
296        (DER), as specified in ITU-T X.690.";
297     reference
298       "RFC 6031: Cryptographic Message Syntax (CMS)
299                  Symmetric Key Package Content Type
300        ITU-T X.690:
301          Information technology - ASN.1 encoding rules:
302          Specification of Basic Encoding Rules (BER),
303          Canonical Encoding Rules (CER) and Distinguished
304          Encoding Rules (DER) 02/2021.";
305   }
306
307   /*************************************************/
308   /*   Identities for Encrypted Value Structures   */
309   /*************************************************/
310
311   identity encrypted-value-format {
312     description
313       "Base format identity for encrypted values.";
314   }
315
316   identity symmetrically-encrypted-value-format {
317     if-feature "symmetrically-encrypted-value-format";
318     base encrypted-value-format;
319     description
320       "Base format identity for symmetrically encrypted
321        values.";
322   }
323
324   identity asymmetrically-encrypted-value-format {
325     if-feature "asymmetrically-encrypted-value-format";
326     base encrypted-value-format;
327     description
328       "Base format identity for asymmetrically encrypted
329        values.";
330   }
331
332   identity cms-encrypted-data-format {
333     if-feature "cms-encrypted-data-format";
334     base symmetrically-encrypted-value-format;
335     description
336       "Indicates that the encrypted value conforms to
337        the 'encrypted-data-cms' type with the constraint
338        that the 'unprotectedAttrs' value is not set.";
339     reference
340       "RFC 5652: Cryptographic Message Syntax (CMS)
341        ITU-T X.690:
342          Information technology - ASN.1 encoding rules:
343          Specification of Basic Encoding Rules (BER),
344          Canonical Encoding Rules (CER) and Distinguished
345          Encoding Rules (DER) 02/2021.";
346   }
347
348   identity cms-enveloped-data-format {
349     if-feature "cms-enveloped-data-format";
350     base asymmetrically-encrypted-value-format;
351     description
352       "Indicates that the encrypted value conforms to the
353        'enveloped-data-cms' type with the following constraints:
354
355        The EnvelopedData structure MUST have exactly one
356        'RecipientInfo'.
357
358        If the asymmetric key supports public key cryptography
359        (e.g., RSA), then the 'RecipientInfo' must be a
360        'KeyTransRecipientInfo' with the 'RecipientIdentifier'
361        using a 'subjectKeyIdentifier' with the value set using
362        'method 1' in RFC 7093 over the recipient's public key.
363
364        Otherwise, if the asymmetric key supports key agreement
365        (e.g., ECC), then the 'RecipientInfo' must be a
366        'KeyAgreeRecipientInfo'.  The 'OriginatorIdentifierOrKey'
367        value must use the 'OriginatorPublicKey' alternative.
368        The 'UserKeyingMaterial' value must not be present.
369        There must be exactly one 'RecipientEncryptedKeys' value
370        having the 'KeyAgreeRecipientIdentifier' set to 'rKeyId'
371        with the value set using 'method 1' in RFC 7093 over the
372        recipient's public key.";
373     reference
374       "RFC 5652: Cryptographic Message Syntax (CMS)
375        RFC 7093:
376          Additional Methods for Generating Key
377          Identifiers Values
378        ITU-T X.690:
379          Information technology - ASN.1 encoding rules:
380          Specification of Basic Encoding Rules (BER),
381          Canonical Encoding Rules (CER) and Distinguished
382          Encoding Rules (DER) 02/2021.";
383   }
384
385   /*********************************************************/
386   /*   Identities for Certificate Signing Request Formats  */
387   /*********************************************************/
388
389   identity csr-format {
390     description
391       "A base identity for the certificate signing request
392        formats.  Additional derived identities MAY be defined
393        by future efforts.";
394   }
395
396   identity p10-csr-format {
397     if-feature "p10-csr-format";
398     base csr-format;
399     description
400       "Indicates the 'CertificationRequest' structure
401        defined in RFC 2986.";
402     reference
403       "RFC 2986: PKCS #10: Certification Request Syntax
404                  Specification Version 1.7";
405   }
406
407   /***************************************************/
408   /*   Typedefs for ASN.1 structures from RFC 2986   */
409   /***************************************************/
410
411   typedef csr-info {
412     type binary;
413     description
414       "A CertificationRequestInfo structure, as defined in
415        RFC 2986, encoded using ASN.1 distinguished encoding
416        rules (DER), as specified in ITU-T X.690.";
417     reference
418       "RFC 2986: PKCS #10: Certification Request Syntax
419                  Specification Version 1.7
420        ITU-T X.690:
421          Information technology - ASN.1 encoding rules:
422          Specification of Basic Encoding Rules (BER),
423          Canonical Encoding Rules (CER) and Distinguished
424          Encoding Rules (DER) 02/2021.";
425   }
426
427   typedef p10-csr {
428     type binary;
429     description
430       "A CertificationRequest structure, as specified in
431        RFC 2986, encoded using ASN.1 distinguished encoding
432        rules (DER), as specified in ITU-T X.690.";
433     reference
434       "RFC 2986:
435          PKCS #10: Certification Request Syntax Specification
436          Version 1.7
437        ITU-T X.690:
438          Information technology - ASN.1 encoding rules:
439          Specification of Basic Encoding Rules (BER),
440          Canonical Encoding Rules (CER) and Distinguished
441          Encoding Rules (DER) 02/2021.";
442   }
443
444   /***************************************************/
445   /*   Typedefs for ASN.1 structures from RFC 5280   */
446   /***************************************************/
447
448   typedef x509 {
449     type binary;
450     description
451       "A Certificate structure, as specified in RFC 5280,
452        encoded using ASN.1 distinguished encoding rules (DER),
453        as specified in ITU-T X.690.";
454     reference
455       "RFC 5280:
456          Internet X.509 Public Key Infrastructure Certificate
457          and Certificate Revocation List (CRL) Profile
458        ITU-T X.690:
459          Information technology - ASN.1 encoding rules:
460          Specification of Basic Encoding Rules (BER),
461          Canonical Encoding Rules (CER) and Distinguished
462          Encoding Rules (DER) 02/2021.";
463   }
464
465   typedef crl {
466     type binary;
467     description
468       "A CertificateList structure, as specified in RFC 5280,
469        encoded using ASN.1 distinguished encoding rules (DER),
470        as specified in ITU-T X.690.";
471     reference
472       "RFC 5280:
473          Internet X.509 Public Key Infrastructure Certificate
474          and Certificate Revocation List (CRL) Profile
475        ITU-T X.690:
476          Information technology - ASN.1 encoding rules:
477          Specification of Basic Encoding Rules (BER),
478          Canonical Encoding Rules (CER) and Distinguished
479          Encoding Rules (DER) 02/2021.";
480   }
481
482   /***************************************************/
483   /*   Typedefs for ASN.1 structures from RFC 6960   */
484   /***************************************************/
485
486   typedef oscp-request {
487     type binary;
488     description
489       "A OCSPRequest structure, as specified in RFC 6960,
490        encoded using ASN.1 distinguished encoding rules
491        (DER), as specified in ITU-T X.690.";
492     reference
493       "RFC 6960:
494          X.509 Internet Public Key Infrastructure Online
495          Certificate Status Protocol - OCSP
496        ITU-T X.690:
497          Information technology - ASN.1 encoding rules:
498          Specification of Basic Encoding Rules (BER),
499          Canonical Encoding Rules (CER) and Distinguished
500          Encoding Rules (DER) 02/2021.";
501   }
502
503   typedef oscp-response {
504     type binary;
505     description
506       "A OCSPResponse structure, as specified in RFC 6960,
507        encoded using ASN.1 distinguished encoding rules
508        (DER), as specified in ITU-T X.690.";
509     reference
510       "RFC 6960:
511          X.509 Internet Public Key Infrastructure Online
512          Certificate Status Protocol - OCSP
513        ITU-T X.690:
514          Information technology - ASN.1 encoding rules:
515          Specification of Basic Encoding Rules (BER),
516          Canonical Encoding Rules (CER) and Distinguished
517          Encoding Rules (DER) 02/2021.";
518   }
519
520   /***********************************************/
521   /*   Typedefs for ASN.1 structures from 5652   */
522   /***********************************************/
523
524   typedef cms {
525     type binary;
526     description
527       "A ContentInfo structure, as specified in RFC 5652,
528        encoded using ASN.1 distinguished encoding rules (DER),
529        as specified in ITU-T X.690.";
530     reference
531       "RFC 5652:
532          Cryptographic Message Syntax (CMS)
533        ITU-T X.690:
534          Information technology - ASN.1 encoding rules:
535          Specification of Basic Encoding Rules (BER),
536          Canonical Encoding Rules (CER) and Distinguished
537          Encoding Rules (DER) 02/2021.";
538   }
539
540   typedef data-content-cms {
541     type cms;
542     description
543       "A CMS structure whose top-most content type MUST be the
544        data content type, as described by Section 4 in RFC 5652.";
545     reference
546       "RFC 5652: Cryptographic Message Syntax (CMS)";
547   }
548
549   typedef signed-data-cms {
550     type cms;
551     description
552       "A CMS structure whose top-most content type MUST be the
553        signed-data content type, as described by Section 5 in
554        RFC 5652.";
555     reference
556       "RFC 5652: Cryptographic Message Syntax (CMS)";
557   }
558
559   typedef enveloped-data-cms {
560     type cms;
561     description
562       "A CMS structure whose top-most content type MUST be the
563        enveloped-data content type, as described by Section 6
564        in RFC 5652.";
565     reference
566       "RFC 5652: Cryptographic Message Syntax (CMS)";
567   }
568
569   typedef digested-data-cms {
570     type cms;
571     description
572       "A CMS structure whose top-most content type MUST be the
573        digested-data content type, as described by Section 7
574        in RFC 5652.";
575     reference
576       "RFC 5652: Cryptographic Message Syntax (CMS)";
577   }
578
579   typedef encrypted-data-cms {
580     type cms;
581     description
582       "A CMS structure whose top-most content type MUST be the
583        encrypted-data content type, as described by Section 8
584        in RFC 5652.";
585     reference
586       "RFC 5652: Cryptographic Message Syntax (CMS)";
587   }
588
589   typedef authenticated-data-cms {
590     type cms;
591     description
592       "A CMS structure whose top-most content type MUST be the
593        authenticated-data content type, as described by Section 9
594        in RFC 5652.";
595     reference
596       "RFC 5652: Cryptographic Message Syntax (CMS)";
597   }
598
599   /*********************************************************/
600   /*   Typedefs for ASN.1 structures related to RFC 5280   */
601   /*********************************************************/
602
603   typedef trust-anchor-cert-x509 {
604     type x509;
605     description
606       "A Certificate structure that MUST encode a self-signed
607        root certificate.";
608   }
609
610   typedef end-entity-cert-x509 {
611     type x509;
612     description
613       "A Certificate structure that MUST encode a certificate
614        that is neither self-signed nor having Basic constraint
615        CA true.";
616   }
617
618   /*********************************************************/
619   /*   Typedefs for ASN.1 structures related to RFC 5652   */
620   /*********************************************************/
621
622   typedef trust-anchor-cert-cms {
623     type signed-data-cms;
624     description
625       "A CMS SignedData structure that MUST contain the chain of
626        X.509 certificates needed to authenticate the certificate
627        presented by a client or end-entity.
628
629        The CMS MUST contain only a single chain of certificates.
630        The client or end-entity certificate MUST only authenticate
631        to the last intermediate CA certificate listed in the chain.
632
633        In all cases, the chain MUST include a self-signed root
634        certificate.  In the case where the root certificate is
635        itself the issuer of the client or end-entity certificate,
636        only one certificate is present.
637
638        This CMS structure MAY (as applicable where this type is
639        used) also contain suitably fresh (as defined by local
640        policy) revocation objects with which the device can
641        verify the revocation status of the certificates.
642
643        This CMS encodes the degenerate form of the SignedData
644        structure (RFC 5652, Section 5.2) that is commonly used
645        to disseminate X.509 certificates and revocation objects
646        (RFC 5280).";
647     reference
648       "RFC 5280:
649          Internet X.509 Public Key Infrastructure Certificate
650          and Certificate Revocation List (CRL) Profile.
651        RFC 5652:
652          Cryptographic Message Syntax (CMS)";
653   }
654
655   typedef end-entity-cert-cms {
656     type signed-data-cms;
657     description
658       "A CMS SignedData structure that MUST contain the end
659        entity certificate itself, and MAY contain any number
660        of intermediate certificates leading up to a trust
661        anchor certificate.  The trust anchor certificate
662        MAY be included as well.
663
664        The CMS MUST contain a single end entity certificate.
665        The CMS MUST NOT contain any spurious certificates.
666
667        This CMS structure MAY (as applicable where this type is
668        used) also contain suitably fresh (as defined by local
669        policy) revocation objects with which the device can
670        verify the revocation status of the certificates.
671
672        This CMS encodes the degenerate form of the SignedData
673        structure (RFC 5652, Section 5.2) that is commonly
674        used to disseminate X.509 certificates and revocation
675        objects (RFC 5280).";
676
677     reference
678       "RFC 5280:
679          Internet X.509 Public Key Infrastructure Certificate
680          and Certificate Revocation List (CRL) Profile.
681        RFC 5652:
682          Cryptographic Message Syntax (CMS)";
683   }
684
685   /*****************/
686   /*   Groupings   */
687   /*****************/
688
689   grouping encrypted-value-grouping {
690     description
691       "A reusable grouping for a value that has been encrypted by
692        a referenced symmetric or asymmetric key.";
693     container encrypted-by {
694       nacm:default-deny-write;
695       description
696         "An empty container enabling a reference to the key that
697          encrypted the value to be augmented in.  The referenced
698          key MUST be a symmetric key or an asymmetric key.
699
700          A symmetric key MUST be referenced via a leaf node called
701          'symmetric-key-ref'.  An asymmetric key MUST be referenced
702          via a leaf node called 'asymmetric-key-ref'.
703
704          The leaf nodes MUST be direct descendants in the data tree,
705          and MAY be direct descendants in the schema tree (e.g.,
706          choice/case statements are allowed, but not a container).";
707     }
708     leaf encrypted-value-format {
709       type identityref {
710         base encrypted-value-format;
711       }
712       mandatory true;
713       description
714         "Identifies the format of the 'encrypted-value' leaf.
715
716          If 'encrypted-by' points to a symmetric key, then a
717          'symmetrically-encrypted-value-format' based identity
718          MUST by set (e.g., cms-encrypted-data-format).
719
720          If 'encrypted-by' points to an asymmetric key, then an
721          'asymmetrically-encrypted-value-format' based identity
722          MUST by set (e.g., cms-enveloped-data-format).";
723     }
724     leaf encrypted-value {
725       nacm:default-deny-write;
726       type binary;
727       must '../encrypted-by';
728       mandatory true;
729       description
730         "The value, encrypted using the referenced symmetric
731          or asymmetric key.  The value MUST be encoded using
732          the format associated with the 'encrypted-value-format'
733          leaf.";
734     }
735   }
736
737   grouping password-grouping {
738     description
739       "A password that may be encrypted.";
740     choice password-type {
741       nacm:default-deny-write;
742       mandatory true;
743       description
744         "Choice between password types.";
745       case cleartext-password {
746         if-feature "cleartext-passwords";
747         leaf cleartext-password {
748           nacm:default-deny-all;
749           type string;
750           description
751             "The cleartext value of the password.";
752         }
753       }
754       case encrypted-password {
755         if-feature "encrypted-passwords";
756         container encrypted-password {
757           description
758             "A container for the encrypted password value.";
759           uses encrypted-value-grouping;
760         }
761       }
762     }
763   }
764
765   grouping symmetric-key-grouping {
766     description
767       "A symmetric key.";
768     leaf key-format {
769       nacm:default-deny-write;
770       type identityref {
771         base symmetric-key-format;
772       }
773       description
774         "Identifies the symmetric key's format.  Implementations
775          SHOULD ensure that the incoming symmetric key value is
776          encoded in the specified format.
777
778          For encrypted keys, the value is the decrypted key's
779          format (i.e., the 'encrypted-value-format' conveys the
780          encrypted key's format.";
781     }
782     choice key-type {
783       nacm:default-deny-write;
784       mandatory true;
785       description
786         "Choice between key types.";
787       case cleartext-key {
788         leaf cleartext-key {
789           if-feature "cleartext-symmetric-keys";
790           nacm:default-deny-all;
791           type binary;
792           must '../key-format';
793           description
794             "The binary value of the key.  The interpretation of
795              the value is defined by the 'key-format' field.";
796         }
797       }
798       case hidden-key {
799         if-feature "hidden-symmetric-keys";
800         leaf hidden-key {
801           type empty;
802           must 'not(../key-format)';
803           description
804             "A hidden key.  How such keys are created is outside
805              the scope of this module.";
806         }
807       }
808       case encrypted-key {
809         if-feature "encrypted-symmetric-keys";
810         container encrypted-key {
811           must '../key-format';
812           description
813             "A container for the encrypted symmetric key value.
814              The interpretation of the 'encrypted-value' node
815              is via the 'key-format' node";
816           uses encrypted-value-grouping;
817         }
818       }
819     }
820   }
821
822   grouping public-key-grouping {
823     description
824       "A public key.";
825     leaf public-key-format {
826       nacm:default-deny-write;
827       type identityref {
828         base public-key-format;
829       }
830       mandatory true;
831       description
832         "Identifies the public key's format. Implementations SHOULD
833          ensure that the incoming public key value is encoded in the
834          specified format.";
835     }
836     leaf public-key {
837       nacm:default-deny-write;
838       type binary;
839       mandatory true;
840       description
841         "The binary value of the public key.  The interpretation
842          of the value is defined by 'public-key-format' field.";
843     }
844   }
845
846   grouping asymmetric-key-pair-grouping {
847     description
848       "A private key and its associated public key.  Implementations
849        SHOULD ensure that the two keys are a matching pair.";
850     uses public-key-grouping;
851     leaf private-key-format {
852       nacm:default-deny-write;
853       type identityref {
854         base private-key-format;
855       }
856       description
857         "Identifies the private key's format.  Implementations SHOULD
858          ensure that the incoming private key value is encoded in the
859          specified format.
860
861          For encrypted keys, the value is the decrypted key's
862          format (i.e., the 'encrypted-value-format' conveys the
863          encrypted key's format.";
864     }
865     choice private-key-type {
866       nacm:default-deny-write;
867       mandatory true;
868       description
869         "Choice between key types.";
870       case cleartext-private-key {
871         if-feature "cleartext-private-keys";
872         leaf cleartext-private-key {
873           nacm:default-deny-all;
874           type binary;
875           must '../private-key-format';
876           description
877             "The value of the binary key  The key's value is
878              interpreted by the 'private-key-format' field.";
879         }
880       }
881       case hidden-private-key {
882         if-feature "hidden-private-keys";
883         leaf hidden-private-key {
884           type empty;
885           must 'not(../private-key-format)';
886           description
887             "A hidden key.  How such keys are created is
888              outside the scope of this module.";
889         }
890       }
891       case encrypted-private-key {
892         if-feature "encrypted-private-keys";
893         container encrypted-private-key {
894           must '../private-key-format';
895           description
896             "A container for the encrypted asymmetric private key
897              value.  The interpretation of the 'encrypted-value'
898              node is via the 'private-key-format' node";
899           uses encrypted-value-grouping;
900         }
901       }
902     }
903   }
904
905   grouping certificate-expiration-grouping {
906     description
907       "A notification for when a certificate is about to, or
908        already has, expired.";
909     notification certificate-expiration {
910       if-feature "certificate-expiration-notification";
911       description
912         "A notification indicating that the configured certificate
913          is either about to expire or has already expired.  When to
914          send notifications is an implementation specific decision,
915          but it is RECOMMENDED that a notification be sent once a
916          month for 3 months, then once a week for four weeks, and
917          then once a day thereafter until the issue is resolved.";
918       leaf expiration-date {
919         type yang:date-and-time;
920         mandatory true;
921         description
922           "Identifies the expiration date on the certificate.";
923       }
924     }
925   }
926
927   grouping trust-anchor-cert-grouping {
928     description
929       "A trust anchor certificate, and a notification for when
930        it is about to (or already has) expire.";
931     leaf cert-data {
932       nacm:default-deny-write;
933       type trust-anchor-cert-cms;
934       description
935         "The binary certificate data for this certificate.";
936     }
937     uses certificate-expiration-grouping;
938   }
939
940   grouping end-entity-cert-grouping {
941     description
942       "An end entity certificate, and a notification for when
943        it is about to (or already has) expire.  Implementations
944        SHOULD assert that, where used, the end entity certificate
945        contains the expected public key.";
946     leaf cert-data {
947       nacm:default-deny-write;
948       type end-entity-cert-cms;
949       description
950         "The binary certificate data for this certificate.";
951     }
952     uses certificate-expiration-grouping;
953   }
954
955   grouping generate-csr-grouping {
956     description
957       "Defines the 'generate-csr' action.";
958     action generate-csr {
959       if-feature "csr-generation";
960       nacm:default-deny-all;
961       description
962         "Generates a certificate signing request structure for
963          the associated asymmetric key using the passed subject
964          and attribute values.
965
966          This action statement is only available when the
967          associated 'public-key-format' node's value is
968          'subject-public-key-info-format'.";
969       reference
970         "RFC 6125:
971           Representation and Verification of Domain-Based
972           Application Service Identity within Internet Public Key
973           Infrastructure Using X.509 (PKIX) Certificates in the
974           Context of Transport Layer Security (TLS)";
975       input {
976         leaf csr-format {
977           type identityref {
978             base csr-format;
979           }
980           mandatory true;
981           description
982             "Specifies the format for the returned certificate.";
983         }
984         leaf csr-info {
985           type csr-info;
986           mandatory true;
987           description
988             "A CertificationRequestInfo structure, as defined in
989              RFC 2986.
990
991              Enables the client to provide a fully-populated
992              CertificationRequestInfo structure that the server
993              only needs to sign in order to generate the complete
994              'CertificationRequest' structure to return in the
995              'output'.
996
997              The 'AlgorithmIdentifier' field contained inside
998              the 'SubjectPublicKeyInfo' field MUST be one known
999              to be supported by the device.";
1000           reference
1001             "RFC 2986:
1002                PKCS #10: Certification Request Syntax Specification
1003              RFC AAAA:
1004                YANG Data Types and Groupings for Cryptography";
1005         }
1006       }
1007       output {
1008         choice csr-type {
1009           mandatory true;
1010           description
1011             "A choice amongst certificate signing request formats.
1012              Additional formats MAY be augmented into this 'choice'
1013              statement by future efforts.";
1014           case p10-csr {
1015             leaf p10-csr {
1016               type p10-csr;
1017               description
1018                 "A CertificationRequest, as defined in RFC 2986.";
1019             }
1020             description
1021               "A CertificationRequest, as defined in RFC 2986.";
1022             reference
1023               "RFC 2986:
1024                  PKCS #10: Certification Request Syntax Specification
1025                RFC AAAA:
1026                  YANG Data Types and Groupings for Cryptography";
1027           }
1028         }
1029       }
1030     }
1031   } // generate-csr-grouping
1032
1033   grouping asymmetric-key-pair-with-cert-grouping {
1034     description
1035       "A private/public key pair and an associated certificate.
1036        Implementations SHOULD assert that the certificate contains
1037        the matching public key.";
1038     uses asymmetric-key-pair-grouping;
1039     uses end-entity-cert-grouping;
1040     uses generate-csr-grouping;
1041   } // asymmetric-key-pair-with-cert-grouping
1042
1043   grouping asymmetric-key-pair-with-certs-grouping {
1044     description
1045       "A private/public key pair and a list of associated
1046        certificates.  Implementations SHOULD assert that
1047        certificates contain the matching public key.";
1048     uses asymmetric-key-pair-grouping;
1049     container certificates {
1050       nacm:default-deny-write;
1051       description
1052         "Certificates associated with this asymmetric key.";
1053       list certificate {
1054         key "name";
1055         description
1056           "A certificate for this asymmetric key.";
1057         leaf name {
1058           type string;
1059           description
1060             "An arbitrary name for the certificate.";
1061         }
1062         uses end-entity-cert-grouping {
1063           refine "cert-data" {
1064             mandatory true;
1065           }
1066         }
1067       }
1068     }
1069     uses generate-csr-grouping;
1070   } // asymmetric-key-pair-with-certs-grouping
1071
1072 }