Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ea40692 authored by Jeff Tinker's avatar Jeff Tinker
Browse files

Add VTS tests for drm+crypto HALs

Tests: drm vts tests are passing

related-to-bug: 32815560

Change-Id: I2b36f27fbb42eba37f3e5a26acea0e359e60b3af
parent 8074912d
Loading
Loading
Loading
Loading
+195 KiB

File added.

No diff preview for this file type.

+46 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

cc_test {
    name: "drm_hidl_test",
    srcs: [
        "drm_hal_clearkey_test.cpp",
        "drm_hal_vendor_test.cpp",
        "shared_library.cpp",
        "vendor_modules.cpp"
        ],
    shared_libs: [
        "android.hardware.drm@1.0",
        "android.hidl.allocator@1.0",
        "android.hidl.memory@1.0",
        "libbase",
        "libcutils",
        "libhidlbase",
        "libhidlmemory",
        "libhidltransport",
        "libhwbinder",
        "liblog",
        "libnativehelper",
        "libutils",
    ],
    static_libs: [
        "VtsHalHidlTargetTestBase"
    ],
    cflags: [
        "-O0",
        "-g",
    ],
}
+904 −0

File added.

Preview size limit exceeded, changes collapsed.

+213 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef DRM_HAL_VENDOR_MODULE_API_H
#define DRM_HAL_VENDOR_MODULE_API_H

#include <stdint.h>
#include <map>
#include <string>
#include <vector>

/**
 * The DRM and Crypto HALs interact with vendor-provided HAL implementations
 * that have DRM-specific capabilities. Since the VTS tests cannot contain
 * DRM-specific functionality, supporting modules are required to enable VTS
 * to validate HAL implementations in a generic way.  If the vendor-specific
 * VTS module is not provided for a given drm HAL implementation, only very
 * small subset of functionality can be verified.
 *
 * As an example, a DRM HAL implementation interacts with a DRM-specific
 * license server to obtain licenses for decrypting content.  The DRM HAL
 * implementation generates a key request message, delivers it to the server
 * and receives a key response message which is then loaded into the HAL. Once
 * the keys are loaded, the Crypto HAL decryption functionality and performance
 * and other associated APIs can be tested by the common VTS test suite.
 *
 * Vendor-specific VTS modules are shared libraries used by the DRM VTS test.
 * They provide a set of functions to support VTS testing of the DRM HAL module.
 *
 * The modules are placed in a common location on the file system. The VTS test
 * scans through all vendor-provided support libraries and runs the VTS test
 * suite on each library that is found.
 *
 * The vendor-specific module exposes an extern “C” vendorModuleFactory()
 * function that returns a DrmHalVTSVendorModule instance. DrmHalVTSVendorModule
 * instances are versioned, where each version is represented by subclass of
 * DrmHalVTSVendorModule that corresponds to the API version. For example, a
 * vendor-specific module that implements version 1 of the API would return a
 * DrmHalVTSVendorModule_V1 from the vendorModuleFactory() function.
 */

class DrmHalVTSVendorModule;

extern "C" {
/**
 * The factory method for creating DrmHalVTSVendorModule instances. The returned
 * instance will be a subclass of DrmHalVTSVendorModule that corresponds to the
 * supported API version.
 */
DrmHalVTSVendorModule* vendorModuleFactory();
};

class DrmHalVTSVendorModule {
   public:
    DrmHalVTSVendorModule() {}
    virtual ~DrmHalVTSVendorModule() {}

    /**
     * Return the vendor-specific module API version. The version is an integer
     * value with initial version 1. The API version indicates which subclass
     * version DrmHalVTSVendorModule this instance is.
     */
    virtual uint32_t getAPIVersion() = 0;

    /**
     * Return the UUID for the DRM HAL implementation. Protection System
     * Specific
     * UUID (see http://dashif.org/identifiers/protection/)
     */
    virtual std::vector<uint8_t> getUUID() = 0;

