crypto.subtle.wrapKey "jwk" format returns ArrayBuffer objects
Reported by
francois...@intel.com,
Mar 10 2016
|
|||
Issue descriptionChrome Version : 48 URLs (if applicable) : https://diafygi.github.io/webcrypto-examples/ Other browsers tested: N/A What steps will reproduce the problem? (1) use window.crypto.subtle.wrapKey with "jwk" format, it always returns an ArrayBuffer object (even in your test suite https://chromium.googlesource.com/chromium/blink/+/72fef91ac1ef679207f51def8133b336a6f6588f/LayoutTests/crypto/rsa-oaep-wrap-unwrap-aes.html) What is the expected result? window.crypto.subtle.wrapKey when used with "jwk" format should return an object that can be converted to JSON using JSON.stringify. What happens instead? I get an ArrayBuffer object that I cannot convert to valid JWT JSON...
,
Jun 16 2016
,
Jun 16 2016
WontFix as this it is working as intended. wrapKey() with 'jwk' is expected to return an ArrayBuffer, NOT a JWT: https://w3c.github.io/webcrypto/Overview.html#dfn-SubtleCrypto-method-wrapKey 'jwk' in this case simply tells it what format to export the key in prior to encryption.
,
Jun 16 2016
If you are unhappy with this behavior best to take it up with the spec: https://github.com/w3c/webcrypto/issues
,
Jun 16 2016
Hmmm , but the spec you link to says: ==== If format is equal to the string "jwk": Convert key to an ECMAScript Object, as specified in [ WebIDL]. Let json be the result of representing key as a UTF-16 string conforming to the JSON grammar; for example, by executing the JSON.stringify algorithm specified in ECMA262. Let bytes be the byte sequence the results from converting json, a JavaScript String comprised of UTF-16 code points, to UTF-8 code points. == Also in the spec https://w3c.github.io/webcrypto/Overview.html#subtlecrypto-interface-datatypes "jwk": The key is a JsonWebKey dictionary encoded as a JavaScript object ====
,
Jun 16 2016
That is step 14. And then in the following step (15) you call the wrapKey() or encrypt() operation on that, which outputs BYTES.
So let's say you are doing:
wrapKey('jwk', key, wrappingKey, wrapAlgorithm='aes-cbc')
Conceptually this boils down to:
AesCbcEncryptBytes(wrappingKey, ExportKeyToJsonBytes(key))
The step 14 is that ExportKeyToJsonBytes(key) expression above.
The output from wrapKey() is always going to be ciphered bytes.
Certainly it wouldn't make sense for the output to be a JWK.
As far as a JWT, isn't that just a delivery vehicle for signed data? That wouldn't be appropriate here either, but I suppose it could be crammed into a JWT.
,
Jun 16 2016
OK I guess that's an impedance mismatch between JWK RFC and the W3C spec For instance https://tools.ietf.org/html/rfc7520#section-5.8 Ultimately what I want to make sure is that it can be make cross platform / cross technology.
,
Jun 16 2016
Ah, so your expectation was to get a JWE out? JOSE is not my area of expertise; I suggest asking questions either on the webcrypto spec github issues (https://github.com/w3c/webcrypto/issues), or on the WG's mailing list (public-webcrypto@w3.org). That said there were numerous discussions about the interop of these standards, so I don't expect this is going to be changed.
,
Jun 16 2016
There are no plans for the Chrome team to support JWE, and that was intentional and, as Eric mentioned, discussed at great length. The public-webcrypto archives have extensive documentation of the 2+ years of discussion about JOSE specs, for which the final decision was that WebCrypto is *NOT* a JOSE API and it does not emit JOSE objects. |
|||
►
Sign in to add a comment |
|||
Comment 1 by kavvaru@chromium.org
, Mar 10 2016