<?xml version='1.0' encoding='utf-8'?>

<!DOCTYPE rfc  >
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs), 
please see http://xml.resource.org/authoring/README.html. -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude"
category="std"
docName="draft-stjohns-csr-attest-01"
ipr="trust200902"
obsoletes=""
updates=""
submissionType="IETF"
xml:lang="en"
tocInclude="true"
tocDepth="4"
symRefs="true"
sortRefs="true"
version="3">
<!-- xml2rfc v2v3 conversion 2.38.1 -->
<!-- category values: std, bcp, info, exp, and historic
     ipr values: trust200902, noModificationTrust200902, noDerivativesTrust200902,
     or pre5378Trust200902
     you can add the attributes updates="NNNN" and obsoletes="NNNN" 
     they will automatically be output with "(if approved)" -->

<!-- ***** FRONT MATTER ***** -->

<front>
  <!-- The abbreviated title is used in the page header - it is only necessary if the 
       full title is longer than 39 characters -->

  <title abbrev="CSR Attestation Attributes">
    Attestation Attributes for Use with Certification Signing Requests
  </title>
  <seriesInfo name="Internet-Draft" value="draft-stjohns-csr-attest-01"/>

  <author fullname="Michael StJohns" initials="M" surname="StJohns">
    <organization>NthPermutation Security LLC</organization>
    <address>
      <postal>
        <street/>
        <city>Germantown</city>
        <region>MD</region>
        <code>20874</code>
        <country>US</country>
      </postal>
      <phone/>
      <email>msj@nthpermutation.com</email>
    </address>
  </author>
  <date year="2023"/>
  <area>Security</area>
  <workgroup>LAMPS</workgroup>
  <!--<keyword>template</keyword> -->
  <abstract>
    <t>
      This document describes two ASN.1 Attribute definitions, and an
      ASN.1 CLASS definition for an attestation statement structure
      that may be used to encode key attestation data for inclusion in
      PKCS10 certificate requests and in other circumstances.
    </t>
  </abstract>
