Title: [221728] trunk/Source/WebCore
- Revision
- 221728
- Author
- [email protected]
- Date
- 2017-09-07 05:57:14 -0700 (Thu, 07 Sep 2017)
Log Message
[EME] CDMClearKey: implement remaining methods of CDMPrivate derivative
https://bugs.webkit.org/show_bug.cgi?id=176495
Reviewed by Xabier Rodriguez-Calvar.
Implement the remaining CDMPrivateClearKey methods, following the
ClearKey specification:
- server certificates are not supported, but sessions are;
- 'keyids' init data in JSON format is acceptable;
- JSON responses are acceptable;
- session IDs must use the 32-bit integer format.
No new tests -- covered by imported W3C tests that utilize ClearKey.
* platform/encryptedmedia/clearkey/CDMClearKey.cpp:
(WebCore::parseJSONObject):
(WebCore::CDMPrivateClearKey::loadAndInitialize):
(WebCore::CDMPrivateClearKey::supportsServerCertificates const):
(WebCore::CDMPrivateClearKey::supportsSessions const):
(WebCore::CDMPrivateClearKey::supportsInitData const):
(WebCore::CDMPrivateClearKey::sanitizeResponse const):
(WebCore::CDMPrivateClearKey::sanitizeSessionId const):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (221727 => 221728)
--- trunk/Source/WebCore/ChangeLog 2017-09-07 12:14:12 UTC (rev 221727)
+++ trunk/Source/WebCore/ChangeLog 2017-09-07 12:57:14 UTC (rev 221728)
@@ -1,3 +1,28 @@
+2017-09-07 Zan Dobersek <[email protected]>
+
+ [EME] CDMClearKey: implement remaining methods of CDMPrivate derivative
+ https://bugs.webkit.org/show_bug.cgi?id=176495
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ Implement the remaining CDMPrivateClearKey methods, following the
+ ClearKey specification:
+ - server certificates are not supported, but sessions are;
+ - 'keyids' init data in JSON format is acceptable;
+ - JSON responses are acceptable;
+ - session IDs must use the 32-bit integer format.
+
+ No new tests -- covered by imported W3C tests that utilize ClearKey.
+
+ * platform/encryptedmedia/clearkey/CDMClearKey.cpp:
+ (WebCore::parseJSONObject):
+ (WebCore::CDMPrivateClearKey::loadAndInitialize):
+ (WebCore::CDMPrivateClearKey::supportsServerCertificates const):
+ (WebCore::CDMPrivateClearKey::supportsSessions const):
+ (WebCore::CDMPrivateClearKey::supportsInitData const):
+ (WebCore::CDMPrivateClearKey::sanitizeResponse const):
+ (WebCore::CDMPrivateClearKey::sanitizeSessionId const):
+
2017-09-07 Carlos Garcia Campos <[email protected]>
[GTK] Bring back line height rounding when computing font metrics
Modified: trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp (221727 => 221728)
--- trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp 2017-09-07 12:14:12 UTC (rev 221727)
+++ trunk/Source/WebCore/platform/encryptedmedia/clearkey/CDMClearKey.cpp 2017-09-07 12:57:14 UTC (rev 221728)
@@ -35,9 +35,29 @@
#include "CDMRestrictions.h"
#include "CDMSessionType.h"
#include "SharedBuffer.h"
+#include <inspector/InspectorValues.h>
+using namespace Inspector;
+
namespace WebCore {
+RefPtr<InspectorObject> parseJSONObject(const SharedBuffer& buffer)
+{
+ // Fail on large buffers whose size doesn't fit into a 32-bit unsigned integer.
+ size_t size = buffer.size();
+ if (size > std::numeric_limits<unsigned>::max())
+ return nullptr;
+
+ // Parse the buffer contents as JSON, returning the root object (if any).
+ String json { buffer.data(), static_cast<unsigned>(size) };
+ RefPtr<InspectorValue> value;
+ RefPtr<InspectorObject> object;
+ if (!InspectorValue::parseJSON(json, value) || !value->asObject(object))
+ return nullptr;
+
+ return object;
+}
+
CDMFactoryClearKey& CDMFactoryClearKey::singleton()
{
static CDMFactoryClearKey s_factory;
@@ -139,31 +159,51 @@
void CDMPrivateClearKey::loadAndInitialize()
{
+ // No-op.
}
bool CDMPrivateClearKey::supportsServerCertificates() const
{
+ // Server certificates are not supported.
return false;
}
bool CDMPrivateClearKey::supportsSessions() const
{
- return false;
+ // Sessions are supported.
+ return true;
}
-bool CDMPrivateClearKey::supportsInitData(const AtomicString&, const SharedBuffer&) const
+bool CDMPrivateClearKey::supportsInitData(const AtomicString& initDataType, const SharedBuffer& initData) const
{
- return false;
+ // Fail for init data types other than 'keyids'.
+ if (!equalLettersIgnoringASCIICase(initDataType, "keyids"))
+ return false;
+
+ // Validate the initData buffer as an JSON object.
+ if (!parseJSONObject(initData))
+ return false;
+
+ return true;
}
-RefPtr<SharedBuffer> CDMPrivateClearKey::sanitizeResponse(const SharedBuffer&) const
+RefPtr<SharedBuffer> CDMPrivateClearKey::sanitizeResponse(const SharedBuffer& response) const
{
- return nullptr;
+ // Validate the response buffer as an JSON object.
+ if (!parseJSONObject(response))
+ return nullptr;
+
+ return response.copy();
}
-std::optional<String> CDMPrivateClearKey::sanitizeSessionId(const String&) const
+std::optional<String> CDMPrivateClearKey::sanitizeSessionId(const String& sessionId) const
{
- return std::nullopt;
+ // Validate the session ID string as an 32-bit integer.
+ bool ok;
+ sessionId.toUIntStrict(&ok);
+ if (!ok)
+ return std::nullopt;
+ return sessionId;
}
CDMInstanceClearKey::CDMInstanceClearKey() = default;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes