Support exporting symmetric keys as JWK
https://bugs.webkit.org/show_bug.cgi?id=124442

Reviewed by Sam Weinig.

Source/JavaScriptCore: 

* runtime/JSONObject.h: Export JSONStringify.

Source/WebCore: 

Error handling is not consistent yet - some errors cause exceptions, and others
result in rejected promises. This part of spec is incomplete, so I basically did
what was most straightforward in each case.

* bindings/js/JSCryptoKeySerializationJWK.h: 
* bindings/js/JSCryptoKeySerializationJWK.cpp:
(WebCore::JSCryptoKeySerializationJWK::reconcileUsages): Updated a comment with a better link.
(WebCore::JSCryptoKeySerializationJWK::buildJSONForOctetSequence): A helper to building JWK.
(WebCore::JSCryptoKeySerializationJWK::addToJSON): Ditto.
(WebCore::JSCryptoKeySerializationJWK::addBoolToJSON): Ditto.
(WebCore::JSCryptoKeySerializationJWK::addJWKAlgorithmToJSON): Ditto. The code for
mapping is my best guess, this all needs to be specified.
(WebCore::JSCryptoKeySerializationJWK::addJWKUseToJSON): A helper to building JWK.
(WebCore::JSCryptoKeySerializationJWK::serialize): Build a JSON string for the key.

* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::JSSubtleCrypto::importKey): Updated a comment.
(WebCore::JSSubtleCrypto::exportKey): Use CryptoKeySerialization (also for raw keys,
for consistency).

* crypto/CryptoKey.h:
(WebCore::CryptoKey::algorithmIdentifier):
(WebCore::CryptoKey::usagesBitmap):
Exposed data needed for building JWK (it used to be only exposed in a form suitable
for DOM accessors).

* crypto/keys/CryptoKeyHMAC.h: Ditto, added an accessor for JWK.

* crypto/keys/CryptoKeySerializationRaw.cpp: (WebCore::CryptoKeySerializationRaw::serialize):
* crypto/keys/CryptoKeySerializationRaw.h:
Moved from JSSubtleCryptoCustom.cpp for consistency.

Source/WTF: 

Base64URL encoding doesn't use '=' padding, and doesn't need any other options.
Added this mode for encode, and removed policy arguments from exposed functions.

* wtf/text/Base64.cpp:
(WTF::base64EncodeInternal):
(WTF::base64URLEncode):
(WTF::base64URLDecode):
* wtf/text/Base64.h:
(WTF::base64URLEncode):

LayoutTests: 

* crypto/subtle/aes-export-key-expected.txt:
* crypto/subtle/aes-export-key.html:
* crypto/subtle/hmac-export-key-expected.txt:
* crypto/subtle/hmac-export-key.html:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159377 268f45cc-cd09-0410-ab3c-d52691b4dbfc