• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
26 namespace android {
27 
28 struct AString;
29 
30 struct 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,
51                       DrmPlugin::KeyRequestType *keyRequestType) = 0;
52 
53     virtual status_t provideKeyResponse(Vector<uint8_t> const &sessionId,
54                                         Vector<uint8_t> const &response,
55                                         Vector<uint8_t> &keySetId) = 0;
56 
57     virtual status_t removeKeys(Vector<uint8_t> const &keySetId) = 0;
58 
59     virtual status_t restoreKeys(Vector<uint8_t> const &sessionId,
60                                  Vector<uint8_t> const &keySetId) = 0;
61 
62     virtual status_t queryKeyStatus(Vector<uint8_t> const &sessionId,
63                                     KeyedVector<String8, String8> &infoMap) const = 0;
64 
65     virtual status_t getProvisionRequest(String8 const &certType,
66                                          String8 const &certAuthority,
67                                          Vector<uint8_t> &request,
68                                          String8 &defaulUrl) = 0;
69 
70     virtual status_t provideProvisionResponse(Vector<uint8_t> const &response,
71                                               Vector<uint8_t> &certificate,
72                                               Vector<uint8_t> &wrappedKey) = 0;
73 
74     virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) = 0;
75     virtual status_t getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) = 0;
76 
77     virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) = 0;
78     virtual status_t releaseAllSecureStops() = 0;
79 
80     virtual status_t getPropertyString(String8 const &name, String8 &value) const = 0;
81     virtual status_t getPropertyByteArray(String8 const &name,
82                                           Vector<uint8_t> &value) const = 0;
83     virtual status_t setPropertyString(String8 const &name,
84                                        String8 const &value ) const = 0;
85     virtual status_t setPropertyByteArray(String8 const &name,
86                                           Vector<uint8_t> const &value) const = 0;
87 
88     virtual status_t setCipherAlgorithm(Vector<uint8_t> const &sessionId,
89                                         String8 const &algorithm) = 0;
90 
91     virtual status_t setMacAlgorithm(Vector<uint8_t> const &sessionId,
92                                      String8 const &algorithm) = 0;
93 
94     virtual status_t encrypt(Vector<uint8_t> const &sessionId,
95                              Vector<uint8_t> const &keyId,
96                              Vector<uint8_t> const &input,
97                              Vector<uint8_t> const &iv,
98                              Vector<uint8_t> &output) = 0;
99 
100     virtual status_t decrypt(Vector<uint8_t> const &sessionId,
101                              Vector<uint8_t> const &keyId,
102                              Vector<uint8_t> const &input,
103                              Vector<uint8_t> const &iv,
104                              Vector<uint8_t> &output) = 0;
105 
106     virtual status_t sign(Vector<uint8_t> const &sessionId,
107                           Vector<uint8_t> const &keyId,
108                           Vector<uint8_t> const &message,
109                           Vector<uint8_t> &signature) = 0;
110 
111     virtual status_t verify(Vector<uint8_t> const &sessionId,
112                             Vector<uint8_t> const &keyId,
113                             Vector<uint8_t> const &message,
114                             Vector<uint8_t> const &signature,
115                             bool &match) = 0;
116 
117     virtual status_t signRSA(Vector<uint8_t> const &sessionId,
118                              String8 const &algorithm,
119                              Vector<uint8_t> const &message,
120                              Vector<uint8_t> const &wrappedKey,
121                              Vector<uint8_t> &signature) = 0;
122 
123     virtual status_t setListener(const sp<IDrmClient>& listener) = 0;
124 
125 private:
126     DISALLOW_EVIL_CONSTRUCTORS(IDrm);
127 };
128 
129 struct BnDrm : public BnInterface<IDrm> {
130     virtual status_t onTransact(
131             uint32_t code, const Parcel &data, Parcel *reply,
132             uint32_t flags = 0);
133 private:
134     void readVector(const Parcel &data, Vector<uint8_t> &vector) const;
135     void writeVector(Parcel *reply, Vector<uint8_t> const &vector) const;
136 };
137 
138 }  // namespace android
139 
140 #endif // ANDROID_IDRM_H_
141