NETCONF Working Group K. Watsen
Internet-Draft Watsen Networks
Intended status: Standards Track May 20, 2020
Expires: November 21, 2020

Common YANG Data Types for Cryptography
draft-ietf-netconf-crypto-types-15

Abstract

This document presents a YANG 1.1 (RFC 7950) module defining identities, typedefs, and groupings useful to cryptographic applications.

Editorial Note (To be removed by RFC Editor)

This draft contains placeholder values that need to be replaced with finalized values at the time of publication. This note summarizes all of the substitutions that are needed. No other RFC Editor instructions are specified elsewhere in this document.

Artwork in this document contains shorthand references to drafts in progress. Please apply the following replacements:

Artwork in this document contains placeholder values for the date of publication of this draft. Please apply the following replacement:

The following Appendix section is to be removed prior to publication:

Note to Reviewers (To be removed by RFC Editor)

This document presents a YANG module or modules that is/are part of a collection of drafts that work together to produce the ultimate goal of the NETCONF WG: to define configuration modules for NETCONF client and servers, and RESTCONF client and servers.

The relationship between the various drafts in the collection is presented in the below diagram.

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

Full draft names and link to drafts:

Status of This Memo

This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.

Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at https://datatracker.ietf.org/drafts/current/.

Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."

This Internet-Draft will expire on November 21, 2020.

Copyright Notice

Copyright (c) 2020 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 Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.


Table of Contents

1. Introduction

This document presents a YANG 1.1 [RFC7950] module defining identities, typedefs, and groupings useful to cryptographic applications.

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.

2. The Crypto Types Module

2.1. Tree Diagram

This section provides a tree diagram [RFC8340] for the "ietf-crypto-types" module. Only "grouping" statements are represented, as tree diagrams have no means to represent identities or typedefs.

module: ietf-crypto-types

  grouping symmetric-key-grouping
    +-- key-format?         identityref
    +-- (key-type)
       +--:(key)
       |  +-- key?          binary
       +--:(hidden-key)
          +-- hidden-key?   empty
  grouping public-key-grouping
    +-- public-key-format    identityref
    +-- public-key           binary
  grouping asymmetric-key-pair-grouping
    +-- public-key-format           identityref
    +-- public-key                  binary
    +-- private-key-format?         identityref
    +-- (private-key-type)
       +--:(private-key)
       |  +-- private-key?          binary
       +--:(hidden-private-key)
          +-- hidden-private-key?   empty
  grouping trust-anchor-cert-grouping
    +-- cert?                     trust-anchor-cert-cms
    +---n certificate-expiration
       +-- expiration-date    yang:date-and-time
  grouping trust-anchor-certs-grouping
    +-- cert*                     trust-anchor-cert-cms
    +---n certificate-expiration
       +-- expiration-date    yang:date-and-time
  grouping end-entity-cert-grouping
    +-- cert?                     end-entity-cert-cms
    +---n certificate-expiration
       +-- expiration-date    yang:date-and-time
  grouping end-entity-certs-grouping
    +-- cert*                     end-entity-cert-cms
    +---n certificate-expiration
       +-- expiration-date    yang:date-and-time
  grouping generate-csr-grouping
    +---x generate-certificate-signing-request
            {certificate-signing-request-generation}?
       +---w input
       |  +---w subject       binary
       |  +---w attributes?   binary
       +--ro output
          +--ro certificate-signing-request    ct:csr
  grouping asymmetric-key-pair-with-cert-grouping
    +-- public-key-format                       identityref
    +-- public-key                              binary
    +-- private-key-format?                     identityref
    +-- (private-key-type)
    |  +--:(private-key)
    |  |  +-- private-key?                      binary
    |  +--:(hidden-private-key)
    |     +-- hidden-private-key?               empty
    +-- cert?                                   end-entity-cert-cms
    +---n certificate-expiration
    |  +-- expiration-date    yang:date-and-time
    +---x generate-certificate-signing-request
            {certificate-signing-request-generation}?
       +---w input
       |  +---w subject       binary
       |  +---w attributes?   binary
       +--ro output
          +--ro certificate-signing-request    ct:csr
  grouping asymmetric-key-pair-with-certs-grouping
    +-- public-key-format                       identityref
    +-- public-key                              binary
    +-- private-key-format?                     identityref
    +-- (private-key-type)
    |  +--:(private-key)
    |  |  +-- private-key?                      binary
    |  +--:(hidden-private-key)
    |     +-- hidden-private-key?               empty
    +-- certificates
    |  +-- certificate* [name]
    |     +-- name?                     string
    |     +-- cert                      end-entity-cert-cms
    |     +---n certificate-expiration
    |        +-- expiration-date    yang:date-and-time
    +---x generate-certificate-signing-request
            {certificate-signing-request-generation}?
       +---w input
       |  +---w subject       binary
       |  +---w attributes?   binary
       +--ro output
          +--ro certificate-signing-request    ct:csr

