From: Nikos Mavrogianopoulos Subject: Re: Proposal for the ASN.1 form of TPM1.2 and TPM2 keys Date: Mon, 26 Dec 2016 08:18:02 +0100 Message-ID: References: <1482516363.2501.34.camel@HansenPartnership.com> <1482596030.2316.4.camel@HansenPartnership.com> <1482691491.3394.8.camel@HansenPartnership.com> <1482709652.3394.15.camel@HansenPartnership.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7781656521763754658==" Return-path: In-Reply-To: <1482709652.3394.15.camel@HansenPartnership.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gnutls-devel-bounces@lists.gnutls.org Sender: "Gnutls-devel" To: James Bottomley , Nikos Mavrogiannopoulos Cc: trousers-tech@lists.sourceforge.net, tpmdd-devel@lists.sourceforge.net, David Woodhouse , openssl-dev@openssl.org, GnuTLS development list List-Id: tpmdd-devel@lists.sourceforge.net --===============7781656521763754658== Content-Type: multipart/alternative; boundary="----FK1BSHHOV3AT47L0BUAOW7DQL5VL0L" Content-Transfer-Encoding: 8bit ------FK1BSHHOV3AT47L0BUAOW7DQL5VL0L Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 I'd like both backwards and forward compatibility actually, exactly like x509. If an informational field is added like the key usage that I mentioned, I doubt you'd like all the previous consumers incompatible. For other extensions which make the structure totally incompatible you can use the critical flag. Anyway even the original struct is OK, it is exactly like any other key structs we have. On December 26, 2016 12:47:32 AM GMT+01:00, James Bottomley wrote: >On Sun, 2016-12-25 at 22:08 +0100, Nikos Mavrogiannopoulos wrote: >> On Sun, Dec 25, 2016 at 7:44 PM, James Bottomley >> wrote: >> > > TPMKey ::= SEQUENCE { >> > > type OBJECT IDENTIFIER >> > > version [0] IMPLICIT INTEGER OPTIONAL >> > > emptyAuth [1] IMPLICIT BOOLEAN OPTIONAL >> > > parent [2] IMPLICIT INTEGER OPTIONAL >> > > publicKey [3] IMPLICIT OCTET STRING OPTIONAL >> > > privateKey OCTET STRING >> > > extensions [4] EXPLICIT Extensions OPTIONAL >> > > } >> > >> > Actually, that's the utility of ASN.1, once you use tagging, you >> > don't have to do this. The structure above is identical to: >> > >> > TPMKey ::= SEQUENCE { >> > type OBJECT IDENTIFIER >> > version [0] IMPLICIT INTEGER OPTIONAL >> > emptyAuth [1] IMPLICIT BOOLEAN OPTIONAL >> > parent [2] IMPLICIT INTEGER OPTIONAL >> > publicKey [3] IMPLICIT OCTET STRING OPTIONAL >> > privateKey OCTET STRING >> > } >> > >> > If tag 4 isn't present because optional tags are not coded when not >> > present, so you can expand any ASN.1 structure as long as you have >> > a clue from the version number that you should be looking for the >> > optional extras. The point being I don't have to specify the >> > expansion now, I can wait until we need it. >> >> How would that work for example if you want to add an additional >> field with information on the type of the key for example (key >> usage)? You would add the tag 4 as you say, and then all the previous > >> parsers written with the initial description will fail parsing the >> new structure. X.509 (==PKIX) is only expandable via the extensions >> field which is already defined. If you add a field to it, no parser >> would be able to read the certificate. > >Um, well, you only want backwards compatibility, you don't really want >forward compatibility. Assuming something extends the structure and >adds version v2, why would it matter that an old v1 application can't >read a v2 structure because it doesn't understand the tag 4? Even if >it could it can't make use of the extra fields and something nasty will >happen. What you want is that the new v2 application can parse both >the v2 structure and the old v1 one, but it's advantageous that a v1 >application fails with a v2 structure because it prevents cockups. > >James -- Sent from my Android device with K-9 Mail. Please excuse my brevity. ------FK1BSHHOV3AT47L0BUAOW7DQL5VL0L Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit I'd like both backwards and forward compatibility actually, exactly like x509. If an informational field is added like the key usage that I mentioned, I doubt you'd like all the previous consumers incompatible. For other extensions which make the structure totally incompatible you can use the critical flag. Anyway even the original struct is OK, it is exactly like any other key structs we have.

On December 26, 2016 12:47:32 AM GMT+01:00, James Bottomley <James.Bottomley@HansenPartnership.com> wrote:
On Sun, 2016-12-25 at 22:08 +0100, Nikos Mavrogiannopoulos wrote:
On Sun, Dec 25, 2016 at 7:44 PM, James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
TPMKey ::= SEQUENCE {
type OBJECT IDENTIFIER
version [0] IMPLICIT INTEGER OPTIONAL
emptyAuth [1] IMPLICIT BOOLEAN OPTIONAL
parent [2] IMPLICIT INTEGER OPTIONAL
publicKey [3] IMPLICIT OCTET STRING OPTIONAL
privateKey OCTET STRING
extensions [4] EXPLICIT Extensions OPTIONAL
}

Actually, that's the utility of ASN.1, once you use tagging, you
don't have to do this. The structure above is identical to:

TPMKey ::= SEQUENCE {
type OBJECT IDENTIFIER
version [0] IMPLICIT INTEGER OPTIONAL
emptyAuth [1] IMPLICIT BOOLEAN OPTIONAL
parent [2] IMPLICIT INTEGER OPTIONAL
publicKey [3] IMPLICIT OCTET STRING OPTIONAL
privateKey OCTET STRING
}

If tag 4 isn't present because optional tags are not coded when not
present, so you can expand any ASN.1 structure as long as you have
a clue from the version number that you should be looking for the
optional extras. The point bei ng I don't have to specify the
expansion now, I can wait until we need it.

How would that work for example if you want to add an additional
field with information on the type of the key for example (key
usage)? You would add the tag 4 as you say, and then all the previous
parsers written with the initial description will fail parsing the
new structure. X.509 (==PKIX) is only expandable via the extensions
field which is already defined. If you add a field to it, no parser
would be able to read the certificate.

Um, well, you only want backwards compatibility, you don't really want
forward compatibility. Assuming something extends the structure and
adds version v2, why would it matter that an old v1 application can't
read a v2 structure because it doesn't understand the tag 4? Even if
it could it can't make use of the extra fields and something nasty will
happen. What you want is that the new v2 application can parse both
the v2 structure and the old v1 one, but it's advantageous that a v1
application fails with a v2 structure because it prevents cockups.

James


--
Sent from my Android device with K-9 Mail. Please excuse my brevity. ------FK1BSHHOV3AT47L0BUAOW7DQL5VL0L-- --===============7781656521763754658== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Gnutls-devel mailing list Gnutls-devel@lists.gnutls.org http://lists.gnupg.org/mailman/listinfo/gnutls-devel --===============7781656521763754658==--