1 /* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <media/stagefright/foundation/ABase.h> 18 #include <media/drm/DrmAPI.h> 19 #include <mediadrm/IDrmClient.h> 20 #include <mediadrm/IDrmMetricsConsumer.h> 21 22 #ifndef ANDROID_IDRM_H_ 23 24 #define ANDROID_IDRM_H_ 25 26 namespace android { 27 28 struct AString; 29 30 struct IDrm : public virtual RefBase { 31 ~IDrmIDrm32 virtual ~IDrm() {} 33 34 virtual status_t initCheck() const = 0; 35 36 virtual status_t isCryptoSchemeSupported(const uint8_t uuid[16], 37 const String8 &mimeType, 38 DrmPlugin::SecurityLevel securityLevel, 39 bool *result) = 0; 40 41 virtual status_t createPlugin(const uint8_t uuid[16], 42 const String8 &appPackageName) = 0; 43 44 virtual status_t destroyPlugin() = 0; 45 46 virtual status_t openSession(DrmPlugin::SecurityLevel securityLevel, 47 Vector<uint8_t> &sessionId) = 0; 48 49 virtual status_t closeSession(Vector<uint8_t> const &sessionId) = 0; 50 51 virtual status_t 52 getKeyRequest(Vector<uint8_t> const &sessionId, 53 Vector<uint8_t> const &initData, 54 String8 const &mimeType, DrmPlugin::KeyType keyType, 55 KeyedVector<String8, String8> const &optionalParameters, 56 Vector<uint8_t> &request, String8 &defaultUrl, 57 DrmPlugin::KeyRequestType *keyRequestType) = 0; 58 59 virtual status_t provideKeyResponse(Vector<uint8_t> const &sessionId, 60 Vector<uint8_t> const &response, 61 Vector<uint8_t> &keySetId) = 0; 62 63 virtual status_t removeKeys(Vector<uint8_t> const &keySetId) = 0; 64 65 virtual status_t restoreKeys(Vector<uint8_t> const &sessionId, 66 Vector<uint8_t> const &keySetId) = 0; 67 68 virtual status_t queryKeyStatus(Vector<uint8_t> const &sessionId, 69 KeyedVector<String8, String8> &infoMap) const = 0; 70 71 virtual status_t getProvisionRequest(String8 const &certType, 72 String8 const &certAuthority, 73 Vector<uint8_t> &request, 74 String8 &defaulUrl) = 0; 75 76 virtual status_t provideProvisionResponse(Vector<uint8_t> const &response, 77 Vector<uint8_t> &certificate, 78 Vector<uint8_t> &wrappedKey) = 0; 79 80 virtual status_t getSecureStops(List<Vector<uint8_t>> &secureStops) = 0; 81 virtual status_t getSecureStopIds(List<Vector<uint8_t>> &secureStopIds) = 0; 82 virtual status_t getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) = 0; 83 84 virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) = 0; 85 virtual status_t removeSecureStop(Vector<uint8_t> const &ssid) = 0; 86 virtual status_t removeAllSecureStops() = 0; 87 88 virtual status_t getHdcpLevels(DrmPlugin::HdcpLevel *connectedLevel, 89 DrmPlugin::HdcpLevel *maxLevel) 90 const = 0; 91 virtual status_t getNumberOfSessions(uint32_t *currentSessions, 92 uint32_t *maxSessions) const = 0; 93 virtual status_t getSecurityLevel(Vector<uint8_t> const &sessionId, 94 DrmPlugin::SecurityLevel *level) const = 0; 95 96 virtual status_t getOfflineLicenseKeySetIds(List<Vector<uint8_t>> &keySetIds) const = 0; 97 virtual status_t removeOfflineLicense(Vector<uint8_t> const &keySetId) = 0; 98 virtual status_t getOfflineLicenseState(Vector<uint8_t> const &keySetId, 99 DrmPlugin::OfflineLicenseState *licenseState) const = 0; 100 101 virtual status_t getPropertyString(String8 const &name, String8 &value) const = 0; 102 virtual status_t getPropertyByteArray(String8 const &name, 103 Vector<uint8_t> &value) const = 0; 104 virtual status_t setPropertyString(String8 const &name, 105 String8 const &value ) const = 0; 106 virtual status_t setPropertyByteArray(String8 const &name, 107 Vector<uint8_t> const &value) const = 0; 108 109 virtual status_t getMetrics(const sp<IDrmMetricsConsumer> &consumer) = 0; 110 111 virtual status_t setCipherAlgorithm(Vector<uint8_t> const &sessionId, 112 String8 const &algorithm) = 0; 113 114 virtual status_t setMacAlgorithm(Vector<uint8_t> const &sessionId, 115 String8 const &algorithm) = 0; 116 117 virtual status_t encrypt(Vector<uint8_t> const &sessionId, 118 Vector<uint8_t> const &keyId, 119 Vector<uint8_t> const &input, 120 Vector<uint8_t> const &iv, 121 Vector<uint8_t> &output) = 0; 122 123 virtual status_t decrypt(Vector<uint8_t> const &sessionId, 124 Vector<uint8_t> const &keyId, 125 Vector<uint8_t> const &input, 126 Vector<uint8_t> const &iv, 127 Vector<uint8_t> &output) = 0; 128 129 virtual status_t sign(Vector<uint8_t> const &sessionId, 130 Vector<uint8_t> const &keyId, 131 Vector<uint8_t> const &message, 132 Vector<uint8_t> &signature) = 0; 133 134 virtual status_t verify(Vector<uint8_t> const &sessionId, 135 Vector<uint8_t> const &keyId, 136 Vector<uint8_t> const &message, 137 Vector<uint8_t> const &signature, 138 bool &match) = 0; 139 140 virtual status_t signRSA(Vector<uint8_t> const &sessionId, 141 String8 const &algorithm, 142 Vector<uint8_t> const &message, 143 Vector<uint8_t> const &wrappedKey, 144 Vector<uint8_t> &signature) = 0; 145 146 virtual status_t setListener(const sp<IDrmClient>& listener) = 0; 147 148 protected: IDrmIDrm149 IDrm() {} 150 151 private: 152 DISALLOW_EVIL_CONSTRUCTORS(IDrm); 153 }; 154 155 } // namespace android 156 157 #endif // ANDROID_IDRM_H_ 158