Index: public/platform/WebCryptoKeyAlgorithmParams.h |
diff --git a/public/platform/WebCryptoKeyAlgorithmParams.h b/public/platform/WebCryptoKeyAlgorithmParams.h |
index d71c6f086f399affab35891ac797ae1117cbb52a..903d32c146a58b3d65bb7b09d1ec13487f2b7da9 100644 |
--- a/public/platform/WebCryptoKeyAlgorithmParams.h |
+++ b/public/platform/WebCryptoKeyAlgorithmParams.h |
@@ -37,6 +37,18 @@ |
namespace blink { |
+// Interface used for serializing WebCryptoKeyAlgorithmParams to a javascript |
+// dictionary. |
+class WebCryptoKeyAlgorithmDictionary { |
+public: |
+ virtual ~WebCryptoKeyAlgorithmDictionary() { } |
+ |
+ virtual void setString(const char*, const char*) = 0; |
+ virtual void setUint(const char*, unsigned) = 0; |
+ virtual void setAlgorithm(const char*, const WebCryptoAlgorithm&) = 0; |
+ virtual void setUint8Array(const char*, const WebVector<unsigned char>&) = 0; |
+}; |
+ |
enum WebCryptoKeyAlgorithmParamsType { |
WebCryptoKeyAlgorithmParamsTypeNone, |
WebCryptoKeyAlgorithmParamsTypeHmac, |
@@ -51,6 +63,8 @@ public: |
{ |
return WebCryptoKeyAlgorithmParamsTypeNone; |
} |
+ |
+ virtual void writeToDictionary(WebCryptoKeyAlgorithmDictionary*) const = 0; |
}; |
class WebCryptoAesKeyAlgorithmParams : public WebCryptoKeyAlgorithmParams { |
@@ -70,6 +84,11 @@ public: |
return WebCryptoKeyAlgorithmParamsTypeAes; |
} |
+ virtual void writeToDictionary(WebCryptoKeyAlgorithmDictionary* dict) const |
+ { |
+ dict->setUint("length", m_lengthBits); |
+ } |
+ |
private: |
unsigned short m_lengthBits; |
}; |
@@ -97,6 +116,12 @@ public: |
return WebCryptoKeyAlgorithmParamsTypeHmac; |
} |
+ virtual void writeToDictionary(WebCryptoKeyAlgorithmDictionary* dict) const |
+ { |
+ dict->setAlgorithm("hash", m_hash); |
+ dict->setUint("length", m_lengthBits); |
+ } |
+ |
private: |
WebCryptoAlgorithm m_hash; |
unsigned m_lengthBits; |
@@ -131,6 +156,13 @@ public: |
return WebCryptoKeyAlgorithmParamsTypeRsaHashed; |
} |
+ virtual void writeToDictionary(WebCryptoKeyAlgorithmDictionary* dict) const |
+ { |
+ dict->setAlgorithm("hash", m_hash); |
+ dict->setUint("modulusLength", m_modulusLengthBits); |
+ dict->setUint8Array("publicExponent", m_publicExponent); |
+ } |
+ |
private: |
unsigned m_modulusLengthBits; |
WebVector<unsigned char> m_publicExponent; |