[SVG Masking] Enable the use of <mask> elements for -webkit-mask-image
[WebKit-https.git] / Source / WebCore / crypto / CryptoKey.h
index a43accb..7df9e1a 100644 (file)
 #ifndef CryptoKey_h
 #define CryptoKey_h
 
+#if ENABLE(SUBTLE_CRYPTO)
+
 #include "CryptoAlgorithmIdentifier.h"
 #include "CryptoKeyType.h"
 #include "CryptoKeyUsage.h"
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
+#include <wtf/TypeCasts.h>
 #include <wtf/Vector.h>
 
-#if ENABLE(SUBTLE_CRYPTO)
-
 namespace WebCore {
 
 class CryptoAlgorithmDescriptionBuilder;
+class CryptoKeyData;
 
-ENUM_CLASS(CryptoKeyClass) {
+enum class CryptoKeyClass {
     HMAC,
-    AES
+    AES,
+    RSA
 };
 
 class CryptoKey : public RefCounted<CryptoKey> {
@@ -56,8 +59,14 @@ public:
     virtual void buildAlgorithmDescription(CryptoAlgorithmDescriptionBuilder&) const;
     Vector<String> usages() const;
 
+    CryptoAlgorithmIdentifier algorithmIdentifier() const { return m_algorithm; }
+    CryptoKeyUsage usagesBitmap() const { return m_usages; }
     bool allows(CryptoKeyUsage usage) const { return usage == (m_usages & usage); }
 
+    virtual std::unique_ptr<CryptoKeyData> exportData() const = 0;
+
+    static Vector<uint8_t> randomData(size_t);
+
 private:
     CryptoAlgorithmIdentifier m_algorithm;
     CryptoKeyType m_type;
@@ -67,5 +76,10 @@ private:
 
 } // namespace WebCore
 
+#define SPECIALIZE_TYPE_TRAITS_CRYPTO_KEY(ToClassName, KeyClass) \
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ToClassName) \
+    static bool isType(const WebCore::CryptoKey& key) { return key.keyClass() == WebCore::KeyClass; } \
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // ENABLE(SUBTLE_CRYPTO)
 #endif // CryptoKey_h