+ int -> bytes conversion fix
This commit is contained in:
parent
e5782f5674
commit
91db649c9c
|
@ -11,4 +11,4 @@ from pyplayready.system.pssh import *
|
||||||
from pyplayready.system.session import *
|
from pyplayready.system.session import *
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.4.4"
|
__version__ = "0.4.5"
|
||||||
|
|
|
@ -68,11 +68,18 @@ class ECCKey:
|
||||||
path.parent.mkdir(parents=True, exist_ok=True)
|
path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
path.write_bytes(self.dumps(private_only))
|
path.write_bytes(self.dumps(private_only))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _to_bytes(n: int) -> bytes:
|
||||||
|
byte_len = (n.bit_length() + 7) // 8
|
||||||
|
if byte_len % 2 != 0:
|
||||||
|
byte_len += 1
|
||||||
|
return n.to_bytes(byte_len, 'big')
|
||||||
|
|
||||||
def get_point(self, curve: Curve) -> Point:
|
def get_point(self, curve: Curve) -> Point:
|
||||||
return Point(self.key.pointQ.x, self.key.pointQ.y, curve)
|
return Point(self.key.pointQ.x, self.key.pointQ.y, curve)
|
||||||
|
|
||||||
def private_bytes(self) -> bytes:
|
def private_bytes(self) -> bytes:
|
||||||
return self.key.d.to_bytes()
|
return self._to_bytes(int(self.key.d))
|
||||||
|
|
||||||
def private_sha256_digest(self) -> bytes:
|
def private_sha256_digest(self) -> bytes:
|
||||||
hash_object = SHA256.new()
|
hash_object = SHA256.new()
|
||||||
|
@ -80,7 +87,7 @@ class ECCKey:
|
||||||
return hash_object.digest()
|
return hash_object.digest()
|
||||||
|
|
||||||
def public_bytes(self) -> bytes:
|
def public_bytes(self) -> bytes:
|
||||||
return self.key.pointQ.x.to_bytes() + self.key.pointQ.y.to_bytes()
|
return self._to_bytes(int(self.key.pointQ.x)) + self._to_bytes(int(self.key.pointQ.y))
|
||||||
|
|
||||||
def public_sha256_digest(self) -> bytes:
|
def public_sha256_digest(self) -> bytes:
|
||||||
hash_object = SHA256.new()
|
hash_object = SHA256.new()
|
||||||
|
|
|
@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pyplayready"
|
name = "pyplayready"
|
||||||
version = "0.4.4"
|
version = "0.4.5"
|
||||||
description = "pyplayready CDM (Content Decryption Module) implementation in Python."
|
description = "pyplayready CDM (Content Decryption Module) implementation in Python."
|
||||||
license = "CC BY-NC-ND 4.0"
|
license = "CC BY-NC-ND 4.0"
|
||||||
authors = ["DevLARLEY, Erevoc", "DevataDev"]
|
authors = ["DevLARLEY, Erevoc", "DevataDev"]
|
||||||
|
|
Loading…
Reference in New Issue