2.2. YANG Module

This module has normative references to [RFC2119], [RFC2986], [RFC3447], [RFC4253], [RFC5280], [RFC5652], [RFC5915], [RFC5958], [RFC6031], [RFC6125], [RFC6991], [RFC8174], [RFC8341], and [ITU.X690.2015].

<CODE BEGINS> file "ietf-crypto-types@2020-05-20.yang"

module ietf-crypto-types {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-crypto-types";
  prefix ct;

  import ietf-yang-types {
    prefix yang;
    reference
      "RFC 6991: Common YANG Data Types";
  }

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

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

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

  description
    "This module defines common YANG types for cryptographic
     applications.

     Copyright (c) 2020 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 Simplified
     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 AAAA
     (https://www.rfc-editor.org/info/rfcAAAA); see the RFC
     itself for full legal notices.

     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.";

  revision 2020-05-20 {
    description
      "Initial version";
    reference
      "RFC AAAA: Common YANG Data Types for Cryptography";
  }


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

  feature one-asymmetric-key-format {
    description
      "Indicates that the server supports the
       'one-asymmetric-key-format' identity.";
  }

  feature one-symmetric-key-format {
    description
      "Indicates that the server supports the
       'one-symmetric-key-format' identity.";
  }

  feature encrypted-one-symmetric-key-format {
    description
      "Indicates that the server supports the
       'encrypted-one-symmetric-key-format' identity.";
  }

  feature encrypted-one-asymmetric-key-format {
    description
      "Indicates that the server supports the
       'encrypted-one-asymmetric-key-format' identity.";
  }

  feature certificate-signing-request-generation {
    description
      "Indicates that the server implements the
       'generate-certificate-signing-request' action.";
  }


  /*************************************************/
  /*   Base Identities for Key Format Structures   */
  /*************************************************/

  identity public-key-format {
    description "Base key-format identity for public keys.";
  }

  identity private-key-format {
    description "Base key-format identity for private keys.";
  }

  identity symmetric-key-format {
    description "Base key-format identity for symmetric keys.";
  }


  /****************************************************/
  /*   Identities for Private Key Format Structures   */
  /****************************************************/

  identity rsa-private-key-format {
    base "private-key-format";
    description
      "Indicates that the private key value is encoded
       as an RSAPrivateKey (from RFC 3447).";
    reference
      "RFC 3447: PKCS #1: RSA Cryptography
                 Specifications Version 2.2";
  }

  identity ec-private-key-format {
    base "private-key-format";
    description
      "Indicates that the private key value is encoded
       as an ECPrivateKey (from RFC 5915)";
    reference
      "RFC 5915: Elliptic Curve Private Key Structure";
  }

  identity one-asymmetric-key-format {
    if-feature "one-asymmetric-key-format";
    base "private-key-format";
    description
      "Indicates that the private key value is a CMS
       OneAsymmetricKey structure, as defined in RFC 5958,
       encoded using ASN.1 distinguished encoding rules
       (DER), as specified in ITU-T X.690.";
    reference
      "RFC 5958: Asymmetric Key Packages
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
  }

  identity encrypted-one-asymmetric-key-format {
    if-feature "encrypted-one-asymmetric-key-format";
    base "private-key-format";
    description
      "Indicates that the private key value is a CMS EnvelopedData
       structure, per Section 8 in RFC 5652, containing a
       OneAsymmetricKey structure, as defined in RFC 5958,
       encoded using ASN.1 distinguished encoding rules (DER),
       as specified in ITU-T X.690.";
    reference
      "RFC 5652: Cryptographic Message Syntax (CMS)
       RFC 5958: Asymmetric Key Packages
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
   }


  /***************************************************/
  /*   Identities for Public Key Format Structures   */
  /***************************************************/

  identity ssh-public-key-format {
    base "public-key-format";
    description
      "Indicates that the public key value is an SSH public key,
       as specified by RFC 4253, Section 6.6, i.e.:

         string    certificate or public key format
                   identifier
         byte[n]   key/certificate data.";
    reference
      "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity subject-public-key-info-format {
    base "public-key-format";
    description
      "Indicates that the public key value is a SubjectPublicKeyInfo
       structure, as described in RFC 5280 encoded using ASN.1
       distinguished encoding rules (DER), as specified in
       ITU-T X.690.";
    reference
      "RFC 5280:
         Internet X.509 Public Key Infrastructure Certificate
         and Certificate Revocation List (CRL) Profile
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
  }


  /******************************************************/
  /*   Identities for Symmetric Key Format Structures   */
  /******************************************************/

  identity octet-string-key-format {
    base "symmetric-key-format";
    description
      "Indicates that the key is encoded as a raw octet string.
       The length of the octet string MUST be appropriate for
       the associated algorithm's block size.";
  }

  identity one-symmetric-key-format {
    if-feature "one-symmetric-key-format";
    base "symmetric-key-format";
    description
      "Indicates that the private key value is a CMS
       OneSymmetricKey structure, as defined in RFC 6031,
       encoded using ASN.1 distinguished encoding rules
       (DER), as specified in ITU-T X.690.";
    reference
      "RFC 6031: Cryptographic Message Syntax (CMS)
                 Symmetric Key Package Content Type
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
  }

  identity encrypted-one-symmetric-key-format {
    if-feature "encrypted-one-symmetric-key-format";
    base "symmetric-key-format";
    description
      "Indicates that the private key value is a CMS
       EnvelopedData structure, per Section 8 in RFC 5652,
       containing a OneSymmetricKey structure, as defined
       in RFC 6031, encoded using ASN.1 distinguished
       encoding rules (DER), as specified in ITU-T X.690.";
    reference
      "RFC 5652: Cryptographic Message Syntax (CMS)
       RFC 6031: Cryptographic Message Syntax (CMS)
                 Symmetric Key Package Content Type
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
  }


  /***************************************************/
  /*   Typedefs for ASN.1 structures from RFC 2986   */
  /***************************************************/

  typedef csr {
    type binary;
    description
      "A CertificationRequest structure, as specified in RFC 2986,
       encoded using ASN.1 distinguished encoding rules (DER), as
       specified in ITU-T X.690.";
    reference
      "RFC 2986:
         PKCS #10: Certification Request Syntax Specification
         Version 1.7
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
  }

  /***************************************************/
  /*   Typedefs for ASN.1 structures from RFC 5280   */
  /***************************************************/

  typedef x509 {
    type binary;
    description
      "A Certificate structure, as specified in RFC 5280,
       encoded using ASN.1 distinguished encoding rules (DER),
       as specified in ITU-T X.690.";
    reference
      "RFC 5280:
         Internet X.509 Public Key Infrastructure Certificate
         and Certificate Revocation List (CRL) Profile
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
  }

  typedef crl {
    type binary;
    description
      "A CertificateList structure, as specified in RFC 5280,
       encoded using ASN.1 distinguished encoding rules (DER),
       as specified in ITU-T X.690.";
    reference
      "RFC 5280:
         Internet X.509 Public Key Infrastructure Certificate
         and Certificate Revocation List (CRL) Profile
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
  }


  /***********************************************/
  /*   Typedefs for ASN.1 structures from 5652   */
  /***********************************************/

  typedef cms {
    type binary;
    description
      "A ContentInfo structure, as specified in RFC 5652,
       encoded using ASN.1 distinguished encoding rules (DER),
       as specified in ITU-T X.690.";
    reference
      "RFC 5652:
         Cryptographic Message Syntax (CMS)
       ITU-T X.690:
         Information technology - ASN.1 encoding rules:
         Specification of Basic Encoding Rules (BER),
         Canonical Encoding Rules (CER) and Distinguished
         Encoding Rules (DER).";
  }

  typedef data-content-cms {
    type cms;
    description
      "A CMS structure whose top-most content type MUST be the
       data content type, as described by Section 4 in RFC 5652.";
    reference
      "RFC 5652: Cryptographic Message Syntax (CMS)";
  }

  typedef signed-data-cms {
    type cms;
    description
      "A CMS structure whose top-most content type MUST be the
       signed-data content type, as described by Section 5 in
       RFC 5652.";
    reference
      "RFC 5652: Cryptographic Message Syntax (CMS)";
  }

  typedef enveloped-data-cms {
    type cms;
    description
      "A CMS structure whose top-most content type MUST be the
       enveloped-data content type, as described by Section 6
       in RFC 5652.";
    reference
      "RFC 5652: Cryptographic Message Syntax (CMS)";
  }

  typedef digested-data-cms {
    type cms;
    description
      "A CMS structure whose top-most content type MUST be the
       digested-data content type, as described by Section 7
       in RFC 5652.";
    reference
      "RFC 5652: Cryptographic Message Syntax (CMS)";
  }

  typedef encrypted-data-cms {
    type cms;
    description
      "A CMS structure whose top-most content type MUST be the
       encrypted-data content type, as described by Section 8
       in RFC 5652.";
    reference
      "RFC 5652: Cryptographic Message Syntax (CMS)";
  }

  typedef authenticated-data-cms {
    type cms;
    description
      "A CMS structure whose top-most content type MUST be the
       authenticated-data content type, as described by Section 9
       in RFC 5652.";
    reference
      "RFC 5652: Cryptographic Message Syntax (CMS)";
  }


  /*********************************************************/
  /*   Typedefs for ASN.1 structures related to RFC 5280   */
  /*********************************************************/

  typedef trust-anchor-cert-x509 {
    type x509;
    description
      "A Certificate structure that MUST encode a self-signed
       root certificate.";
  }

  typedef end-entity-cert-x509 {
    type x509;
    description
      "A Certificate structure that MUST encode a certificate
       that is neither self-signed nor having Basic constraint
       CA true.";
  }


  /*********************************************************/
  /*   Typedefs for ASN.1 structures related to RFC 5652   */
  /*********************************************************/

  typedef trust-anchor-cert-cms {
    type signed-data-cms;
    description
      "A CMS SignedData structure that MUST contain the chain of
       X.509 certificates needed to authenticate the certificate
       presented by a client or end-entity.

       The CMS MUST contain only a single chain of certificates.
       The client or end-entity certificate MUST only authenticate
       to last intermediate CA certificate listed in the chain.

       In all cases, the chain MUST include a self-signed root
       certificate.  In the case where the root certificate is
       itself the issuer of the client or end-entity certificate,
       only one certificate is present.

       This CMS structure MAY (as applicable where this type is
       used) also contain suitably fresh (as defined by local
       policy) revocation objects with which the device can
       verify the revocation status of the certificates.

       This CMS encodes the degenerate form of the SignedData
       structure that is commonly used to disseminate X.509
       certificates and revocation objects (RFC 5280).";
    reference
      "RFC 5280:
         Internet X.509 Public Key Infrastructure Certificate
         and Certificate Revocation List (CRL) Profile.";
  }

  typedef end-entity-cert-cms {
    type signed-data-cms;
    description
      "A CMS SignedData structure that MUST contain the end
       entity certificate itself, and MAY contain any number
       of intermediate certificates leading up to a trust
       anchor certificate.  The trust anchor certificate
       MAY be included as well.

       The CMS MUST contain a single end entity certificate.
       The CMS MUST NOT contain any spurious certificates.

       This CMS structure MAY (as applicable where this type is
       used) also contain suitably fresh (as defined by local
       policy) revocation objects with which the device can
       verify the revocation status of the certificates.

       This CMS encodes the degenerate form of the SignedData
       structure that is commonly used to disseminate X.509
       certificates and revocation objects (RFC 5280).";
    reference
      "RFC 5280:
         Internet X.509 Public Key Infrastructure Certificate
         and Certificate Revocation List (CRL) Profile.";
  }


  /**********************************************/
  /*   Groupings for keys and/or certificates   */
  /**********************************************/

  grouping symmetric-key-grouping {
    description
      "A symmetric key and algorithm.";
    leaf key-format {
      nacm:default-deny-write;
      type identityref {
        base symmetric-key-format;
      }
      description "Identifies the symmetric key's format.";
    }
    choice key-type {
      mandatory true;
      description
        "Choice between key types.";
      leaf key {
        nacm:default-deny-all;
        type binary;
        must "../key-format";
        description
          "The binary value of the key.  The interpretation of
           the value is defined by the 'key-format' field.";
      }
      leaf hidden-key {
        nacm:default-deny-write;
        type empty;
        must "not(../key-format)";
        description
          "A permanently hidden key.  How such keys are created
           is outside the scope of this module.";
      }
    }
  }

  grouping public-key-grouping {
    description
      "A public key and its associated algorithm.";
    leaf public-key-format {
      nacm:default-deny-write;
      type identityref {
        base public-key-format;
      }
      mandatory true;
      description "Identifies the key's format.";
    }
    leaf public-key {
      nacm:default-deny-write;
      type binary;
      mandatory true;
      description
        "The binary value of the public key.  The interpretation
         of the value is defined by 'public-key-format' field.";
    }
  }

  grouping asymmetric-key-pair-grouping {
    description
      "A private key and its associated public key and algorithm.";
    uses public-key-grouping;
    leaf private-key-format {
      nacm:default-deny-write;
      type identityref {
        base private-key-format;
      }
      description "Identifies the key's format.";
    }
    choice private-key-type {
      mandatory true;
      description
        "Choice between key types.";
      leaf private-key {
        nacm:default-deny-all;
        type binary;
        must "../private-key-format";
        description
          "The value of the binary key  The key's value is
           interpreted by the 'private-key-format' field.";
      }
      leaf hidden-private-key {
        nacm:default-deny-write;
        type empty;
        must "not(../private-key-format)";
        description
          "A permanently hidden key.  How such keys are created
           is outside the scope of this module.";
      }
    }
  }

  grouping trust-anchor-cert-grouping {
    description
      "A trust anchor certificate, and a notification for when
       it is about to (or already has) expire.";
    leaf cert {
      nacm:default-deny-write;
      type trust-anchor-cert-cms;
      description
        "The binary certificate data for this certificate.";
      reference
        "RFC YYYY: Common YANG Data Types for Cryptography";
    }
    notification certificate-expiration {
      description
        "A notification indicating that the configured certificate
         is either about to expire or has already expired.  When to
         send notifications is an implementation specific decision,
         but it is RECOMMENDED that a notification be sent once a
         month for 3 months, then once a week for four weeks, and
         then once a day thereafter until the issue is resolved.";
      leaf expiration-date {
        type yang:date-and-time;
        mandatory true;
        description
          "Identifies the expiration date on the certificate.";
      }
    }
  }

  grouping trust-anchor-certs-grouping {
    description
      "A list of trust anchor certificates, and a notification
       for when one is about to (or already has) expire.";
    leaf-list cert {
      nacm:default-deny-write;
      type trust-anchor-cert-cms;
      description
        "The binary certificate data for this certificate.";
      reference
        "RFC YYYY: Common YANG Data Types for Cryptography";
    }
    notification certificate-expiration {
      description
        "A notification indicating that the configured certificate
         is either about to expire or has already expired.  When to
         send notifications is an implementation specific decision,
         but it is RECOMMENDED that a notification be sent once a
         month for 3 months, then once a week for four weeks, and
         then once a day thereafter until the issue is resolved.";
      leaf expiration-date {
        type yang:date-and-time;
        mandatory true;
        description
          "Identifies the expiration date on the certificate.";
      }
    }
  }

  grouping end-entity-cert-grouping {
    description
      "An end entity certificate, and a notification for when
       it is about to (or already has) expire.  Implementations
       SHOULD assert that, where used, the end entity certificate
       contains the expected public key.";
    leaf cert {
      nacm:default-deny-write;
      type end-entity-cert-cms;
      description
        "The binary certificate data for this certificate.";
      reference
        "RFC YYYY: Common YANG Data Types for Cryptography";
    }
    notification certificate-expiration {
      description
        "A notification indicating that the configured certificate
         is either about to expire or has already expired.  When to
         send notifications is an implementation specific decision,
         but it is RECOMMENDED that a notification be sent once a
         month for 3 months, then once a week for four weeks, and
         then once a day thereafter until the issue is resolved.";
      leaf expiration-date {
        type yang:date-and-time;
        mandatory true;
        description
          "Identifies the expiration date on the certificate.";
      }
    }
  }

  grouping end-entity-certs-grouping {
    description
      "A list of end entity certificates, and a notification for
       when one is about to (or already has) expire.";
    leaf-list cert {
      nacm:default-deny-write;
      type end-entity-cert-cms;
      description
        "The binary certificate data for this certificate.";
      reference
        "RFC YYYY: Common YANG Data Types for Cryptography";
    }
    notification certificate-expiration {
      description
        "A notification indicating that the configured certificate
         is either about to expire or has already expired.  When to
         send notifications is an implementation specific decision,
         but it is RECOMMENDED that a notification be sent once a
         month for 3 months, then once a week for four weeks, and
         then once a day thereafter until the issue is resolved.";
      leaf expiration-date {
        type yang:date-and-time;
        mandatory true;
        description
          "Identifies the expiration date on the certificate.";
      }
    }
  }

  grouping generate-csr-grouping {
    description
      "Defines the 'generate-certificate-signing-request' action.";
    action generate-certificate-signing-request {
      if-feature certificate-signing-request-generation;
      nacm:default-deny-all;
      description
        "Generates a certificate signing request structure for
         the associated asymmetric key using the passed subject
         and attribute values.
         
         This action statement is only available when the
         associated 'public-key-format' node's value is
         'subject-public-key-info-format'.";
      reference
        "RFC 6125:
          Representation and Verification of Domain-Based
          Application Service Identity within Internet Public Key
          Infrastructure Using X.509 (PKIX) Certificates in the
          Context of Transport Layer Security (TLS)";
      input {
        leaf subject {
          type binary;
          mandatory true;
          description
            "The 'subject' field per the CertificationRequestInfo
              structure as specified by RFC 2986, Section 4.1
              encoded using the ASN.1 distinguished encoding
              rules (DER), as specified in ITU-T X.690.";
          reference
            "RFC 2986: PKCS #10: Certification Request Syntax
                       Specification Version 1.7.
             ITU-T X.690:
               Information technology - ASN.1 encoding rules:
               Specification of Basic Encoding Rules (BER),
               Canonical Encoding Rules (CER) and Distinguished
               Encoding Rules (DER).";
        }
        leaf attributes {
          type binary;
          description
            "The 'attributes' field from the structure
             CertificationRequestInfo as specified by RFC 2986,
             Section 4.1 encoded using the ASN.1 distinguished
             encoding rules (DER), as specified in ITU-T X.690.";
          reference
            "RFC 2986: PKCS #10: Certification Request Syntax
                       Specification Version 1.7.
             ITU-T X.690:
               Information technology - ASN.1 encoding rules:
               Specification of Basic Encoding Rules (BER),
               Canonical Encoding Rules (CER) and Distinguished
               Encoding Rules (DER).";
        }
      }
      output {
        leaf certificate-signing-request {
          type ct:csr;
          mandatory true;
          description
            "The requested certificate signing request structure.";
        }
      }
    }
  } // generate-csr-grouping

  grouping asymmetric-key-pair-with-cert-grouping {
    description
      "A private/public key pair and an associated certificate.
       Implementations SHOULD assert that certificates contain
       the matching public key.";
    uses asymmetric-key-pair-grouping;
    uses end-entity-cert-grouping;
    uses generate-csr-grouping;
  } // asymmetric-key-pair-with-cert-grouping

  grouping asymmetric-key-pair-with-certs-grouping {
    description
      "A private/public key pair and associated certificates.
       Implementations SHOULD assert that certificates contain
       the matching public key.";
    uses asymmetric-key-pair-grouping;
    container certificates {
      nacm:default-deny-write;
      description
        "Certificates associated with this asymmetric key.
         More than one certificate supports, for instance,
         a TPM-protected asymmetric key that has both IDevID
         and LDevID certificates associated.";
      list certificate {
        key "name";
        description
          "A certificate for this asymmetric key.";
        leaf name {
          type string;
          description
            "An arbitrary name for the certificate.  If the name
             matches the name of a certificate that exists
             independently in <operational> (i.e., an IDevID),
             then the 'cert' node MUST NOT be configured.";
        }
        uses end-entity-cert-grouping {
          refine cert {
            mandatory true;
          }
        }
      }
    }
    uses generate-csr-grouping;
  } // asymmetric-key-pair-with-certs-grouping

}

<CODE ENDS>

2.3. Examples

2.3.1. The "asymmetric-key-pair-with-certs-grouping" Grouping

The following example module illustrates the use of both the "symmetric-key-grouping" and the "asymmetric-key-pair-with-certs-grouping" groupings defined in the "ietf-crypto-types" module.

module ex-crypto-types-usage {
  yang-version 1.1;

