------------- Fix SHA hashing to remove race condition. This change fixes the implementation by passing in the digest buffer. ------------- The input to ProvisioningEngine::NewProvisioningSession should be pkcs8 private key instead of pkcs1 private key ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=151273394 Change-Id: Ibcdff7757b2ac2878ee8b1b88365083964bfa10a
102 lines
3.0 KiB
Python
102 lines
3.0 KiB
Python
################################################################################
|
|
# Copyright 2017 Google Inc.
|
|
#
|
|
# 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.
|
|
################################################################################
|
|
|
|
"""Class that provides test data for Provisioning SDK testing."""
|
|
|
|
import os
|
|
|
|
import pywrapcertificate_type
|
|
|
|
_TEST_CERT_DATA_FOLDER = os.path.join('example', 'example_data')
|
|
_DEV_CERT_DATA_FOLDER = os.path.join('example', 'dev_cert_example_data')
|
|
|
|
|
|
class TestDataProvider(object):
|
|
"""For for Test Data."""
|
|
|
|
def __init__(self, cert_type):
|
|
"""Initializes the TestData for Provisioning SDK tests."""
|
|
assert (cert_type in (
|
|
pywrapcertificate_type.kCertDevelopment,
|
|
pywrapcertificate_type.kCertTesting))
|
|
self._cert_type = cert_type
|
|
|
|
def _GetTestData(self, filename):
|
|
"""Helps read test data files such as certs and keys for SDK testing."""
|
|
current_dir = os.path.realpath(os.path.dirname(__file__))
|
|
if self._cert_type == pywrapcertificate_type.kCertDevelopment:
|
|
subfolder_path = _DEV_CERT_DATA_FOLDER
|
|
elif self._cert_type == pywrapcertificate_type.kCertTesting:
|
|
subfolder_path = _TEST_CERT_DATA_FOLDER
|
|
while not os.path.isdir(os.path.join(current_dir, subfolder_path)):
|
|
current_dir = os.path.dirname(current_dir)
|
|
filename = os.path.join(current_dir, subfolder_path, filename)
|
|
with open(filename, 'rb') as data_file:
|
|
data = data_file.read()
|
|
return data
|
|
|
|
@property
|
|
def service_drm_cert(self):
|
|
return self._GetTestData('service.cert')
|
|
|
|
@property
|
|
def service_public_key(self):
|
|
return self._GetTestData('service.public')
|
|
|
|
@property
|
|
def service_private_key(self):
|
|
return self._GetTestData('service.encrypted.private')
|
|
|
|
@property
|
|
def service_private_key_passphrase(self):
|
|
return self._GetTestData('service.passphrase')
|
|
|
|
@property
|
|
def provisioner_drm_cert(self):
|
|
return self._GetTestData('provisioner.cert')
|
|
|
|
@property
|
|
def provisioner_private_key(self):
|
|
return self._GetTestData('provisioner.encrypted.private')
|
|
|
|
@property
|
|
def provisioner_private_key_passphrase(self):
|
|
return self._GetTestData('provisioner.passphrase')
|
|
|
|
@property
|
|
def provisioner_spoid_secret(self):
|
|
return self._GetTestData('provisioner.spoid_secret')
|
|
|
|
@property
|
|
def ca_public_key(self):
|
|
return self._GetTestData('intermediate.public')
|
|
|
|
@property
|
|
def ca_private_key(self):
|
|
return self._GetTestData('intermediate.encrypted.private')
|
|
|
|
@property
|
|
def ca_private_key_passphrase(self):
|
|
return self._GetTestData('intermediate.passphrase')
|
|
|
|
@property
|
|
def device_public_key(self):
|
|
return self._GetTestData('user.public')
|
|
|
|
@property
|
|
def device_private_key(self):
|
|
return self._GetTestData('user.private')
|
|
|
|
@property
|
|
def message(self):
|
|
return self._GetTestData('message')
|
|
|
|
@property
|
|
def certificate_list(self):
|
|
return self._GetTestData('certificate_list')
|