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";
}
//import iana-hash-algs {
// prefix iha;
// reference
// "RFC XXXX: Common YANG Data Types for Cryptography";
//}
import iana-symmetric-algs {
prefix isa;
reference
"RFC XXXX: Common YANG Data Types for Cryptography";
}
import iana-asymmetric-algs {
prefix iasa;
reference
"RFC XXXX: Common YANG Data Types for Cryptography";
}
organization
"IETF NETCONF (Network Configuration) Working Group";
contact
"WG Web:
WG List:
Author: Kent Watsen
Author: Wang Haiguang ";
description
"This module defines common YANG types for cryptographic
applications.
Copyright (c) 2019 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 XXXX
(https://www.rfc-editor.org/info/rfcXXXX); 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 2019-11-20 {
description
"Initial version";
reference
"RFC XXXX: 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.";
}
/********************************************/
/* Identities for Key Format Structures */
/********************************************/
/*** base key formats ****/
identity key-format-base {
description "Base key-format identity for all keys.";
}
identity public-key-format {
base "key-format-base";
description "Base key-format identity for public keys.";
}
identity private-key-format {
base "key-format-base";
description "Base key-format identity for private keys.";
}
identity symmetric-key-format {
base "key-format-base";
description "Base key-format identity for symmetric keys.";
}
/**** for private keys ****/
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 encoded
as a OneAsymmetricKey structure (RFC 6031).";
// FIXME: DER encoded ASN.1, etc...or flex PEM?
reference
"RFC 5958: Asymmetric Key Packages";
}
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 encoded
as a OneAsymmetricKey structure (RFC 5958).";
// FIXME: DER encoded ASN.1, etc...or flex PEM?
reference
"RFC 5652: Cryptographic Message Syntax (CMS)
RFC 5958: Asymmetric Key Packages";
}
/**** for public keys ****/
identity ssh-public-key-format {
base "public-key-format";
description
"Indicates that the public key value is encoded
an SSH public key, as described by RFC 4716.";
reference
"RFC 4716: The Secure Shell (SSH) Public Key
File Format";
}
identity subject-public-key-info-format {
base "public-key-format";
description
"Indicates that the public key value is encoded as
a SubjectPublicKeyInfo structure, as described in
RFC 5280.";
// FIXME: DER encoded ASN.1, etc...
reference
"RFC 5280:
Internet X.509 Public Key Infrastructure Certificate
and Certificate Revocation List (CRL) Profile";
}
/**** for symmetric keys ****/
identity octet-string-key-format {
base "symmetric-key-format";
description
"Indicates that the key is encoded as a raw octet string.";
// FIXME
// Knowing that it is an "OctetString" isn't really helpful.
// Knowing the length of the octet string would be helpful,
// as it relates to the algorithm's block size. We may want
// to only (for now) use "one-symmetric-key-format" for
// symmetric keys...were the usability issues Juergen
// mentioned before only apply to asymmetric keys?
}
identity one-symmetric-key-format {
if-feature "one-symmetric-key-format";
base "symmetric-key-format";
description
"Indicates that the symmetric key value is encoded
as a OneSymmetricKey (from RFC 6031).";
// FIXME: DER encoded ASN.1, etc...or flex PEM?
reference
"RFC 6031: Cryptographic Message Syntax (CMS)
Symmetric Key Package Content Type";
}
identity encrypted-one-symmetric-key-format {
if-feature "encrypted-one-symmetric-key-format";
base "symmetric-key-format";
description
"Indicates that the symmetric key value is encoded
as an EncryptedData structure (RFC 5652) containing
OneSymmetricKey (RFC 6031).";
// FIXME: DER encoded ASN.1, etc...or flex PEM?
reference
"RFC 5652: Cryptographic Message Syntax (CMS)
RFC 6031: Cryptographic Message Syntax (CMS)
Symmetric Key Package Content Type";
}
/***************************************************/
/* 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 structures related to RFC 4253 */
/***************************************************/
typedef ssh-host-key {
type binary;
description
"The binary public key data for an SSH 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";
}
/*********************************************************/
/* 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.";
}
typedef ssh-public-key-type { // DELETE?
type binary;
description
"The binary public key data for this SSH 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";
}
/**********************************************/
/* Groupings for keys and/or certificates */
/**********************************************/
grouping symmetric-key-grouping {
description
"A symmetric key and algorithm.";
leaf algorithm {
type isa:symmetric-algorithm-type;
mandatory true;
description
"The algorithm to be used when generating the key.";
reference
"RFC CCCC: Common YANG Data Types for Cryptography";
}
leaf key-format {
nacm:default-deny-write;
when "../key or ../encrypted-key"; // FIXME: forward ref?!
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 'key-format'. For example,
FIXME.";
reference
"RFC XXXX: FIXME";
}
leaf hidden-key {
nacm:default-deny-write;
type empty;
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 algorithm {
nacm:default-deny-write;
type iasa:asymmetric-algorithm-type;
mandatory true;
description
"Identifies the key's algorithm.";
reference
"RFC CCCC: Common YANG Data Types for Cryptography";
}
leaf public-key-format {
nacm:default-deny-write;
when "../public-key";
type identityref {
base public-key-format;
}
description "Identifies the key's format.";
}
leaf public-key {
nacm:default-deny-write;
type binary;
must "../public-key-format";
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;
when "../private-key or ../encrypted-private-key";
// FIXME: forward ref?!
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;
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 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;
action generate-certificate-signing-request {
nacm:default-deny-all;
description
"Generates a certificate signing request structure for
the associated asymmetric key using the passed subject
and attribute values. The specified assertions need
to be appropriate for the certificate's use. For
example, an entity certificate for a TLS server
SHOULD have values that enable clients to satisfy
RFC 6125 processing.";
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 binary;
mandatory true;
description
"A CertificationRequest structure as specified by
RFC 2986, Section 4.2 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).";
}
}
} // generate-certificate-signing-request
} // 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 (i.e., an IDevID),
then the 'cert' node MUST NOT be configured.";
}
uses end-entity-cert-grouping;
}
} // certificates
action generate-certificate-signing-request {
nacm:default-deny-all;
description
"Generates a certificate signing request structure for
the associated asymmetric key using the passed subject
and attribute values. The specified assertions need
to be appropriate for the certificate's use. For
example, an entity certificate for a TLS server
SHOULD have values that enable clients to satisfy
RFC 6125 processing.";
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 binary;
mandatory true;
description
"A CertificationRequest structure as specified by
RFC 2986, Section 4.2 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).";
}
}
} // generate-certificate-signing-request
} // asymmetric-key-pair-with-certs-grouping
}