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

Unified Diff: Source/core/platform/chromium/support/WebCryptoKey.cpp

Issue 18033004: WebCrypto: Add WebKit API structure for keys. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase onto master Created 7 years, 5 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/core/core.gypi ('k') | Source/modules/crypto/Algorithm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/chromium/support/WebCryptoKey.cpp
diff --git a/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp b/Source/core/platform/chromium/support/WebCryptoKey.cpp
similarity index 52%
copy from Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp
copy to Source/core/platform/chromium/support/WebCryptoKey.cpp
index 0ca2d40f74416e44425edef012e6487de724817d..a239917fd6674bf62d0eee18971552db0a8affab 100644
--- a/Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp
+++ b/Source/core/platform/chromium/support/WebCryptoKey.cpp
@@ -29,70 +29,70 @@
*/
#include "config.h"
-#include "public/platform/WebCryptoAlgorithm.h"
+#include "public/platform/WebCryptoKey.h"
-#include "public/platform/WebCryptoAlgorithmParams.h"
+#include "public/platform/WebCryptoAlgorithm.h"
#include "wtf/OwnPtr.h"
#include "wtf/ThreadSafeRefCounted.h"
namespace WebKit {
-class WebCryptoAlgorithmPrivate : public ThreadSafeRefCounted<WebCryptoAlgorithmPrivate> {
+class WebCryptoKeyPrivate : public ThreadSafeRefCounted<WebCryptoKeyPrivate> {
public:
- WebCryptoAlgorithmPrivate(WebCryptoAlgorithmId algorithmId, const char* algorithmName, PassOwnPtr<WebCryptoAlgorithmParams> params)
- : algorithmId(algorithmId)
- , algorithmName(algorithmName)
- , params(params)
+ WebCryptoKeyPrivate(PassOwnPtr<WebCryptoKeyHandle> handle, WebCryptoKeyType type, bool extractable, const WebCryptoAlgorithm& algorithm, WebCryptoKeyUsageMask keyUsage)
+ : handle(handle)
+ , type(type)
+ , extractable(extractable)
+ , algorithm(algorithm)
+ , keyUsage(keyUsage)
{
}
- WebCryptoAlgorithmId algorithmId;
- const char* const algorithmName;
- OwnPtr<WebCryptoAlgorithmParams> params;
+ const OwnPtr<WebCryptoKeyHandle> handle;
+ const WebCryptoKeyType type;
+ const bool extractable;
+ const WebCryptoAlgorithm algorithm;
+ const WebCryptoKeyUsageMask keyUsage;
};
-WebCryptoAlgorithm::WebCryptoAlgorithm(WebCryptoAlgorithmId algorithmId, const char* algorithmName, PassOwnPtr<WebCryptoAlgorithmParams> params)
- : m_private(adoptRef(new WebCryptoAlgorithmPrivate(algorithmId, algorithmName, params)))
+WebCryptoKey WebCryptoKey::create(WebCryptoKeyHandle* handle, WebCryptoKeyType type, bool extractable, const WebCryptoAlgorithm& algorithm, WebCryptoKeyUsageMask keyUsage)
{
+ WebCryptoKey key;
+ key.m_private = adoptRef(new WebCryptoKeyPrivate(adoptPtr(handle), type, extractable, algorithm, keyUsage));
+ return key;
}
-WebCryptoAlgorithmId WebCryptoAlgorithm::algorithmId() const
+WebCryptoKeyHandle* WebCryptoKey::handle() const
{
- return m_private->algorithmId;
+ return m_private->handle.get();
}
-const char* WebCryptoAlgorithm::algorithmName() const
+WebCryptoKeyType WebCryptoKey::type() const
{
- return m_private->algorithmName;
+ return m_private->type;
}
-WebCryptoAlgorithmParamsType WebCryptoAlgorithm::paramsType() const
+bool WebCryptoKey::extractable() const
{
- if (!m_private->params)
- return WebCryptoAlgorithmParamsTypeNone;
- return m_private->params->type();
+ return m_private->extractable;
}
-WebCryptoAesCbcParams* WebCryptoAlgorithm::aesCbcParams() const
+const WebCryptoAlgorithm& WebCryptoKey::algorithm() const
{
- if (paramsType() == WebCryptoAlgorithmParamsTypeAesCbcParams)
- return static_cast<WebCryptoAesCbcParams*>(m_private->params.get());
- return 0;
+ return m_private->algorithm;
}
-WebCryptoAesKeyGenParams* WebCryptoAlgorithm::aesKeyGenParams() const
+WebCryptoKeyUsageMask WebCryptoKey::keyUsage() const
{
- if (paramsType() == WebCryptoAlgorithmParamsTypeAesKeyGenParams)
- return static_cast<WebCryptoAesKeyGenParams*>(m_private->params.get());
- return 0;
+ return m_private->keyUsage;
}
-void WebCryptoAlgorithm::assign(const WebCryptoAlgorithm& other)
+void WebCryptoKey::assign(const WebCryptoKey& other)
{
m_private = other.m_private;
}
-void WebCryptoAlgorithm::reset()
+void WebCryptoKey::reset()
{
m_private.reset();
}
« no previous file with comments | « Source/core/core.gypi ('k') | Source/modules/crypto/Algorithm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698