</front>
<middle>
  <section numbered="true" toc="default">
    <name>Introduction</name>
    <t>
      This document creates two ATTRIBUTE/Attribute definitions.  The
      first Attribute may be used to carry a set of certificates or
      public keys that may be necessary to validate an attestation.
      The second Attribute carries a structure that may be used to
      carry key attestation statements, signatures and related
      data. Both of these Attribute definitions are intended to be
      used to carry the attestation data a Certification Authority (CA) may
      need to decide to issue a certificate containg the attested key.
    </t>
    <t>
      The AttestStatement structure provides an encoding that may be
      used regardless of the actual format and mechanisms used by an
      given type of attestation. In its simplest expansion it encodes
      a SEQUENCE of an OBJECT IDENTIFIER and a related ASN.1 type.
    </t>
    <t>
      For the purposes of this document, a "certificate" is a signed
      binding of a public key and some identifying or use
      information.  An X.509 Certificate is one example, but the
      structures described below allow for the carriage of any
      identifiable type of certificate. Examples include Card Verifiable
      Certificates <xref target="TR-03110-3"/> and <xref target="EQMV"/> implicit certificates.
    </t>
    <section numbered="true" toc="default">
      <name>Requirements Language</name>
      <t>
	The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
	NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and
	"OPTIONAL" in this document are to be interpreted as described
	in <xref target="RFC2119" format="default">RFC 2119</xref>.
      </t>
    </section>
  </section>
  <section anchor="dictionary" numbered="true" toc="default">
    <name>Definitions</name>
    <t>
      The following definitions should be used in the context of this
      document primarily to understand the relationship of an
      attestation to the ASN.1 structures used to carry an attestation
      in PKIX structures. As of the date of this document, the IETF
      lacked a common nomenclature for attestation-related terms.
    </t>
    <dl newline="true">
      <dt>Attestation Engine</dt>
      <dd>
	The secure hardware and firmware used to compose and sign an
	attestation.
      </dd>
      <dt>Attestation Key</dt>
      <dd>
	Either the private key used to sign an attestation statement,
	or the related public key used to verify the attestation
	statement, depending on context.
      </dd>
      <dt>Attester</dt>
      <dd>
	The entity that directs the creation of an attestation
	statement and who owns, controls, or is permitted to use the
	private attestation key.
      </dd>
      <dt>Ancillary Attestation Data</dt>
      <dd>
	Any data provided from a source external to the attestation
	engine as part of the creation of an attestation statement
	and/or any additional data needed for the verification of an
	attestation statement. The externally provided data could be a
	relying party originated nonce, a time stamp, session
	information or other data meant to be bound in time to the
	attestation statement. Other additional data may be an
	internally formatted key, or other data needed to bridge
	between the attestation statement and PKIX or other relying or
	interpretating regimes.  The format of externally provided
	data is not under the control of the attestation engine, but
	may need to be transformed, such as by hashing, before it may
	be incorporated within the attestation statement
	processing. For example, a relying party may need both the
	"externalData" argument for the TPM 2.0 TPM2_Certify command,
	and the TPMT_PUBLIC structure containing the key being
	certified to verify an attestation.
      </dd>
      <dt>Attestation Statement</dt>
      <dd>
	The object, any optional ancillary data incorporated during
	the creation of that object, and the signature over that
	object, created by an attestation engine at the request of an
	Attester to provide evidence of a fact or set of facts within
	the cognizance of the attestation engine at a particular point
	in time."  Sometimes referred to simply as an "attestation".
      </dd>
      <dt>Attestation</dt>
      <dd>
	The implicit or explicit collection of an attestation
	statement, any ancillary data, an attestation key, and a chain
	of trust for that key. By convention, this contains at
	least the minimum data needed to cryptographically validate an
	attestation statement and extract any policy meaning.
      </dd>
      <dt>Key Attestation</dt>
      <dd>
	An attestation created with respect to a particular key or key
	pair.
      </dd>

    </dl>

  </section>
  <section anchor="asn1elements" numbered="true" toc="default">
    <name>ASN.1 Elements</name>
    <section anchor="oidDefs" numbered="true" toc="default">
      <name>Object Identifiers</name>
      <t>
	Placeholder for now, waiting on guidance.
      </t>
      <sourcecode>
id-pkix OBJECT IDENTIFIER ::= { iso(1) identified-organization(3)
     dod(6) internet(1) security(5) mechanisms(5) pkix(7) }

-- Branch for CSR and related attributes - IETF version of id-at
id-cra OBJECT IDENTIFIER ::= { id-pkix (TBD1) }

-- Branch for attestation statement types
id-ata OBJECT IDENTIFIER ::= { id-pkix (TBD2) }
      </sourcecode>
    </section>
    <section anchor="certchoice" numbered="true" toc="default">
      <name>CertificateChoice</name>
      <t>
	This is an ASN.1 CHOICE construct used to represent an
	encoding of a broad variety of certificate types.
      </t>
      <sourcecode>
CertificateChoice ::=
   CHOICE {
      cert Certificate, -- typical X.509 cert
      opaqueCert    [0] IMPLICIT OCTET STRING, -- Format implicitly agreed upon
                                                        -- by sender and receiver
      typedCert     [1] IMPLICIT TypedCert,    
      typedFlatCert [2] IMPLICIT TypedFlatCert 
   }
      </sourcecode>
      <t>
	"Certificate" is a standard X.509 certificate that
	<bcp14>MUST</bcp14> be compliant with RFC5280. Enforcement of
	this constraint is left to the relying parties.
      </t>
      <t>
	"opaqueCert" should be used sparingly as it requires the
	receiving party to implictly know its format.  It is encoded
	as an OCTET STRING.
      </t>
      <t>
	"TypedCert" is an ASN.1 construct that has the charateristics
	of a certificate, but is not encoded as an X.509 certificate.
	The certTypeField indicates how to interpret the certBody
	field. While it is possible to carry any type of data in this
	structure, it's intended the content field include data for at
	least one public key formatted as a SubjectPublicKeyInfo (see
	<xref target="RFC5912"/>).
      </t>
      <sourcecode>
	<![CDATA[
TYPED-CERT ::= TYPE-IDENTIFIER -- basically an object id and a matching ASN1
                               -- structure encoded as a sequence
CertType ::= TYPED-CERT.&id   

TypedCert ::= SEQUENCE {
              certType     TYPED-CERT.&id({TypedCertSet}),
              content     TYPED-CERT.&Type ({TypedCertSet}{@certType})
          }

TypedCertSet TYPED-CERT ::= {
             ... -- Empty for now, 
             }
	]]>
      </sourcecode>
      <t>
	"TypedFlatCert" is a certificate that does not have a valid
	ASN.1 encoding. Think compact or implicit certificates as
	might be used with smart cards.  certType indicates the format
	of the data in the certBody field, and ideally refers to a
	published specification.
      </t>
      <sourcecode>