  namespace "http://example.com/ns/example-crypto-types-usage";
  prefix "ectu";

  import ietf-crypto-types {
    prefix ct;
    reference 
      "RFC AAAA: Common YANG Data Types for Cryptography";
  }

  organization
   "Example Corporation";

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

  description
   "This module illustrates the grouping
    defined in the crypto-types draft called 
    'asymmetric-key-pair-with-certs-grouping'.";

  revision "2020-05-20" {
    description
     "Initial version";
    reference
     "RFC AAAA: Common YANG Data Types for Cryptography";
  }

  container symmetric-keys {
    description
      "A container of symmetric keys.";
    list symmetric-key {
      key name;
      description
        "A symmetric key";
      leaf name {
        type string;
        description
          "An arbitrary name for this key.";
      }
      uses ct:symmetric-key-grouping;
    }
  }
  container asymmetric-keys {
    description
      "A container of asymmetric keys.";
    list asymmetric-key {
      key name;
      leaf name {
        type string;
        description
          "An arbitrary name for this key.";
      }
      uses ct:asymmetric-key-pair-with-certs-grouping;
      description
        "An asymmetric key pair with associated certificates.";
    }
  }
}

Given the above example usage module, the following example illustrates some configured keys.

<symmetric-keys
  xmlns="http://example.com/ns/example-crypto-types-usage"
  xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-crypto-types">
  <symmetric-key>
    <name>ex-hidden-symmetric-key</name>
    <hidden-key/>
  </symmetric-key>
  <symmetric-key>
    <name>ex-octet-string-based-symmetric-key</name>
    <key-format>ct:octet-string-key-format</key-format>
    <key>base64encodedvalue==</key>
  </symmetric-key>
  <symmetric-key>
    <name>ex-one-symmetric-based-symmetric-key</name>
    <key-format>ct:one-symmetric-key-format</key-format>
    <key>base64encodedvalue==</key>
  </symmetric-key>
  <symmetric-key>
    <name>ex-encrypted-one-symmetric-based-symmetric-key</name>
    <key-format>ct:encrypted-one-symmetric-key-format</key-format>
    <key>base64encodedvalue==</key>
  </symmetric-key>
</symmetric-keys>

<asymmetric-keys
  xmlns="http://example.com/ns/example-crypto-types-usage"
  xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-crypto-types">
  <asymmetric-key>
    <name>ex-hidden-asymmetric-key</name>
    <public-key-format>
      ct:subject-public-key-info-format
    </public-key-format>
    <public-key>base64encodedvalue==</public-key>
    <hidden-private-key/>
    <certificates>
      <certificate>
        <name>ex-hidden-key-cert</name>
        <cert>base64encodedvalue==</cert>
      </certificate>
    </certificates>
  </asymmetric-key>
  <asymmetric-key>
    <name>ex-subject-public-info-based-asymmetric-key</name>
    <public-key-format>
      ct:subject-public-key-info-format
    </public-key-format>
    <public-key>base64encodedvalue==</public-key>
    <private-key-format>
      ct:rsa-private-key-format
    </private-key-format>
    <private-key>base64encodedvalue==</private-key>
    <certificates>
      <certificate>
        <name>ex-cert</name>
        <cert>base64encodedvalue==</cert>
      </certificate>
    </certificates>
  </asymmetric-key>
  <asymmetric-key>
    <name>ex-one-asymmetric-based-symmetric-key</name>
    <public-key-format>
      ct:subject-public-key-info-format
    </public-key-format>
    <public-key>base64encodedvalue==</public-key>
    <private-key-format>
      ct:one-asymmetric-key-format
    </private-key-format>
    <private-key>base64encodedvalue==</private-key>
  </asymmetric-key>
  <asymmetric-key>
    <name>ex-encrypted-one-asymmetric-based-symmetric-key</name>
    <public-key-format>
      ct:subject-public-key-info-format
    </public-key-format>
    <public-key>base64encodedvalue==</public-key>
    <private-key-format>
      ct:encrypted-one-asymmetric-key-format
    </private-key-format>
    <private-key>base64encodedvalue==</private-key>
  </asymmetric-key>
</asymmetric-keys>

2.3.2. The "generate-certificate-signing-request" Action

The following example illustrates the "generate-certificate-signing-request" action with the NETCONF protocol.

REQUEST

<rpc message-id="101"
  xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <action xmlns="urn:ietf:params:xml:ns:yang:1">
    <asymmetric-keys
      xmlns="http://example.com/ns/example-crypto-types-usage">
      <asymmetric-key>
        <name>ex-key-sect571r1</name>
        <generate-certificate-signing-request>
          <subject>base64encodedvalue==</subject>
          <attributes>base64encodedvalue==</attributes>
        </generate-certificate-signing-request>
      </asymmetric-key>
    </asymmetric-keys>
  </action>
</rpc>

RESPONSE

<rpc-reply message-id="101"
   xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
   <certificate-signing-request
     xmlns="http://example.com/ns/example-crypto-types-usage">
     base64encodedvalue==
   </certificate-signing-request>
</rpc-reply>

2.3.3. The "certificate-expiration" Notification

The following example illustrates the "certificate-expiration" notification with the NETCONF protocol.

<notification
  xmlns="urn:ietf:params:xml:ns:netconf:notification:1.0">
  <eventTime>2018-05-25T00:01:00Z</eventTime>
  <keys xmlns="http://example.com/ns/example-crypto-types-usage">
    <key>
      <name>locally-defined key</name>
      <certificates>
        <certificate>
          <name>my-cert</name>
          <certificate-expiration>
            <expiration-date>
              2018-08-05T14:18:53-05:00
            </expiration-date>
          </certificate-expiration>
        </certificate>
      </certificates>
    </key>
  </keys>
</notification>

3. Security Considerations

3.1. No Support for CRMF

This document uses PKCS #10 [RFC2986] for the "generate-certificate-signing-request" action. The use of Certificate Request Message Format (CRMF) [RFC4211] was considered, but is was unclear if there was market demand for it. If it is desired to support CRMF in the future, a backwards compatible solution can be defined at that time.

3.2. Access to Data Nodes

The YANG module in this document defines "grouping" statements that are designed to be accessed via YANG based management protocols, such as NETCONF [RFC6241] and RESTCONF [RFC8040]. Both of these protocols have mandatory-to-implement secure transport layers (e.g., SSH, TLS) with mutual authentication.

The NETCONF access control model (NACM) [RFC8341] provides the means to restrict access for particular users to a pre-configured subset of all available protocol operations and content.

Since the module in this document only define groupings, these considerations are primarily for the designers of other modules that use these groupings.

There are a number of data nodes defined by the grouping statements that are writable/creatable/deletable (i.e., config true, which is the default). Some of these data nodes may be considered sensitive or vulnerable in some network environments. Write operations (e.g., edit-config) to these data nodes without proper protection can have a negative effect on network operations. These are the subtrees and data nodes and their sensitivity/vulnerability:

*:
All of the data nodes defined by all the groupings are considered sensitive to write operations. For instance, the modification of a public key or a certificate can dramatically alter the implemented security policy. For this reason, the NACM extension "default-deny-write" has been applied to all the data nodes defined by all the groupings.

Some of the readable data nodes in the 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:

/private-key:
The "private-key" node defined in the "asymmetric-key-pair-grouping" grouping 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" has been applied to it here.

Some of the operations in this YANG module may be considered sensitive or vulnerable in some network environments. It is thus important to control access to these operations. These are the operations and their sensitivity/vulnerability:

*:
All of the "action" statements defined by groupings SHOULD only be executed by authorized users. For this reason, the NACM extension "default-deny-all" has been applied to all of them. Note that NACM uses "default-deny-all" to protect "RPC" and "action" statements; it does not define, e.g., an extension called "default-deny-execute".
generate-certificate-signing-request:
For this action, it is RECOMMENDED that implementations assert channel binding [RFC5056], so as to ensure that the application layer that sent the request is the same as the device authenticated when the secure transport layer was established.

4. IANA Considerations

4.1. Update the "IETF XML" Registry

This document registers one URI in the "ns" subregistry of the "IETF XML" registry [RFC3688]. Following the format in [RFC3688], the following registration is requested:

   URI: urn:ietf:params:xml:ns:yang:ietf-crypto-types
   Registrant Contact: The NETCONF WG of the IETF.
   XML: N/A, the requested URI is an XML namespace.

4.2. Update the "YANG Module Names" Registry

This document registers one YANG module in the "YANG Module Names" registry [RFC6020]. Following the format in [RFC6020], the the following registration is requested:

   name:         ietf-crypto-types
   namespace:    urn:ietf:params:xml:ns:yang:ietf-crypto-types
   prefix:       ct
   reference:    RFC AAAA

5. References

5.1. Normative References

[ITU.X690.2015] International Telecommunication Union, "Information Technology - ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER)", ITU-T Recommendation X.690, ISO/IEC 8825-1, August 2015.
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997.
[RFC3447] Jonsson, J. and B. Kaliski, "Public-Key Cryptography Standards (PKCS) #1: RSA Cryptography Specifications Version 2.1", RFC 3447, DOI 10.17487/RFC3447, February 2003.
[RFC4253] Ylonen, T. and C. Lonvick, "The Secure Shell (SSH) Transport Layer Protocol", RFC 4253, DOI 10.17487/RFC4253, January 2006.
[RFC5280] Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R. and W. Polk, "Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile", RFC 5280, DOI 10.17487/RFC5280, May 2008.
[RFC5652] Housley, R., "Cryptographic Message Syntax (CMS)", STD 70, RFC 5652, DOI 10.17487/RFC5652, September 2009.
[RFC5958] Turner, S., "Asymmetric Key Packages", RFC 5958, DOI 10.17487/RFC5958, August 2010.
[RFC6031] Turner, S. and R. Housley, "Cryptographic Message Syntax (CMS) Symmetric Key Package Content Type", RFC 6031, DOI 10.17487/RFC6031, December 2010.
[RFC6991] Schoenwaelder, J., "Common YANG Data Types", RFC 6991, DOI 10.17487/RFC6991, July 2013.
[RFC7950] Bjorklund, M., "The YANG 1.1 Data Modeling Language", RFC 7950, DOI 10.17487/RFC7950, August 2016.
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017.
[RFC8341] Bierman, A. and M. Bjorklund, "Network Configuration Access Control Model", STD 91, RFC 8341, DOI 10.17487/RFC8341, March 2018.

5.2. Informative References

[RFC2986] Nystrom, M. and B. Kaliski, "PKCS #10: Certification Request Syntax Specification Version 1.7", RFC 2986, DOI 10.17487/RFC2986, November 2000.
[RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, DOI 10.17487/RFC3688, January 2004.
[RFC4211] Schaad, J., "Internet X.509 Public Key Infrastructure Certificate Request Message Format (CRMF)", RFC 4211, DOI 10.17487/RFC4211, September 2005.
[RFC5056] Williams, N., "On the Use of Channel Bindings to Secure Channels", RFC 5056, DOI 10.17487/RFC5056, November 2007.
[RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an IANA Considerations Section in RFCs", RFC 5226, DOI 10.17487/RFC5226, May 2008.
[RFC5915] Turner, S. and D. Brown, "Elliptic Curve Private Key Structure", RFC 5915, DOI 10.17487/RFC5915, June 2010.
[RFC6020] Bjorklund, M., "YANG - A Data Modeling Language for the Network Configuration Protocol (NETCONF)", RFC 6020, DOI 10.17487/RFC6020, October 2010.
[RFC6125] Saint-Andre, P. and J. Hodges, "Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS)", RFC 6125, DOI 10.17487/RFC6125, March 2011.
[RFC6241] Enns, R., Bjorklund, M., Schoenwaelder, J. and A. Bierman, "Network Configuration Protocol (NETCONF)", RFC 6241, DOI 10.17487/RFC6241, June 2011.
[RFC8040] Bierman, A., Bjorklund, M. and K. Watsen, "RESTCONF Protocol", RFC 8040, DOI 10.17487/RFC8040, January 2017.
[RFC8340] Bjorklund, M. and L. Berger, "YANG Tree Diagrams", BCP 215, RFC 8340, DOI 10.17487/RFC8340, March 2018.

Appendix A. Change Log

A.1. I-D to 00

A.2. 00 to 01

A.3. 01 to 02

A.4. 02 to 03

A.5. 03 to 04

A.6. 04 to 05

A.7. 05 to 06

A.8. 06 to 07

A.9. 07 to 08

A.10. 08 to 09

A.11. 09 to 10

A.12. 10 to 11

A.13. 11 to 12

A.14. 12 to 13

A.15. 13 to 14

A.16. 14 to 15

Acknowledgements

The authors would like to thank for following for lively discussions on list and in the halls (ordered by last name): Martin Bjorklund, Nick Hancock, Wang Haiguang, Balázs Kovács, Rich Salz, Juergen Schoenwaelder, Eric Voit, Rob Wilton, and Liang Xia.

Author's Address

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