diff --git a/pyplayready/__init__.py b/pyplayready/__init__.py index 4147abb..cc207d3 100644 --- a/pyplayready/__init__.py +++ b/pyplayready/__init__.py @@ -10,4 +10,4 @@ from .session import * from .xml_key import * from .xmrlicense import * -__version__ = "0.3.8" +__version__ = "0.3.9" diff --git a/pyplayready/cdm.py b/pyplayready/cdm.py index cd034fc..6b88ef5 100644 --- a/pyplayready/cdm.py +++ b/pyplayready/cdm.py @@ -265,7 +265,7 @@ class Cdm: raise InvalidLicense("Public encryption key does not match") for key in parsed_licence.get_content_keys(): - if Key.CipherType(key.cipher_type) == Key.CipherType.ECC256: + if Key.CipherType(key.cipher_type) == Key.CipherType.ECC_256: session.keys.append(Key( key_id=UUID(bytes_le=key.key_id), key_type=key.key_type, diff --git a/pyplayready/key.py b/pyplayready/key.py index 601afde..23cde0f 100644 --- a/pyplayready/key.py +++ b/pyplayready/key.py @@ -6,12 +6,12 @@ from typing import Union class Key: class KeyType(Enum): - Invalid = 0x0000 - AES128CTR = 0x0001 - RC4 = 0x0002 - AES128ECB = 0x0003 - Cocktail = 0x0004 - AES128CBC = 0x0005 + INVALID = 0x0000 + AES_128_CTR = 0x0001 + RC4_CIPHER = 0x0002 + AES_128_ECB = 0x0003 + COCKTAIL = 0x0004 + AES_128_CBC = 0x0005 UNKNOWN = 0xffff @classmethod @@ -19,12 +19,12 @@ class Key: return cls.UNKNOWN class CipherType(Enum): - Invalid = 0x0000 - RSA128 = 0x0001 - ChainedLicense = 0x0002 - ECC256 = 0x0003 - ECCforScalableLicenses = 0x0004 - Scalable = 0x0005 + INVALID = 0x0000 + RSA_1024 = 0x0001 + CHAINED_LICENSE = 0x0002 + ECC_256 = 0x0003 + ECC_256_WITH_KZ = 0x0004 + SCALABLE = 0x0005 UNKNOWN = 0xffff @classmethod diff --git a/pyplayready/serve.py b/pyplayready/serve.py index b17da80..a1de8be 100644 --- a/pyplayready/serve.py +++ b/pyplayready/serve.py @@ -5,11 +5,11 @@ from typing import Any, Optional, Union from aiohttp.typedefs import Handler from aiohttp import web -from pyplayready import __version__ +from pyplayready import __version__, PSSH from pyplayready.cdm import Cdm from pyplayready.device import Device -from pyplayready.exceptions import (InvalidSession, TooManySessions, InvalidLicense) +from pyplayready.exceptions import (InvalidSession, TooManySessions, InvalidLicense, InvalidPssh) routes = web.RouteTableDef() @@ -134,6 +134,18 @@ async def get_license_challenge(request: web.Request) -> web.Response: # get init data init_data = body["init_data"] + if not init_data.startswith(" web.Response: }, status=400) except Exception as e: return web.json_response({ - "status": 400, + "status": 500, "message": f"Error, {e}" - }, status=400) + }, status=500) return web.json_response({ "status": 200, @@ -199,9 +211,9 @@ async def parse_license(request: web.Request) -> web.Response: }, status=400) except Exception as e: return web.json_response({ - "status": 400, + "status": 500, "message": f"Error, {e}" - }, status=400) + }, status=500) return web.json_response({ "status": 200, @@ -243,9 +255,9 @@ async def get_keys(request: web.Request) -> web.Response: }, status=400) except Exception as e: return web.json_response({ - "status": 400, + "status": 500, "message": f"Error, {e}" - }, status=400) + }, status=500) # get the keys in json form keys_json = [ diff --git a/pyproject.toml b/pyproject.toml index 7840e7e..39bf93e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "pyplayready" -version = "0.3.8" +version = "0.3.9" description = "pyplayready CDM (Content Decryption Module) implementation in Python." license = "CC BY-NC-ND 4.0" authors = ["DevLARLEY, Erevoc", "DevataDev"]