TypedFlatCert ::= SEQUENCE {
    certType OBJECT IDENTIFIER,
    certBody OCTET STRING
}
      </sourcecode>
    </section>
    <section anchor="attestAttribute" numbered="true" toc="default">
      <name>AttestAttribute</name>
      <t>
	By definition, Attributes within a Certification Signing
	Request are typed as ATTRIBUTE. This attribute definition
	contains one or more attestation statements of a type
	"AttestStatement".
      </t>
      <sourcecode>
id-cra-attestStatement OBJECT IDENTIFIER ::= { id-cra 2 }
	
AttestAttribute ATTRIBUTE ::= {
  TYPE AttestStatement
  IDENTIFIED BY id-cra-attestStatement
}
      </sourcecode>
    </section>
    <section anchor="attestCertsAttribute" numbered="true"
	     toc="default">
      <name>AttestCertsAttribute</name>
      <t>
	The "AttestCertsAttribute" contains a sequence of certificates
	that may be needed to validate the contents of an attestation
	statement contained in an attestAttribute.  By convention, the
	first element of the SEQUENCE <bcp14>SHOULD</bcp14> contain the object that
	contains the public key needed to directly validate the
	attestAttribute.  The remaining elements should chain that
	data back to an agreed upon root of trust for the attestation.
      </t>
      <sourcecode>
id-cra-attestChainCerts OBJECT IDENTIFIER ::= { id-cra 1 }
	
attestCertsAttribute ATTRIBUTE ::= {
  TYPE SEQUENCE OF CertificateChoice
  COUNTS MAX 1
  IDENTIFIED BY id-cra-attestChainCerts
}
      </sourcecode>

    </section>
    <section anchor="attestStatement" numbered="true" toc="default">
      <name>AttestStatement</name>
      <t>
	An AttestStatement is an object of class ATTEST-STATEMENT
	encoded as a sequence fields, of which the type of the "value"
	field is controlled by the value of the "type" field, similar
	to an Attribute definition.
      </t>
      <sourcecode>
	<![CDATA[
ATTEST-STATEMENT ::= CLASS {
  &id                 OBJECT IDENTIFIER UNIQUE,
  &Type,                  -- NOT optional
  &algidPresent       ParamOptions DEFAULT absent,
  &sigPresent         ParamOptions DEFAULT absent,
  &ancillaryPresent   ParamOptions DEFAULT absent,
  &sigType            DEFAULT OCTET STRING
  &ancillaryType      DEFAULT OCTET STRING
          
} WITH SYNTAX {
  TYPE  &Type
  IDENTIFIED BY &id
  [ALGID IS &algidPresent]
  [SIGNATURE [TYPE &sigType] IS &sigPresent]
  [ANCILLARY [TYPE &ancillaryType] IS &ancillaryPresent]
}

AttestStatement { ATTEST-STATEMENT:IOSet}  ::= SEQUENCE
  {
    type          ATTEST-STATEMENT.&id({IOSet}),
    value         ATTEST-STATEMENT.&Type({IOSet}{@type}),
    algId         [0] IMPLICIT  AlgorithmIdentifier OPTIONAL,
    signature     [1] ATTEST-STATEMENT.&sigType OPTIONAL -- NOT implicit
    ancillaryData [2] ATTEST-STATEMENT.&ancillaryType OPTIONAL
  }

	]]>
      </sourcecode>
      <t>
	Depending on whether the "value" field contains an entire
	signed attestation, or only the toBeSigned portion, the algId
	field may or may not be present.  If present it contains the
	AlgorithmIdentifier of the signature algorithm used to sign
	the attestation statement. If absent, either the value field
	contains an indication of the signature algorithm, or the
	signature algorithm is fixed for that specific type of
	AttestStatement.
      </t>
      <t>
	Similarly for the "signature" field, if the "value" field contains
	only the toBeSigned portion of the attestation statement, this
	field <bcp14>SHOULD</bcp14> be present. The "signature" field may by typed as
	any valid ASN.1 type. Opaque signature types <bcp14>SHOULD</bcp14> specify
	the use of sub-typed OCTET STRING.  For example:
      </t>
      
      <sourcecode>
