IDrm.h revision 9cf69e0fc110f17c28e988ed0f9bf91abfaf710d
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 <binder/IInterface.h> 18#include <media/stagefright/foundation/ABase.h> 19#include <media/drm/DrmAPI.h> 20#include <media/IDrmClient.h> 21 22#ifndef ANDROID_IDRM_H_ 23 24#define ANDROID_IDRM_H_ 25 26namespace android { 27 28struct AString; 29 30struct IDrm : public IInterface { 31 DECLARE_META_INTERFACE(Drm); 32 33 virtual status_t initCheck() const = 0; 34 35 virtual bool isCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType) = 0; 36 37 virtual status_t createPlugin(const uint8_t uuid[16]) = 0; 38 39 virtual status_t destroyPlugin() = 0; 40 41 virtual status_t openSession(Vector<uint8_t> &sessionId) = 0; 42 43 virtual status_t closeSession(Vector<uint8_t> const &sessionId) = 0; 44 45 virtual status_t 46 getKeyRequest(Vector<uint8_t> const &sessionId, 47 Vector<uint8_t> const &initData, 48 String8 const &mimeType, DrmPlugin::KeyType keyType, 49 KeyedVector<String8, String8> const &optionalParameters, 50 Vector<uint8_t> &request, String8 &defaultUrl) = 0; 51 52 virtual status_t provideKeyResponse(Vector<uint8_t> const &sessionId, 53 Vector<uint8_t> const &response, 54 Vector<uint8_t> &keySetId) = 0; 55 56 virtual status_t removeKeys(Vector<uint8_t> const &keySetId) = 0; 57 58 virtual status_t restoreKeys(Vector<uint8_t> const &sessionId, 59 Vector<uint8_t> const &keySetId) = 0; 60 61 virtual status_t queryKeyStatus(Vector<uint8_t> const &sessionId, 62 KeyedVector<String8, String8> &infoMap) const = 0; 63 64 virtual status_t getProvisionRequest(Vector<uint8_t> &request, 65 String8 &defaulUrl) = 0; 66 67 virtual status_t provideProvisionResponse(Vector<uint8_t> const &response) = 0; 68 69 virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) = 0; 70 71 virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) = 0; 72 73 virtual status_t getPropertyString(String8 const &name, String8 &value) const = 0; 74 virtual status_t getPropertyByteArray(String8 const &name, 75 Vector<uint8_t> &value) const = 0; 76 virtual status_t setPropertyString(String8 const &name, 77 String8 const &value ) const = 0; 78 virtual status_t setPropertyByteArray(String8 const &name, 79 Vector<uint8_t> const &value) const = 0; 80 81 virtual status_t setCipherAlgorithm(Vector<uint8_t> const &sessionId, 82 String8 const &algorithm) = 0; 83 84 virtual status_t setMacAlgorithm(Vector<uint8_t> const &sessionId, 85 String8 const &algorithm) = 0; 86 87 virtual status_t encrypt(Vector<uint8_t> const &sessionId, 88 Vector<uint8_t> const &keyId, 89 Vector<uint8_t> const &input, 90 Vector<uint8_t> const &iv, 91 Vector<uint8_t> &output) = 0; 92 93 virtual status_t decrypt(Vector<uint8_t> const &sessionId, 94 Vector<uint8_t> const &keyId, 95 Vector<uint8_t> const &input, 96 Vector<uint8_t> const &iv, 97 Vector<uint8_t> &output) = 0; 98 99 virtual status_t sign(Vector<uint8_t> const &sessionId, 100 Vector<uint8_t> const &keyId, 101 Vector<uint8_t> const &message, 102 Vector<uint8_t> &signature) = 0; 103 104 virtual status_t verify(Vector<uint8_t> const &sessionId, 105 Vector<uint8_t> const &keyId, 106 Vector<uint8_t> const &message, 107 Vector<uint8_t> const &signature, 108 bool &match) = 0; 109 110 virtual status_t setListener(const sp<IDrmClient>& listener) = 0; 111 112private: 113 DISALLOW_EVIL_CONSTRUCTORS(IDrm); 114}; 115 116struct BnDrm : public BnInterface<IDrm> { 117 virtual status_t onTransact( 118 uint32_t code, const Parcel &data, Parcel *reply, 119 uint32_t flags = 0); 120private: 121 void readVector(const Parcel &data, Vector<uint8_t> &vector) const; 122 void writeVector(Parcel *reply, Vector<uint8_t> const &vector) const; 123}; 124 125} // namespace android 126 127#endif // ANDROID_IDRM_H_ 128 129