Refactor and cleanup codes. No functional changes.
This commit is contained in:
105
common/python/BUILD
Normal file
105
common/python/BUILD
Normal file
@@ -0,0 +1,105 @@
|
||||
################################################################################
|
||||
# Copyright 2016 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# Description:
|
||||
# Build file for CLIF wrappers of Widevine common modules.
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load("//devtools/clif/python:clif_build_rule.bzl", "py_clif_cc")
|
||||
|
||||
py_clif_cc(
|
||||
name = "aes_cbc_util",
|
||||
srcs = ["aes_cbc_util.clif"],
|
||||
deps = [
|
||||
"//common:aes_cbc_util",
|
||||
],
|
||||
)
|
||||
|
||||
py_clif_cc(
|
||||
name = "certificate_type",
|
||||
srcs = ["certificate_type.clif"],
|
||||
deps = [
|
||||
"//common:certificate_type",
|
||||
],
|
||||
)
|
||||
|
||||
py_clif_cc(
|
||||
name = "crypto_util",
|
||||
srcs = ["crypto_util.clif"],
|
||||
deps = [
|
||||
"//common:crypto_util",
|
||||
],
|
||||
)
|
||||
|
||||
py_clif_cc(
|
||||
name = "drm_root_certificate",
|
||||
srcs = ["drm_root_certificate.clif"],
|
||||
clif_deps = [
|
||||
":certificate_type",
|
||||
],
|
||||
pyclif_deps = [
|
||||
"//protos/public:drm_certificate_pyclif",
|
||||
"//protos/public:signed_drm_certificate_pyclif",
|
||||
],
|
||||
deps = [
|
||||
"//util/task/python:status_clif",
|
||||
"//common:drm_root_certificate",
|
||||
],
|
||||
)
|
||||
|
||||
py_clif_cc(
|
||||
name = "rsa_test_keys",
|
||||
testonly = 1,
|
||||
srcs = ["rsa_test_keys.clif"],
|
||||
deps = [
|
||||
"//common:rsa_test_keys",
|
||||
],
|
||||
)
|
||||
|
||||
py_clif_cc(
|
||||
name = "rsa_key",
|
||||
srcs = ["rsa_key.clif"],
|
||||
deps = [
|
||||
"//common:rsa_key",
|
||||
],
|
||||
)
|
||||
|
||||
py_clif_cc(
|
||||
name = "drm_service_certificate",
|
||||
srcs = ["drm_service_certificate.clif"],
|
||||
clif_deps = [
|
||||
":certificate_type",
|
||||
":drm_root_certificate",
|
||||
],
|
||||
deps = [
|
||||
"//util/task/python:status_clif",
|
||||
"//common:drm_service_certificate",
|
||||
],
|
||||
)
|
||||
|
||||
py_clif_cc(
|
||||
name = "signing_key_util",
|
||||
srcs = ["signing_key_util.clif"],
|
||||
pyclif_deps = [
|
||||
"//protos/public:license_protocol_pyclif",
|
||||
],
|
||||
deps = [
|
||||
"//common:signing_key_util",
|
||||
],
|
||||
)
|
||||
|
||||
py_clif_cc(
|
||||
name = "test_drm_certificates",
|
||||
testonly = 1,
|
||||
srcs = ["test_drm_certificates.clif"],
|
||||
deps = [
|
||||
"//common:test_drm_certificates",
|
||||
],
|
||||
)
|
||||
11
common/python/aes_cbc_util.clif
Normal file
11
common/python/aes_cbc_util.clif
Normal file
@@ -0,0 +1,11 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "common/aes_cbc_util.h":
|
||||
namespace `widevine::crypto_util`:
|
||||
def `EncryptAesCbc` as Encrypt(key: bytes, iv: bytes, plaintext: bytes) -> bytes
|
||||
11
common/python/certificate_type.clif
Normal file
11
common/python/certificate_type.clif
Normal file
@@ -0,0 +1,11 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "common/certificate_type.h":
|
||||
namespace `widevine`:
|
||||
enum CertificateType
|
||||
15
common/python/crypto_util.clif
Normal file
15
common/python/crypto_util.clif
Normal file
@@ -0,0 +1,15 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "common/crypto_util.h":
|
||||
namespace `widevine::crypto_util`:
|
||||
const `kSigningKeyLabel` as SIGNING_KEY_LABEL: bytes
|
||||
const `kSigningKeySizeBits` as SIGNING_KEY_SIZE_BITS: int
|
||||
|
||||
def DeriveKey(key: bytes, label: bytes, context: bytes, size_bits: uint32_t) -> bytes
|
||||
def CreateSignatureHmacSha256(key: bytes, message: bytes) -> bytes
|
||||
23
common/python/drm_root_certificate.clif
Normal file
23
common/python/drm_root_certificate.clif
Normal file
@@ -0,0 +1,23 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "util/task/python/clif.h" import *
|
||||
from "common/python/certificate_type.h" import *
|
||||
from "protos/public/drm_certificate_pyclif.h" import *
|
||||
from "protos/public/signed_drm_certificate_pyclif.h" import *
|
||||
|
||||
from "common/drm_root_certificate.h":
|
||||
namespace `widevine`:
|
||||
class DrmRootCertificate:
|
||||
def VerifyCertificate(self,
|
||||
serialized_certificate: bytes) -> (status: Status,
|
||||
signed_certificate: SignedDrmCertificate,
|
||||
certificate: DrmCertificate)
|
||||
staticmethods from `DrmRootCertificate`:
|
||||
def CreateByType(cert_type: CertificateType) -> (new_root_cert: DrmRootCertificate,
|
||||
status: Status)
|
||||
18
common/python/drm_service_certificate.clif
Normal file
18
common/python/drm_service_certificate.clif
Normal file
@@ -0,0 +1,18 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "util/task/python/clif.h" import *
|
||||
from "common/python/drm_root_certificate.h" import *
|
||||
from "common/drm_service_certificate.h":
|
||||
namespace `widevine`:
|
||||
staticmethods from `DrmServiceCertificate`:
|
||||
def AddDrmServiceCertificate(
|
||||
root_certificate: DrmRootCertificate,
|
||||
service_certificate: bytes,
|
||||
service_private_key: bytes,
|
||||
service_private_key_passphrase: bytes) -> Status
|
||||
15
common/python/rsa_key.clif
Normal file
15
common/python/rsa_key.clif
Normal file
@@ -0,0 +1,15 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "common/rsa_key.h":
|
||||
namespace `widevine`:
|
||||
class RsaPublicKey:
|
||||
def VerifySignature(self, message: bytes, signature: bytes) -> bool
|
||||
|
||||
staticmethods from `RsaPublicKey`:
|
||||
def Create(serialized_key: bytes) -> RsaPublicKey
|
||||
20
common/python/rsa_test_keys.clif
Normal file
20
common/python/rsa_test_keys.clif
Normal file
@@ -0,0 +1,20 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "common/rsa_test_keys.h":
|
||||
namespace `widevine`:
|
||||
class RsaTestKeys:
|
||||
def private_test_key_1_3072_bits(self) -> bytes
|
||||
def public_test_key_1_3072_bits(self) -> bytes
|
||||
def private_test_key_2_2048_bits(self) -> bytes
|
||||
def public_test_key_2_2048_bits(self) -> bytes
|
||||
def private_test_key_3_2048_bits(self) -> bytes
|
||||
def public_test_key_3_2048_bits(self) -> bytes
|
||||
def private_test_key_2_carmichael_totient_2048_bits(self) -> bytes
|
||||
def private_test_key_3_carmichael_totient_2048_bits(self) -> bytes
|
||||
def private_test_key_4_carmichael_totient_2048_bits(self) -> bytes
|
||||
14
common/python/signing_key_util.clif
Normal file
14
common/python/signing_key_util.clif
Normal file
@@ -0,0 +1,14 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "protos/public/license_protocol_pyclif.h" import *
|
||||
|
||||
from "common/signing_key_util.h":
|
||||
namespace `widevine`:
|
||||
def SigningKeyMaterialSizeBits(protocol_version: ProtocolVersion) -> uint32_t
|
||||
def GetClientSigningKey(derived_key: bytes, protocol_version: ProtocolVersion) -> bytes
|
||||
15
common/python/test_drm_certificates.clif
Normal file
15
common/python/test_drm_certificates.clif
Normal file
@@ -0,0 +1,15 @@
|
||||
################################################################################
|
||||
# Copyright 2018 Google LLC.
|
||||
#
|
||||
# This software is licensed under the terms defined in the Widevine Master
|
||||
# License Agreement. For a copy of this agreement, please contact
|
||||
# widevine-licensing@google.com.
|
||||
################################################################################
|
||||
|
||||
from "common/test_drm_certificates.h":
|
||||
namespace `widevine`:
|
||||
class TestDrmCertificates:
|
||||
def test_root_certificate(self) -> bytes
|
||||
def test_intermediate_certificate(self) -> bytes
|
||||
def test_user_device_certificate(self) -> bytes
|
||||
def test_service_certificate(self) -> bytes
|
||||
Reference in New Issue
Block a user