MyOpaqueSignature ::= OCTET STRING
      </sourcecode>
      <t>
	If possible, the ATTEST-STATEMENT <bcp14>SHOULD</bcp14> specify an un-wrapped
	representation of a signature, rather than an OCTET STRING or
	BIT STRING wrapped ASN.1 structure. I.e., by specifying
	ECDSA-Sig-Value from PKIXAlgs-2009 to encode an ECDSA
	signature.
      </t>
      <sourcecode>
ECDSA-Sig-Value ::= SEQUENCE {
  r  INTEGER,
  s  INTEGER
}
      </sourcecode>
      
      <t>
	The ancillaryData field contains data provided externally to
	the attestation engine,and/or data that may be needed to
	relate the attestation to other PKIX elements. The format or
	content of the externally provided data is not under the
	control of the attestation engine.  For example, this field
	might contain a freshness nonce generated by the relying
	party, a signed time stamp, or even a hash of protocol data or
	nonce data.  See below for a few different examples.
      </t>
    
    </section>
  </section>
  <section anchor="IANA" numbered="true" toc="default">
    <name>IANA Considerations</name>
    <t>
      The IANA is requested to open two new registries and allocate a
      value from the "SMI Security for PKIX Module Identifier"
      registry for the included ASN.1 module.
    </t>
    <section anchor="craRegistry" numbered="true" toc="default">
      <name>"SMI Security for PKIX Certificate Signing Request
      Attributes" Registry</name>
      <t>
	Please open up a registry for CSR Attributes within the
	SMI-numbers registry, allocating an assignment from id-pkix
	("SMI Security for PKIX" Registry) for the purpose.
      </t>
	<t>Proposed Name: id-cra (id-cra OBJECT IDENTIFIER ::=
	{id-pkix (TBD) } )</t>
	<t>
	  Initial Contents
	</t>
	  <table anchor="idcra_initial">
	    <name>Initial entries for CSR Attributes registry</name>
	    <thead>
	      <tr>
		<th align='left'>Decimal</th>
		<th align='left'>Description</th>
		<th align='center'>References</th>
	      </tr>
	    </thead>
	    <tbody>
	      <tr>
		<td align='left'>1</td>
		<td align='left'>Attestation Certificate Chain</td>
	      	<td align='left'>This Doc</td>
	      </tr>
	      <tr>
		<td align='left'>2</td>
		<td align='left'>Attestation Statement</td>
	      	<td align='left'>This Doc</td>
	      </tr>
	      
	    </tbody>
	  </table>
    </section>
    <section anchor="ataRegistry" numbered="true" toc="default">
      <name>"SMI Security for PKIX Certificate Signing Request
      Attributes" Registry</name>
      <t>
	Please open up a registry for CSR Attributes within the
	SMI-numbers registry, allocating an assignment from id-pkix
	("SMI Security for PKIX" Registry) for the purpose.
      </t>
	<t>Proposed Name: id-ata (id-ata OBJECT IDENTIFIER ::=
	{id-pkix (TBD) }</t>
	<t>
	  Initial Contents - None.
	</t>

    </section>
    
  </section>
  <section anchor="Security" numbered="true" toc="default">
    <name>Security Considerations</name>
    <t>
      The attributes and structures defined in this document are
      primarily meant to be used as additional Attributes for a PKCS10
      Certification Signing Request (CSR).  As such, it's up to the
      receiving/relying party to place as much or as little trust in
      the contents of these attributes as necessary to satisfy its own policies.
    </t>
    <t>
      A relying party will need either a specification defining how an
      attestation type was formed and how to validate that type, or a
      trusted method of verifying the attestation.  In the former
      case, a relying party should consider the information available
      from any certificate chain covering the attesting key when
      deciding to accept the attestation.
    </t>
    <t>
      Most attestations will need to provide a method to convert the
      attested key representation into the equivalent SubjectPublicKey
      info structure and the attested key <bcp14>MUST</bcp14> be
      compared for equivalence to the public key provided in the CSR
      before accepting the attestation.
    </t>
    <t>
      The relying party, as always, is responsible for setting the
      rules for what it will accept.  The presence of an
      AttestAttribute is not required by any current standard, but
      such attribute may provide the relying party with additional
      assurance as a prerequisite to issuing certificates or other
      credentials.  That acceptance criteria is out of scope for this
      document. Whether to require an AttestAttribute or its contents
      in any specific use case is out-of-scope for this document.
    </t>
  </section>
</middle>
<!--  *****BACK MATTER ***** -->

<back>
  <references>
    <name>References</name>
    <references>
      <name>Normative References</name>
      <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
    </references>
    <references>
      <name>Informative References</name>
      <xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5912.xml"/>

      <reference anchor="TR-03110-3" target="https://www.bsi.bund.de/SharedDocs/Downloads/EN/BSI/Publications/TechGuidelines/TR03110/BSI_TR-03110_Part-3-V2_2.pdf?__blob=publicationFile&amp;v=1">
        <front>
            <title>Advanced Security Mechanisms for Machine Readable Travel Documents and eIDAS Token - Part 3 Common Specifications V2.21</title>
            <author>
              <organization>Federal Office for Information Security</organization>
	      
            </author>
            <date month="December" year="2016" />

        </front>
	<seriesInfo name="Technical Guideline" value="TR-03110" />
        <refcontent>Federal Republic of Germany</refcontent>
      </reference>
      <reference anchor="EQMV" target="https://www.secg.org/sec4-1.0.pdf">
	<front>
	  <title>
	    Elliptic Curve Qu-Vanstone Implicit Certificate Scheme (ECQV)
	  </title>
	  <author>
	    <organization>Certicom Research</organization>
	  </author>
	  <date month="January" year="2013"/>
	</front>
	<seriesInfo name="Standards for Efficient Cryptography" value="SEC-4"/>
      </reference>
      <referencegroup anchor="TPM20">
	<reference anchor="TPM20-Arch" target="https://trustedcomputinggroup.org/wp-content/uploads/TCG_TPM2_r1p59_Part1_Architecture_pub.pdf">
	  <front>
	    <title>Trusted Platform Module Library - Part 1: Architecture</title>
	    <author>
	      <organization>Trusted Computing Group</organization>
	    </author>
	    <date month="November" year="2019"/>
	  </front>
	  <seriesInfo name="TPM 2.0 Module Library" value="Part1, 00-01.59"/>
	</reference>
	<reference anchor="TPM20-Struct" target="https://trustedcomputinggroup.org/wp-content/uploads/TCG_TPM2_r1p59_Part2_Structures_pub.pdf">
	  <front>
	    <title>Trusted Platform Module Library - Part 2: Structures</title>
	    <author>
	      <organization>Trusted Computing Group</organization>
	    </author>
	    <date month="November" year="2019"/>
	  </front>
	  <seriesInfo name="TPM 2.0 Module Library" value="Part2, 00-01.59"/>
	</reference>
	<reference anchor="TPM20-Cmds" target="https://trustedcomputinggroup.org/wp-content/uploads/TCG_TPM2_r1p59_Part3_Commands_pub.pdf">
	  <front>
	    <title>Trusted Platform Module Library - Part 2: Commands</title>
	    <author>
	      <organization>Trusted Computing Group</organization>
	    </author>
	    <date month="November" year="2019"/>
	  </front>
	  <seriesInfo name="TPM 2.0 Module Library" value="Part2, 00-01.59"/>
	</reference>
	

      </referencegroup>

    
    </references>
  </references>
  <section anchor="examples" numbered="true" toc="default">
    <name>Examples</name>
    <section anchor="simpleattest" numbered="true" toc="default">
      <name>Simple Attestation Example</name>
      <t>
	This is a fragment of ASN.1 meant to demonstrate an absolute
	minimal definition of an ATTEST-STATEMENT.  A similar fragment
	could be used to define an ATTEST-STATEMENT for an opaque HSM
	vendor specific atterstation model.
      </t>
      <sourcecode>
	<![CDATA[
-- This OCTET STRING is not like any other OCTET STRING
-- Please see https://example.com/simple-attest.txt, 
-- Structure labled "Mike's simple attest" for the 
-- structure of this field and how to verify the attestation

MikesSimpleAttestData ::= OCTET STRING

mikesSimpleAttestOid OBJECT IDENTIFIER ::= { id-mikes-root 1 }

MikesSimpleAttest ATTEST-STATEMENT ::= {
  TYPE MikesSimpleAttestData
  IDENTIFIED BY mikesSimpleAttestOid
  -- These are all implied
  -- ALGID IS absent
  -- SIGNATURE is absent
  -- ANCILLARY is absent
}

	]]>
      </sourcecode>
    </section>
    <section anchor="tpmattest" numbered="true" toc="default">
      <name>Example TPM V2.0 Attestation Attribute - Non Normative</name>
      <t>
	What follows is a fragment of an ASN.1 module that might be
	used to define an attestation statment attribute to carry a
	TPM V2.0 key attestation - i.e., the output of the
	TPM2_Certify command.  This is an example and NOT a registered
	definition. It's provided simply to give an example of how to
	write an ATTEST-STATEMENT definition and module.
      </t>
      <sourcecode>
	<![CDATA[
-- IMPORT these.
-- PKI normal form for an ECDSA signature
ECDSA-Sig-Value ::= SEQUENCE {
  r INTEGER,
  s INTEGER
  }

-- Octet string of size n/8 where n is the
-- bit size of the public modulus
RSASignature ::= OCTET STRING

-- One or the other of these depending on the value in TPMT_SIGNATURE
TpmSignature CHOICE ::= {
  ecSig [0] IMPLICIT ECDSA-Sig-Value,
  rsaSig [1] IMPLICIT RSASignature
  }

-- The TPM form of the public key being attested.
-- Needed to verify the attestation - this is the TPMT_PUBLIC structure.
TpmtPublic ::= OCTET STRING

-- The TPMS_ATTEST structure as defined in TPM2.0
-- Unwrapped from the TPM2B_ATTEST provided
-- by the TPM2_Certify command.
TpmsAttest ::= OCTET STRING

-- The qualifying data provided to a TPM2_Certify call, may be absent
-- This is the contents of data field of the TPM2B_DATA structure.
QualifyingData ::= OCTET STRING

TpmAncillary ::= SEQUENCE {
   toBeAttestedPublic TpmtPublic,
   qualifyingData QualifyingData OPTIONAL
   }

-- This represents a maximally unwrapped TPM V2.0 attestation.  The
-- output of TPM2_Certify is a TPM2B_ATTEST and a TPMT_SIGNATURE.  
-- The former is unwrapped into a TPMS_ATTEST and the latter is 
-- decomposed to provide the contents of the algId and signature fields.

--
-- This attestation statement can be verified by:
-- Signature siggy = Signature.getInstance (stmt.algId);
-- siggy.init (attestPublicKey, VERIFY);
-- siggy.update ((short)stmt.value.length) // todo: big or little endian
-- siggy.update (stmt.value.data)
-- bool verified = siggy.verify (getSigData(stmt.signature)); //
unwrap the signature
--

TpmV2AttestStatement ATTEST STATEMENT ::= {
   TYPE TpmsAttest
   IDENTIFIED BY id-ata-tpmv20-1
   ALGID IS present
   SIGNATURE TYPE TpmSignature IS present
   ANCILLARY TYPE TpmAncillary IS present
   }

	]]>
      </sourcecode>

      <t>
	This attestation is the result of executing a TPM2_Certify
	command over a TPM key.  See <xref target="TPM20"/> for more details.
      </t>
      <t>
	The data portion of the value field encoded as OCTET STRING is
	the attestationData from the TPM2B_ATTEST produced by the
	TPM. In other words, strip off the TPM2B_ATTEST "size" field
	and place the TPMS_ATTEST encoded structure in the OCTET
	STRING data field.
      </t>
      <t>
	The algId is derived from the "sigAlg" field of the
	TPMT_SIGNATURE structure.
      </t>
      <t>
	The signature field is a TpmSignature, created by transforming
	the TPMU_SIGNATURE field to the appropriate structure given
	the signature type.
      </t>
      <t>
	The ancillary field contains a structure with the TPMT_PUBLIC
	structure that contains the TPM's format of the key to be
	attested.  The attestation statement data contains a hash of
	this structure, and not the key itself, so the hash of this
	structure needs to be compared to the value in the attestation
	attestation statement.  If that passes, the key needs to be
	transformed into a PKIX style key and compared to the key in
	the certificate signing request to complete the attestation
	verification.
      </t>
      <t>
	The ancillary field also contains an optional OCTET STRING
	which is used if the TPM2_Certify command is called with a
	non-zero length "qualifyingData" argument to contain that
	data. 
      </t>
      <t>
	An AttestCertChain attribute <bcp14>MUST</bcp14> be present if this attribute
	is used as part of a certificate signing request. 
      </t>
      <t>
	
      </t>
    </section>
    
  </section>
  <section anchor="asn1module" numbered="true" toc="default">
    <name>ASN.1 Module for Attestation</name>
    <t>The following module imports definitions from the modules defined in <xref target="RFC5912"/>.</t> 
    <t>IANA Note:  Please replace TBDMOD, TBD1 and TBD2 with assigned values.</t>
    <sourcecode>
      <![CDATA[
-- This module provides a definition for two attributes thay may be
-- used to carry key attestation information within a
-- CertificationSigningRequest (aka PKCS10), or for other purposes.

-- IANA - Value needed
Attest-2023
    {iso(1) identified-organization(3) dod(6) internet(1) security(5)
    mechanisms(5) pkix(7) id-mod(0) id-mod-pkix-attest-01(TBDMOD) }
    
DEFINITIONS EXPLICIT TAGS ::=
BEGIN

IMPORTS

Attribute, SingleAttribute, id-pkix, Certificate
FROM PKIX1Explicit-2009
      {iso(1) identified-organization(3) dod(6) internet(1)
      security(5) mechanisms(5) pkix(7) id-mod(0)
      id-mod-pkix1-explicit-02(51)}

ATTRIBUTE,AttributeSet
FROM PKIX-CommonTypes-2009
      {iso(1) identified-organization(3) dod(6) internet(1) security(5)
      mechanisms(5) pkix(7) id-mod(0) id-mod-pkixCommon-02(57)}

ParamChoice
FROM AlgorithmInformation-2009
    {iso(1) identified-organization(3) dod(6) internet(1) security(5)
    mechanisms(5) pkix(7) id-mod(0)
    id-mod-algorithmInformation-02(58)}

-- IANA - Values needed
-- Branch for attributes types for CSRs and related structures
id-cra OBJECT IDENTIFIER ::= { id-pkix (TBD1) }

-- Branch for attestation statement types
id-ata OBJECT IDENTIFIER ::= { id-pkix (TBD2) }

-- A general comment is that a certificate is a signed binding between
-- public key and some identifying info. Below "cert" is an X.509
-- "Certificate". "opaqueCert" is just string of bytes that the
-- receiving CA must know how to parse given information not carried
-- in this object.  "typedCert" and "typedFlatCert" both use an OID to
-- identify their types, but differ in that the encoding for typedCert
-- is always valid ASN1, whereas the typedFlatCert is just a string of
-- bytes that must be interpreted according to the type.  Note that a
-- typedFlatCert MAY contain an encapsulated ASN1 object, but this is
-- not the best use of the type and is hereby discouraged.
--

CertificateChoice ::=
   CHOICE {
      cert Certificate, -- typical X.509 cert
      opaqueCert [0] IMPLICIT OCTET STRING, -- an opaque cert who's type
                                            -- is known implicitly to
					    -- the responder
      typedCert [1] IMPLICIT TypedCert, -- a typed cert diff from X.509
                                        -- but ASN1 parseable
      typedFlatCert [2] IMPLICIT TypedFlatCert -- typed cert not ASN1 parseable
   }

-- Cribbed from definition of CONTENT-TYPE
-- Alternately as TypedCert ::= SingleAttribute
--
TYPED-CERT ::= TYPE-IDENTIFIER -- basically an object id and a matching ASN1
                               -- structure encoded as a sequence
CertType ::= TYPED-CERT.&id   

TypedCert ::= SEQUENCE {
              certType     TYPED-CERT.&id({TypedCertSet}),
              content      TYPED-CERT.&Type ({TypedCertSet}{@certType})
          }

TypedCertSet TYPED-CERT ::=
             ... -- Empty for now, 
             }


-- The receiving entity is expected to be able to parse the certBody field
-- given the value of the certType field.  This differs from TypedCert in that
-- the contents of the certBody field are not necessarily well formed ASN1
-- in this case the certType tells you how to parse the body of the OCTET STRING,

TypedFlatCert ::= SEQUENCE {
    certType OBJECT IDENTIFIER,
    certBody OCTET STRING
}	


-- A sequence of certificates used to validate an attestation chain.
-- By convention, the first certificate in the chain is the one that
-- contains the public key used to verify the attestation.  If the
-- related attestStatementAttribute contains more than a single
-- attestation, this attribute is expected to contain all of the
-- certificates needed to validate all attestations

id-cra-attestChainCerts OBJECT IDENTIFIER ::= { id-cra (1) }


attestCertsAttribute ATTRIBUTE ::= {
        TYPE SEQUENCE OF CertificateChoice
        COUNTS MAX 1
        IDENTIFIED BY id-cra-attestChainCerts
    }

-- If the signature is provided separately, the value field need not
-- contain the signature.  Note that some attestation methods include
-- a signature method in the part signed by the signature and some do
-- not.

ATTEST-STATEMENT ::= CLASS {
  &id                 OBJECT IDENTIFIER UNIQUE,
  &Type,                  -- NOT optional
  &algidPresent       ParamOptions DEFAULT absent,
  &sigPresent         ParamOptions DEFAULT absent,
  &sigType            DEFAULT OCTET STRING
  &ancillaryPresent   ParamOptions DEFAULT absent,
  &ancillaryType      DEFAULT OCTET STRING

} WITH SYNTAX {
  TYPE  &Type
  IDENTIFIED BY &id
  [ALGID IS &algidPresent]
  [SIGNATURE [TYPE &sigType] IS &sigPresent]
  [ANCILLARY [TYPE &ancillaryType] IS &ancillaryPresent]
}

AttestStatement { ATTEST-STATEMENT:IOSet}  ::= SEQUENCE
  {
    type          ATTEST-STATEMENT.&id({IOSet}),
    value         ATTEST-STATEMENT.&Type({IOSet}{@type}),
    algId         [0] IMPLICIT  AlgorithmIdentifier OPTIONAL,
    signature     [1] ATTEST-STATEMENT.&sigType OPTIONAL -- NOT implicit
    ancillaryData [2] ATTEST-STATEMENT.&ancillaryType OPTIONAL
  }

-- An attribute that contains a attestation statement.

id-cra-attestStatement OBJECT IDENTIFIER ::= { id-cra 2 }

attestAttribute ATTRIBUTE ::= {
        TYPE AttestStatement
        IDENTIFIED BY id-cra-attestStatement
    }

END


      ]]>
    </sourcecode>
  </section>
  <section numbered="false" toc="default">
    <name>Acknowledgements</name>
    <t>Thanks to Russ Housley for a first and useful pass over the
    original ASN.1. Thanks to Mike Ounsworth for not complaining too
    much when I wrote this. Placeholder here for people who spend time
    reviewing the draft!
    </t>
  </section>
</back>
</rfc>
