summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 22:24:37 +0000
committereroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 22:24:37 +0000
commitb7deaa08d0df8e73a0351c00612afc8ec087d713 (patch)
treeeb50b73bff4ae3fba6fc0f10cb81a272dd8c7dda
parent426ccf89ffc1cb33f0929d1869944c933817acc6 (diff)
downloadchromium_src-b7deaa08d0df8e73a0351c00612afc8ec087d713.zip
chromium_src-b7deaa08d0df8e73a0351c00612afc8ec087d713.tar.gz
chromium_src-b7deaa08d0df8e73a0351c00612afc8ec087d713.tar.bz2
[webcrypto] exportKey() now returns dictionary when format='jwk' (CL 1 of 2).
Previously it would return an array buffer of the JSON. This corresponds with the recent spec update: https://dvcs.w3.org/hg/webcrypto-api/rev/f61017a76a5d BUG=373917, 245025 R=rsleevi@chromium.org Review URL: https://codereview.chromium.org/334333004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277884 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/child/webcrypto/webcrypto_impl.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/content/child/webcrypto/webcrypto_impl.cc b/content/child/webcrypto/webcrypto_impl.cc
index ef0740b..3eed927 100644
--- a/content/child/webcrypto/webcrypto_impl.cc
+++ b/content/child/webcrypto/webcrypto_impl.cc
@@ -457,7 +457,24 @@ void DoImportKey(scoped_ptr<ImportKeyState> passed_state) {
}
void DoExportKeyReply(scoped_ptr<ExportKeyState> state) {
+#ifndef WEBCRYPTO_RESULT_ACCEPTS_JSON
+ // TODO(eroman): Remove idfef once blink rolls.
CompleteWithBufferOrError(state->status, state->buffer, &state->result);
+#else
+ if (state->format != blink::WebCryptoKeyFormatJwk) {
+ CompleteWithBufferOrError(state->status, state->buffer, &state->result);
+ return;
+ }
+
+ if (state->status.IsError()) {
+ CompleteWithError(state->status, &state->result);
+ } else {
+ state->result.completeWithJson(
+ reinterpret_cast<const char*>(
+ webcrypto::Uint8VectorStart(&state->buffer)),
+ state->buffer.size());
+ }
+#endif
}
void DoExportKey(scoped_ptr<ExportKeyState> passed_state) {