Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1481)

Unified Diff: Source/modules/crypto/SubtleCrypto.cpp

Issue 23592023: WebCrypto: Add interface for exportKey(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase, add test expectations, remove platformCrypto nullity check Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/crypto/SubtleCrypto.h ('k') | Source/modules/crypto/SubtleCrypto.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/SubtleCrypto.cpp
diff --git a/Source/modules/crypto/SubtleCrypto.cpp b/Source/modules/crypto/SubtleCrypto.cpp
index 06213e14adb32cc8e80877ba56c444623e598a82..25c0d724e0f4445f144fed87ce2474ed6d77e544 100644
--- a/Source/modules/crypto/SubtleCrypto.cpp
+++ b/Source/modules/crypto/SubtleCrypto.cpp
@@ -176,4 +176,25 @@ ScriptObject SubtleCrypto::importKey(const String& rawFormat, ArrayBufferView* k
return result->promise();
}
+ScriptObject SubtleCrypto::exportKey(const String& rawFormat, Key* key, ExceptionState& es)
+{
+ WebKit::WebCryptoKeyFormat format;
+ if (!Key::parseFormat(rawFormat, format, es))
+ return ScriptObject();
+
+ if (!key) {
+ es.throwTypeError("Invalid key argument");
+ return ScriptObject();
+ }
+
+ if (!key->extractable()) {
+ es.throwDOMException(NotSupportedError, "key is not extractable");
+ return ScriptObject();
+ }
+
+ RefPtr<CryptoResult> result = CryptoResult::create();
+ WebKit::Platform::current()->crypto()->exportKey(format, key->key(), result->result());
+ return result->promise();
+}
+
} // namespace WebCore
« no previous file with comments | « Source/modules/crypto/SubtleCrypto.h ('k') | Source/modules/crypto/SubtleCrypto.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698