[Internet]Re: "Pluggable" key serialization in JCE/JCA

Bernd Eckenfels ecki at zusammenkunft.net
Sat Mar 26 22:14:52 UTC 2022


Just for completeness, the standard for key transport in JOSE is JWK (RFC7517).

In COSE it is a COSE_Key(Set) as defined in RFC8152 sect13.

BTW the most widely used CBOR/COSE application are probably the QR codes around Covid and Vaccination certificates of the EU.

Gruss
Bernd
--
http://bernd.eckenfels.net
________________________________
Von: security-dev <security-dev-retn at openjdk.java.net> im Auftrag von Michael StJohns <mstjohns at comcast.net>
Gesendet: Samstag, März 26, 2022 10:29 PM
An: security-dev at openjdk.java.net <security-dev at openjdk.java.net>
Betreff: Re: [Internet]Re: "Pluggable" key serialization in JCE/JCA

On 3/26/2022 11:05 AM, xueleifan(XueleiFan) wrote:
> Hi Anders,
>
> I would like to have look at the COSE/JOSE specs.  If it is convenient to you, any suggestions about where I could start from? RFC 8812?  Do you know where (areas and products) the COSE/JOSE specs are used in practice?
>
> Thanks,
> Xuelei

Hi Xuelei -

Just for clarification - JOSE/COSE are data description languages  with
specific provisions for encoding various type of cryptographic key
material.  E.g. think ASN1 ~= JOSE or COSE and the RFC's that Anders is
pointing you at as approximately equal to PKCS8 and X.509 plus the key
type specific stuff (e.g. PKCS1 for RSA key encodings, X9.63 for EC key
encodings, later IETF RFCs for newer encodings).

This isn't about math so much as it is about encodings.

Mike

>
>> On Mar 25, 2022, at 11:56 AM, Anders Rundgren <anders.rundgren.net at gmail.com> wrote:
>>
>> Hi Michael & the JDK crypto team,
>>
>> Although it might be cool writing a JEP it is not really my job.  There are also multiple ways of addressing this issue.
>>
>> BTW, the COSE/JOSE folks who are about to introduce new algorithms want to overload RFC 8037 which defines a key type OKP.
>> I'm not in favor of this idea since breaks existing OKP code.
>> I'm suggesting that each new crypto system should get its own name space and thus long-term corresponding Java interfaces.
>>
>> Since this is happening NOW and there is no turning back, it would be useful to get some early feedback from the JDK folks.  In fact, this is the origin of this request.
>>
>> It seems that nobody representing JDK crypto is involved in COSE/JOSE.
>>
>> Thanx,
>> Anders
>>
>>
>> On 2022-03-25 18:23, Michael StJohns wrote:
>>> On 3/25/2022 12:33 PM, Anders Rundgren wrote:
>>>> On 2022-03-25 17:12, Anthony Scarpino wrote:
>>>>> When you say "construct and EC key", do you mean creating an EC key from
>>>>> an existing set of values via PKCS8 or X509 encoding?  Or are you
>>>>> talking about EC key generation?
>>>> I was talking about creating keys from parameter data supplied by for
>>>> example JOSE:
>>>>    {
>>>>      "kty": "EC",
>>>>      "crv": "P-256",
>>>>      "x": "6BKxpty8cI-exDzCkh-goU6dXq3MbcY0cd1LaAxiNrU",
>>>>      "y": "mCbcvUzm44j3Lt2b5BPyQloQ91tf2D2V-gzeUxWaUdg"
>>>>    }
>>>>
>>>> Apparently this particular issue have solution (as Michael StJohns
>>>> showed), although it is not particularity intuitive as well as
>>>> undocumented.
>>>>
>>>> Another take on this issue:
>>>> https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/security/Key.html#getEncoded()
>>>>
>>>> "Returns the key in its primary encoding format, or null if this key
>>>> does not support encoding"
>>>>
>>>> With COSE/JOSE there is no longer an obvious primary encoding format.
>>> Of course there is.  You may not like that it's not COSE or JOSE, but
>>> the encoding spec remains as is and 10s of 1000s of implementations that
>>> use that encoding would be annoyed if you tried to claim a new "primary
>>> encoding format".
>>> The SubjectPublicKeyInfo encoding for PublicKeys, the PKCS8 encoding for
>>> private keys, and RAW encoding for SecretKeys is what's there and I'm
>>> pretty sure won't change.  I occasionally wished for a getEncoded()
>>> method that took an encoding type as an argument (e.g.
>>> getEncoded("bareXY") or some such), but that's not in the API.
>>> What I'd suggest is that you write a JEP for adding EncodedKeySpec
>>> classes for COSE and JOSE to the API.   I'd probably also add a
>>> GenericKeyEncodingSpec class.  That should be simple enough as a first step.
>>> The second step would be to write and contribute a Jose and Cose
>>> KeyFactory implementation that uses those classes.
>>> As I noted, it should be possible to externalize any preferred encoding
>>> by using the getKeySpec method of KeyFactory rather than just the key
>>> types default encoding.
>>> Later, Mike
>>>> Anders
>>>>
>>>>> Tony
>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/security-dev/attachments/20220326/ee7fe57c/attachment.htm>


More information about the security-dev mailing list