Subject: [Curdle] Wanted: A valid PKCS#8 file with attributes

From: Brian Smith <[email-masked]>
Date: Wed, 10 May 2017 09:42:20 -1000

Hi,

I've been creating some test vectors for Ed25519 and X25519 PKCS#8
files, some of which I've already shared on this list. I would like to
create some test vectors that include attributes, but I've not seen
any. If somebody could share an example of a valid PKCS#8 file with
attributes, especially ones that make sense for PKCS#8, that would be
very helpful.

Thanks,
Brian
-- 
https://briansmith.org/

---

From: Peter Gutmann <[email-masked]>
Date: Thu, 11 May 2017 10:10:47 +0000

Brian Smith <[email-masked]> writes:

>I've been creating some test vectors for Ed25519 and X25519 PKCS#8 files,
>some of which I've already shared on this list. I would like to create some
>test vectors that include attributes, but I've not seen any. If somebody
>could share an example of a valid PKCS#8 file with attributes, especially
>ones that make sense for PKCS#8, that would be very helpful.

Would PKCS #12 (containing a #8) do?  I have some samples of that created
under Windows, however there's also the code comment:

  11/6/13 - Windows sets these flags to what are effectively gibberish values
  (dataEncipherment for a signing key, digitalSignature for an encryption key)
  so in order to be able to use the key we have to ignore the keyUsage
  settings, in the same way that every other application seems to

so I'm not sure how useful they'll be given that you have to ignore them in
order to be able to use the key.

Peter.

---

From: Brian Smith <[email-masked]>
Date: Thu, 11 May 2017 10:00:25 -1000

Peter Gutmann <[email-masked]> wrote:
> Would PKCS #12 (containing a #8) do?  I have some samples of
> that created under Windows, however there's also the code
> comment:

Are the attributes in the PKCS#12 part or the PKCS#8 part?

It seems like it would be good to find an attribute that makes sense
for X25519 and one that makes sense for Ed25519. The point of the test
cases would be to indicate that one shouldn't reject a PKCS#8 document
just because it contains (an) attribute(s) that one doesn't process.

Cheers,
Brian
-- 
https://briansmith.org/

---

From: Ron Frederick <[email-masked]>
Date: Thu, 11 May 2017 21:14:06 -0700

> attributes, especially ones that make sense for PKCS#8, that would be

I support Ed25519 keys in AsyncSSH right now, but only in OpenSSH key format. I wasn’t aware that there was a PKCS#8 representation defined for these keys. Do you have a reference you can point at for that? I’d love to support it if a standard exists for it.

In a search, I just ran across https://tools.ietf.org/html/draft-ietf-curdle-pkix-04 <https://tools.ietf.org/html/draft-ietf-curdle-pkix-04> — is that what you are basing this on? Do you know of any implementations of this I’d be able to test against?

Regarding attributes, I know that PKCS#8 defines a way to include optional attributes in the PrivateKeyInfo structure, and that a list of possible attributes is defined in PKCS#9, but I don’t believe I’ve ever seen the attributes field used in any PKCS#8 private keys I’ve ever run across, or any options in tools like ssh-keygen or openssl to set them.
-- 
Ron Frederick
[email-masked]

---

From: Peter Gutmann <[email-masked]>
Date: Fri, 12 May 2017 08:28:08 +0000

>Are the attributes in the PKCS#12 part or the PKCS#8 part?

The PKCS #8 part, they follow the private key components (of the RSA key).

>It seems like it would be good to find an attribute that makes sense for
>X25519 and one that makes sense for Ed25519. 

As I mentioned, Microsoft's version doesn't make any sense for RSA let alone
'25519, so I guess if they did '25519 they'd set digitalSignature for X25519
and keyAgreement for Ed25519.  "You asked for attributes, you didn't say they
had to be valid" :-).

>The point of the test cases would be to indicate that one shouldn't reject a
>PKCS#8 document just because it contains (an) attribute(s) that one doesn't
>process.

Again, with this one it'd be not just an attribute you don't process but an
attribute you have to ignore for the key to be usable.

If you really wanted a '25519 PKCS #8 with attributes, and more importantly I
guess attributes that make sense, why not generate your own?  You just need to
write some arbitrary X.509 attributes after the key.  No-one seems to know
what to do with them so you can probably write almost anything without it
mattering much.

Peter.