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