    /**
     * Return the service name for the DRM HAL implementation. If the hal is a
     * legacy
     * drm plugin, i.e. not running as a HIDL service, return the empty string.
     */
    virtual std::string getServiceName() = 0;

   private:
    DrmHalVTSVendorModule(const DrmHalVTSVendorModule&) = delete;
    void operator=(const DrmHalVTSVendorModule&) = delete;
};

/**
 * API Version 1.  This is the baseline version that supports a minimal set
 * of VTS tests.
 */
class DrmHalVTSVendorModule_V1 : public DrmHalVTSVendorModule {
   public:
    DrmHalVTSVendorModule_V1() {}
    virtual ~DrmHalVTSVendorModule_V1() {}

    virtual uint32_t getAPIVersion() { return 1; }

    /**
     * Handle a provisioning request. This function will be called if the HAL
     * module's getProvisionRequest returns a provision request.  The vendor
     * module should process the provisioning request, either by sending it
     * to a provisioning server, or generating a mock response.  The resulting
     * provisioning response is returned to the VTS test.
     *
     * @param provisioningRequest the provisioning request recieved from
     * the DRM HAL
     * @param url the default url the HAL implementation provided with the
     * provisioning request
     * @return the generated provisioning response
     */
    virtual std::vector<uint8_t> handleProvisioningRequest(
            const std::vector<uint8_t>& provisioningRequest,
            const std::string& url) = 0;

    /**
     * Content configuration specifies content-specific parameters associated
     * with a key request/response transaction. It allows the VTS test to
     * request keys and use them to perform decryption.
     */
    struct ContentConfiguration {
        /**
         * Assign a name for this configuration that will be referred to
         * in log messages.
         */
        const std::string name;

        /**
         * Server to use when requesting a key response.  This url will be
         * passed as a parameter to the vendor vts module along with the
         * key request to perform the key request transaction.
         */
        const std::string serverUrl;

        /**
         * Initialization data provided to getKeyRequest, e.g. PSSH for CENC
         * content
         */
        const std::vector<uint8_t> initData;

        /**
         *  Mime type provided to getKeyRequest, e.g. "video/mp4", or "cenc"
         */
        const std::string mimeType;

        /**
         * Optional parameters to be associated with the key request
         */
        const std::map<std::string, std::string> optionalParameters;

        /**
         * The keys that will be available once the keys are loaded
         */
        struct Key {
            /**
             * Indicate if the key content is configured to require secure
             * buffers,
             * where the output buffers are protected and cannot be accessed.
             * A vendor module should provide some content configurations where
             * isSecure is false, to allow decrypt result verification tests to
             * be
             * run.
             */
            bool isSecure;

            /**
             * A key ID identifies a key to use for decryption
             */
            const std::vector<uint8_t> keyId;

            /**
             * The key value is provided to generate expected values for
             * validating
             * decryption.  If isSecure is false, no key value is required.
             */
            const std::vector<uint8_t> keyValue;
        };
        std::vector<Key> keys;
    };

    /**
     * Return a list of content configurations that can be exercised by the
     * VTS test.
     */
    virtual std::vector<ContentConfiguration> getContentConfigurations() = 0;

    /**
     * Handle a key request. This function will be called if the HAL
     * module's getKeyRequest returns a key request.  The vendor
     * module should process the key request, either by sending it
     * to a license server, or by generating a mock response.  The resulting
     * key response is returned to the VTS test.
     *
     * @param keyRequest the key request recieved from the DRM HAL
     * @param serverUrl the url of the key server that was supplied
     * by the ContentConfiguration
     * @return the generated key response
     */
    virtual std::vector<uint8_t> handleKeyRequest(
            const std::vector<uint8_t>& keyRequest,
            const std::string& serverUrl) = 0;
};

#endif  // DRM_HAL_VENDOR_MODULE_API_H
+980 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading