/* * Copyright (C) 2014 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 CLEARKEY_DRM_PLUGIN_H_ #define CLEARKEY_DRM_PLUGIN_H_ #include #include #include #include #include #include #include #include #include "SessionLibrary.h" #include "Utils.h" namespace clearkeydrm { using android::KeyedVector; using android::List; using android::status_t; using android::String8; using android::Vector; class DrmPlugin : public android::DrmPlugin { public: DrmPlugin(SessionLibrary* sessionLibrary) : mSessionLibrary(sessionLibrary) {} virtual ~DrmPlugin() {} virtual status_t openSession(Vector& sessionId); virtual status_t closeSession(const Vector& sessionId); virtual status_t getKeyRequest( const Vector& scope, const Vector& initData, const String8& initDataType, KeyType keyType, const KeyedVector& optionalParameters, Vector& request, String8& defaultUrl, DrmPlugin::KeyRequestType *keyRequestType); virtual status_t provideKeyResponse( const Vector& scope, const Vector& response, Vector& keySetId); virtual status_t removeKeys(const Vector& sessionId) { UNUSED(sessionId); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t restoreKeys( const Vector& sessionId, const Vector& keySetId) { UNUSED(sessionId); UNUSED(keySetId); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t queryKeyStatus( const Vector& sessionId, KeyedVector& infoMap) const { UNUSED(sessionId); UNUSED(infoMap); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t getProvisionRequest( const String8& cert_type, const String8& cert_authority, Vector& request, String8& defaultUrl) { UNUSED(cert_type); UNUSED(cert_authority); UNUSED(request); UNUSED(defaultUrl); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t provideProvisionResponse( const Vector& response, Vector& certificate, Vector& wrappedKey) { UNUSED(response); UNUSED(certificate); UNUSED(wrappedKey); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t getSecureStops(List >& secureStops) { UNUSED(secureStops); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t getSecureStop(Vector const &ssid, Vector &secureStop) { UNUSED(ssid); UNUSED(secureStop); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t releaseSecureStops(const Vector& ssRelease) { UNUSED(ssRelease); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t releaseAllSecureStops() { return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t getPropertyString( const String8& name, String8& value) const; virtual status_t getPropertyByteArray( const String8& name, Vector& value) const { UNUSED(name); UNUSED(value); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t setPropertyString( const String8& name, const String8& value) { UNUSED(name); UNUSED(value); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t setPropertyByteArray( const String8& name, const Vector& value) { UNUSED(name); UNUSED(value); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t setCipherAlgorithm( const Vector& sessionId, const String8& algorithm) { UNUSED(sessionId); UNUSED(algorithm); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t setMacAlgorithm( const Vector& sessionId, const String8& algorithm) { UNUSED(sessionId); UNUSED(algorithm); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t encrypt( const Vector& sessionId, const Vector& keyId, const Vector& input, const Vector& iv, Vector& output) { UNUSED(sessionId); UNUSED(keyId); UNUSED(input); UNUSED(iv); UNUSED(output); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t decrypt( const Vector& sessionId, const Vector& keyId, const Vector& input, const Vector& iv, Vector& output) { UNUSED(sessionId); UNUSED(keyId); UNUSED(input); UNUSED(iv); UNUSED(output); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t sign( const Vector& sessionId, const Vector& keyId, const Vector& message, Vector& signature) { UNUSED(sessionId); UNUSED(keyId); UNUSED(message); UNUSED(signature); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t verify( const Vector& sessionId, const Vector& keyId, const Vector& message, const Vector& signature, bool& match) { UNUSED(sessionId); UNUSED(keyId); UNUSED(message); UNUSED(signature); UNUSED(match); return android::ERROR_DRM_CANNOT_HANDLE; } virtual status_t signRSA( const Vector& sessionId, const String8& algorithm, const Vector& message, const Vector& wrappedKey, Vector& signature) { UNUSED(sessionId); UNUSED(algorithm); UNUSED(message); UNUSED(wrappedKey); UNUSED(signature); return android::ERROR_DRM_CANNOT_HANDLE; } private: DISALLOW_EVIL_CONSTRUCTORS(DrmPlugin); SessionLibrary* mSessionLibrary; }; } // namespace clearkeydrm #endif // CLEARKEY_DRM_PLUGIN_H_