Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 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 | //#define LOG_NDEBUG 0 |
| 18 | #define LOG_TAG "IDrm" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <binder/Parcel.h> |
| 22 | #include <media/IDrm.h> |
| 23 | #include <media/stagefright/MediaErrors.h> |
| 24 | #include <media/stagefright/foundation/ADebug.h> |
| 25 | #include <media/stagefright/foundation/AString.h> |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | enum { |
| 30 | INIT_CHECK = IBinder::FIRST_CALL_TRANSACTION, |
| 31 | IS_CRYPTO_SUPPORTED, |
| 32 | CREATE_PLUGIN, |
| 33 | DESTROY_PLUGIN, |
| 34 | OPEN_SESSION, |
| 35 | CLOSE_SESSION, |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 36 | GET_KEY_REQUEST, |
| 37 | PROVIDE_KEY_RESPONSE, |
| 38 | REMOVE_KEYS, |
| 39 | RESTORE_KEYS, |
| 40 | QUERY_KEY_STATUS, |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 41 | GET_PROVISION_REQUEST, |
| 42 | PROVIDE_PROVISION_RESPONSE, |
| 43 | GET_SECURE_STOPS, |
| 44 | RELEASE_SECURE_STOPS, |
| 45 | GET_PROPERTY_STRING, |
| 46 | GET_PROPERTY_BYTE_ARRAY, |
| 47 | SET_PROPERTY_STRING, |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 48 | SET_PROPERTY_BYTE_ARRAY, |
| 49 | SET_CIPHER_ALGORITHM, |
| 50 | SET_MAC_ALGORITHM, |
| 51 | ENCRYPT, |
| 52 | DECRYPT, |
| 53 | SIGN, |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 54 | SIGN_RSA, |
Jeff Tinker | c0d5f1f | 2013-04-02 13:08:05 -0700 | [diff] [blame] | 55 | VERIFY, |
Jeff Tinker | 68b1555 | 2014-04-30 10:19:03 -0700 | [diff] [blame] | 56 | SET_LISTENER, |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 57 | UNPROVISION_DEVICE, |
| 58 | GET_SECURE_STOP, |
| 59 | RELEASE_ALL_SECURE_STOPS |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | struct BpDrm : public BpInterface<IDrm> { |
| 63 | BpDrm(const sp<IBinder> &impl) |
| 64 | : BpInterface<IDrm>(impl) { |
| 65 | } |
| 66 | |
| 67 | virtual status_t initCheck() const { |
| 68 | Parcel data, reply; |
| 69 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 70 | remote()->transact(INIT_CHECK, data, &reply); |
| 71 | |
| 72 | return reply.readInt32(); |
| 73 | } |
| 74 | |
Jeff Tinker | 9cf69e0 | 2013-08-21 11:59:23 -0700 | [diff] [blame] | 75 | virtual bool isCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 76 | Parcel data, reply; |
| 77 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 78 | data.write(uuid, 16); |
Jeff Tinker | 9cf69e0 | 2013-08-21 11:59:23 -0700 | [diff] [blame] | 79 | data.writeString8(mimeType); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 80 | remote()->transact(IS_CRYPTO_SUPPORTED, data, &reply); |
| 81 | |
| 82 | return reply.readInt32() != 0; |
| 83 | } |
| 84 | |
| 85 | virtual status_t createPlugin(const uint8_t uuid[16]) { |
| 86 | Parcel data, reply; |
| 87 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 88 | data.write(uuid, 16); |
| 89 | |
| 90 | remote()->transact(CREATE_PLUGIN, data, &reply); |
| 91 | |
| 92 | return reply.readInt32(); |
| 93 | } |
| 94 | |
| 95 | virtual status_t destroyPlugin() { |
| 96 | Parcel data, reply; |
| 97 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 98 | remote()->transact(DESTROY_PLUGIN, data, &reply); |
| 99 | |
| 100 | return reply.readInt32(); |
| 101 | } |
| 102 | |
| 103 | virtual status_t openSession(Vector<uint8_t> &sessionId) { |
| 104 | Parcel data, reply; |
| 105 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 106 | |
| 107 | remote()->transact(OPEN_SESSION, data, &reply); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 108 | readVector(reply, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 109 | |
| 110 | return reply.readInt32(); |
| 111 | } |
| 112 | |
| 113 | virtual status_t closeSession(Vector<uint8_t> const &sessionId) { |
| 114 | Parcel data, reply; |
| 115 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 116 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 117 | writeVector(data, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 118 | remote()->transact(CLOSE_SESSION, data, &reply); |
| 119 | |
| 120 | return reply.readInt32(); |
| 121 | } |
| 122 | |
| 123 | virtual status_t |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 124 | getKeyRequest(Vector<uint8_t> const &sessionId, |
| 125 | Vector<uint8_t> const &initData, |
| 126 | String8 const &mimeType, DrmPlugin::KeyType keyType, |
| 127 | KeyedVector<String8, String8> const &optionalParameters, |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame^] | 128 | Vector<uint8_t> &request, String8 &defaultUrl, |
| 129 | DrmPlugin::KeyRequestType *keyRequestType) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 130 | Parcel data, reply; |
| 131 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 132 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 133 | writeVector(data, sessionId); |
| 134 | writeVector(data, initData); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 135 | data.writeString8(mimeType); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 136 | data.writeInt32((uint32_t)keyType); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 137 | |
| 138 | data.writeInt32(optionalParameters.size()); |
| 139 | for (size_t i = 0; i < optionalParameters.size(); ++i) { |
| 140 | data.writeString8(optionalParameters.keyAt(i)); |
| 141 | data.writeString8(optionalParameters.valueAt(i)); |
| 142 | } |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 143 | remote()->transact(GET_KEY_REQUEST, data, &reply); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 144 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 145 | readVector(reply, request); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 146 | defaultUrl = reply.readString8(); |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame^] | 147 | *keyRequestType = static_cast<DrmPlugin::KeyRequestType>(reply.readInt32()); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 148 | |
| 149 | return reply.readInt32(); |
| 150 | } |
| 151 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 152 | virtual status_t provideKeyResponse(Vector<uint8_t> const &sessionId, |
| 153 | Vector<uint8_t> const &response, |
| 154 | Vector<uint8_t> &keySetId) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 155 | Parcel data, reply; |
| 156 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 157 | writeVector(data, sessionId); |
| 158 | writeVector(data, response); |
| 159 | remote()->transact(PROVIDE_KEY_RESPONSE, data, &reply); |
| 160 | readVector(reply, keySetId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 161 | |
| 162 | return reply.readInt32(); |
| 163 | } |
| 164 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 165 | virtual status_t removeKeys(Vector<uint8_t> const &keySetId) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 166 | Parcel data, reply; |
| 167 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 168 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 169 | writeVector(data, keySetId); |
| 170 | remote()->transact(REMOVE_KEYS, data, &reply); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 171 | |
| 172 | return reply.readInt32(); |
| 173 | } |
| 174 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 175 | virtual status_t restoreKeys(Vector<uint8_t> const &sessionId, |
| 176 | Vector<uint8_t> const &keySetId) { |
| 177 | Parcel data, reply; |
| 178 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 179 | |
| 180 | writeVector(data, sessionId); |
| 181 | writeVector(data, keySetId); |
| 182 | remote()->transact(RESTORE_KEYS, data, &reply); |
| 183 | |
| 184 | return reply.readInt32(); |
| 185 | } |
| 186 | |
| 187 | virtual status_t queryKeyStatus(Vector<uint8_t> const &sessionId, |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 188 | KeyedVector<String8, String8> &infoMap) const { |
| 189 | Parcel data, reply; |
| 190 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 191 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 192 | writeVector(data, sessionId); |
| 193 | remote()->transact(QUERY_KEY_STATUS, data, &reply); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 194 | |
| 195 | infoMap.clear(); |
| 196 | size_t count = reply.readInt32(); |
| 197 | for (size_t i = 0; i < count; i++) { |
| 198 | String8 key = reply.readString8(); |
| 199 | String8 value = reply.readString8(); |
| 200 | infoMap.add(key, value); |
| 201 | } |
| 202 | return reply.readInt32(); |
| 203 | } |
| 204 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 205 | virtual status_t getProvisionRequest(String8 const &certType, |
| 206 | String8 const &certAuthority, |
| 207 | Vector<uint8_t> &request, |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 208 | String8 &defaultUrl) { |
| 209 | Parcel data, reply; |
| 210 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 211 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 212 | data.writeString8(certType); |
| 213 | data.writeString8(certAuthority); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 214 | remote()->transact(GET_PROVISION_REQUEST, data, &reply); |
| 215 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 216 | readVector(reply, request); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 217 | defaultUrl = reply.readString8(); |
| 218 | |
| 219 | return reply.readInt32(); |
| 220 | } |
| 221 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 222 | virtual status_t provideProvisionResponse(Vector<uint8_t> const &response, |
| 223 | Vector<uint8_t> &certificate, |
| 224 | Vector<uint8_t> &wrappedKey) { |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 225 | Parcel data, reply; |
| 226 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 227 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 228 | writeVector(data, response); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 229 | remote()->transact(PROVIDE_PROVISION_RESPONSE, data, &reply); |
| 230 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 231 | readVector(reply, certificate); |
| 232 | readVector(reply, wrappedKey); |
| 233 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 234 | return reply.readInt32(); |
| 235 | } |
| 236 | |
Jeff Tinker | 68b1555 | 2014-04-30 10:19:03 -0700 | [diff] [blame] | 237 | virtual status_t unprovisionDevice() { |
| 238 | Parcel data, reply; |
| 239 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 240 | |
| 241 | remote()->transact(UNPROVISION_DEVICE, data, &reply); |
| 242 | |
| 243 | return reply.readInt32(); |
| 244 | } |
| 245 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 246 | virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops) { |
| 247 | Parcel data, reply; |
| 248 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 249 | |
| 250 | remote()->transact(GET_SECURE_STOPS, data, &reply); |
| 251 | |
| 252 | secureStops.clear(); |
| 253 | uint32_t count = reply.readInt32(); |
| 254 | for (size_t i = 0; i < count; i++) { |
| 255 | Vector<uint8_t> secureStop; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 256 | readVector(reply, secureStop); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 257 | secureStops.push_back(secureStop); |
| 258 | } |
| 259 | return reply.readInt32(); |
| 260 | } |
| 261 | |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 262 | virtual status_t getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop) { |
| 263 | Parcel data, reply; |
| 264 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 265 | |
| 266 | writeVector(data, ssid); |
| 267 | remote()->transact(GET_SECURE_STOP, data, &reply); |
| 268 | |
| 269 | readVector(reply, secureStop); |
| 270 | return reply.readInt32(); |
| 271 | } |
| 272 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 273 | virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease) { |
| 274 | Parcel data, reply; |
| 275 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 276 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 277 | writeVector(data, ssRelease); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 278 | remote()->transact(RELEASE_SECURE_STOPS, data, &reply); |
| 279 | |
| 280 | return reply.readInt32(); |
| 281 | } |
| 282 | |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 283 | virtual status_t releaseAllSecureStops() { |
| 284 | Parcel data, reply; |
| 285 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 286 | |
| 287 | remote()->transact(RELEASE_ALL_SECURE_STOPS, data, &reply); |
| 288 | |
| 289 | return reply.readInt32(); |
| 290 | } |
| 291 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 292 | virtual status_t getPropertyString(String8 const &name, String8 &value) const { |
| 293 | Parcel data, reply; |
| 294 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 295 | |
| 296 | data.writeString8(name); |
| 297 | remote()->transact(GET_PROPERTY_STRING, data, &reply); |
| 298 | |
| 299 | value = reply.readString8(); |
| 300 | return reply.readInt32(); |
| 301 | } |
| 302 | |
| 303 | virtual status_t getPropertyByteArray(String8 const &name, Vector<uint8_t> &value) const { |
| 304 | Parcel data, reply; |
| 305 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 306 | |
| 307 | data.writeString8(name); |
| 308 | remote()->transact(GET_PROPERTY_BYTE_ARRAY, data, &reply); |
| 309 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 310 | readVector(reply, value); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 311 | return reply.readInt32(); |
| 312 | } |
| 313 | |
| 314 | virtual status_t setPropertyString(String8 const &name, String8 const &value) const { |
| 315 | Parcel data, reply; |
| 316 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 317 | |
| 318 | data.writeString8(name); |
| 319 | data.writeString8(value); |
| 320 | remote()->transact(SET_PROPERTY_STRING, data, &reply); |
| 321 | |
| 322 | return reply.readInt32(); |
| 323 | } |
| 324 | |
| 325 | virtual status_t setPropertyByteArray(String8 const &name, |
| 326 | Vector<uint8_t> const &value) const { |
| 327 | Parcel data, reply; |
| 328 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 329 | |
| 330 | data.writeString8(name); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 331 | writeVector(data, value); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 332 | remote()->transact(SET_PROPERTY_BYTE_ARRAY, data, &reply); |
| 333 | |
| 334 | return reply.readInt32(); |
| 335 | } |
| 336 | |
| 337 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 338 | virtual status_t setCipherAlgorithm(Vector<uint8_t> const &sessionId, |
| 339 | String8 const &algorithm) { |
| 340 | Parcel data, reply; |
| 341 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 342 | |
| 343 | writeVector(data, sessionId); |
| 344 | data.writeString8(algorithm); |
| 345 | remote()->transact(SET_CIPHER_ALGORITHM, data, &reply); |
| 346 | return reply.readInt32(); |
| 347 | } |
| 348 | |
| 349 | virtual status_t setMacAlgorithm(Vector<uint8_t> const &sessionId, |
| 350 | String8 const &algorithm) { |
| 351 | Parcel data, reply; |
| 352 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 353 | |
| 354 | writeVector(data, sessionId); |
| 355 | data.writeString8(algorithm); |
| 356 | remote()->transact(SET_MAC_ALGORITHM, data, &reply); |
| 357 | return reply.readInt32(); |
| 358 | } |
| 359 | |
| 360 | virtual status_t encrypt(Vector<uint8_t> const &sessionId, |
| 361 | Vector<uint8_t> const &keyId, |
| 362 | Vector<uint8_t> const &input, |
| 363 | Vector<uint8_t> const &iv, |
| 364 | Vector<uint8_t> &output) { |
| 365 | Parcel data, reply; |
| 366 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 367 | |
| 368 | writeVector(data, sessionId); |
| 369 | writeVector(data, keyId); |
| 370 | writeVector(data, input); |
| 371 | writeVector(data, iv); |
| 372 | |
| 373 | remote()->transact(ENCRYPT, data, &reply); |
| 374 | readVector(reply, output); |
| 375 | |
| 376 | return reply.readInt32(); |
| 377 | } |
| 378 | |
| 379 | virtual status_t decrypt(Vector<uint8_t> const &sessionId, |
| 380 | Vector<uint8_t> const &keyId, |
| 381 | Vector<uint8_t> const &input, |
| 382 | Vector<uint8_t> const &iv, |
| 383 | Vector<uint8_t> &output) { |
| 384 | Parcel data, reply; |
| 385 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 386 | |
| 387 | writeVector(data, sessionId); |
| 388 | writeVector(data, keyId); |
| 389 | writeVector(data, input); |
| 390 | writeVector(data, iv); |
| 391 | |
| 392 | remote()->transact(DECRYPT, data, &reply); |
| 393 | readVector(reply, output); |
| 394 | |
| 395 | return reply.readInt32(); |
| 396 | } |
| 397 | |
| 398 | virtual status_t sign(Vector<uint8_t> const &sessionId, |
| 399 | Vector<uint8_t> const &keyId, |
| 400 | Vector<uint8_t> const &message, |
| 401 | Vector<uint8_t> &signature) { |
| 402 | Parcel data, reply; |
| 403 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 404 | |
| 405 | writeVector(data, sessionId); |
| 406 | writeVector(data, keyId); |
| 407 | writeVector(data, message); |
| 408 | |
| 409 | remote()->transact(SIGN, data, &reply); |
| 410 | readVector(reply, signature); |
| 411 | |
| 412 | return reply.readInt32(); |
| 413 | } |
| 414 | |
| 415 | virtual status_t verify(Vector<uint8_t> const &sessionId, |
| 416 | Vector<uint8_t> const &keyId, |
| 417 | Vector<uint8_t> const &message, |
| 418 | Vector<uint8_t> const &signature, |
| 419 | bool &match) { |
| 420 | Parcel data, reply; |
| 421 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 422 | |
| 423 | writeVector(data, sessionId); |
| 424 | writeVector(data, keyId); |
| 425 | writeVector(data, message); |
| 426 | writeVector(data, signature); |
| 427 | |
| 428 | remote()->transact(VERIFY, data, &reply); |
| 429 | match = (bool)reply.readInt32(); |
| 430 | return reply.readInt32(); |
| 431 | } |
| 432 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 433 | virtual status_t signRSA(Vector<uint8_t> const &sessionId, |
| 434 | String8 const &algorithm, |
| 435 | Vector<uint8_t> const &message, |
| 436 | Vector<uint8_t> const &wrappedKey, |
| 437 | Vector<uint8_t> &signature) { |
| 438 | Parcel data, reply; |
| 439 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
| 440 | |
| 441 | writeVector(data, sessionId); |
| 442 | data.writeString8(algorithm); |
| 443 | writeVector(data, message); |
| 444 | writeVector(data, wrappedKey); |
| 445 | |
| 446 | remote()->transact(SIGN_RSA, data, &reply); |
| 447 | readVector(reply, signature); |
| 448 | |
| 449 | return reply.readInt32(); |
| 450 | } |
| 451 | |
Jeff Tinker | c0d5f1f | 2013-04-02 13:08:05 -0700 | [diff] [blame] | 452 | virtual status_t setListener(const sp<IDrmClient>& listener) { |
| 453 | Parcel data, reply; |
| 454 | data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); |
Marco Nelissen | 06b4606 | 2014-11-14 07:58:25 -0800 | [diff] [blame] | 455 | data.writeStrongBinder(IInterface::asBinder(listener)); |
Jeff Tinker | c0d5f1f | 2013-04-02 13:08:05 -0700 | [diff] [blame] | 456 | remote()->transact(SET_LISTENER, data, &reply); |
| 457 | return reply.readInt32(); |
| 458 | } |
| 459 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 460 | private: |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 461 | void readVector(Parcel &reply, Vector<uint8_t> &vector) const { |
| 462 | uint32_t size = reply.readInt32(); |
| 463 | vector.insertAt((size_t)0, size); |
| 464 | reply.read(vector.editArray(), size); |
| 465 | } |
| 466 | |
| 467 | void writeVector(Parcel &data, Vector<uint8_t> const &vector) const { |
| 468 | data.writeInt32(vector.size()); |
| 469 | data.write(vector.array(), vector.size()); |
| 470 | } |
| 471 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 472 | DISALLOW_EVIL_CONSTRUCTORS(BpDrm); |
| 473 | }; |
| 474 | |
| 475 | IMPLEMENT_META_INTERFACE(Drm, "android.drm.IDrm"); |
| 476 | |
| 477 | //////////////////////////////////////////////////////////////////////////////// |
| 478 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 479 | void BnDrm::readVector(const Parcel &data, Vector<uint8_t> &vector) const { |
| 480 | uint32_t size = data.readInt32(); |
| 481 | vector.insertAt((size_t)0, size); |
| 482 | data.read(vector.editArray(), size); |
| 483 | } |
| 484 | |
| 485 | void BnDrm::writeVector(Parcel *reply, Vector<uint8_t> const &vector) const { |
| 486 | reply->writeInt32(vector.size()); |
| 487 | reply->write(vector.array(), vector.size()); |
| 488 | } |
| 489 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 490 | status_t BnDrm::onTransact( |
| 491 | uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { |
| 492 | switch (code) { |
| 493 | case INIT_CHECK: |
| 494 | { |
| 495 | CHECK_INTERFACE(IDrm, data, reply); |
| 496 | reply->writeInt32(initCheck()); |
| 497 | return OK; |
| 498 | } |
| 499 | |
| 500 | case IS_CRYPTO_SUPPORTED: |
| 501 | { |
| 502 | CHECK_INTERFACE(IDrm, data, reply); |
| 503 | uint8_t uuid[16]; |
| 504 | data.read(uuid, sizeof(uuid)); |
Jeff Tinker | 9cf69e0 | 2013-08-21 11:59:23 -0700 | [diff] [blame] | 505 | String8 mimeType = data.readString8(); |
| 506 | reply->writeInt32(isCryptoSchemeSupported(uuid, mimeType)); |
| 507 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 508 | return OK; |
| 509 | } |
| 510 | |
| 511 | case CREATE_PLUGIN: |
| 512 | { |
| 513 | CHECK_INTERFACE(IDrm, data, reply); |
| 514 | uint8_t uuid[16]; |
| 515 | data.read(uuid, sizeof(uuid)); |
| 516 | reply->writeInt32(createPlugin(uuid)); |
| 517 | return OK; |
| 518 | } |
| 519 | |
| 520 | case DESTROY_PLUGIN: |
| 521 | { |
| 522 | CHECK_INTERFACE(IDrm, data, reply); |
| 523 | reply->writeInt32(destroyPlugin()); |
| 524 | return OK; |
| 525 | } |
| 526 | |
| 527 | case OPEN_SESSION: |
| 528 | { |
| 529 | CHECK_INTERFACE(IDrm, data, reply); |
| 530 | Vector<uint8_t> sessionId; |
| 531 | status_t result = openSession(sessionId); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 532 | writeVector(reply, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 533 | reply->writeInt32(result); |
| 534 | return OK; |
| 535 | } |
| 536 | |
| 537 | case CLOSE_SESSION: |
| 538 | { |
| 539 | CHECK_INTERFACE(IDrm, data, reply); |
| 540 | Vector<uint8_t> sessionId; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 541 | readVector(data, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 542 | reply->writeInt32(closeSession(sessionId)); |
| 543 | return OK; |
| 544 | } |
| 545 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 546 | case GET_KEY_REQUEST: |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 547 | { |
| 548 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 549 | Vector<uint8_t> sessionId, initData; |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 550 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 551 | readVector(data, sessionId); |
| 552 | readVector(data, initData); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 553 | String8 mimeType = data.readString8(); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 554 | DrmPlugin::KeyType keyType = (DrmPlugin::KeyType)data.readInt32(); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 555 | |
| 556 | KeyedVector<String8, String8> optionalParameters; |
| 557 | uint32_t count = data.readInt32(); |
| 558 | for (size_t i = 0; i < count; ++i) { |
| 559 | String8 key, value; |
| 560 | key = data.readString8(); |
| 561 | value = data.readString8(); |
| 562 | optionalParameters.add(key, value); |
| 563 | } |
| 564 | |
| 565 | Vector<uint8_t> request; |
| 566 | String8 defaultUrl; |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame^] | 567 | DrmPlugin::KeyRequestType keyRequestType; |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 568 | |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame^] | 569 | status_t result = getKeyRequest(sessionId, initData, mimeType, |
| 570 | keyType, optionalParameters, request, defaultUrl, |
| 571 | &keyRequestType); |
| 572 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 573 | writeVector(reply, request); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 574 | reply->writeString8(defaultUrl); |
Jeff Tinker | d072c90 | 2015-03-16 13:39:29 -0700 | [diff] [blame^] | 575 | reply->writeInt32(static_cast<int32_t>(keyRequestType)); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 576 | reply->writeInt32(result); |
| 577 | return OK; |
| 578 | } |
| 579 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 580 | case PROVIDE_KEY_RESPONSE: |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 581 | { |
| 582 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 583 | Vector<uint8_t> sessionId, response, keySetId; |
| 584 | readVector(data, sessionId); |
| 585 | readVector(data, response); |
| 586 | uint32_t result = provideKeyResponse(sessionId, response, keySetId); |
| 587 | writeVector(reply, keySetId); |
| 588 | reply->writeInt32(result); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 589 | return OK; |
| 590 | } |
| 591 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 592 | case REMOVE_KEYS: |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 593 | { |
| 594 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 595 | Vector<uint8_t> keySetId; |
| 596 | readVector(data, keySetId); |
| 597 | reply->writeInt32(removeKeys(keySetId)); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 598 | return OK; |
| 599 | } |
| 600 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 601 | case RESTORE_KEYS: |
| 602 | { |
| 603 | CHECK_INTERFACE(IDrm, data, reply); |
| 604 | Vector<uint8_t> sessionId, keySetId; |
| 605 | readVector(data, sessionId); |
| 606 | readVector(data, keySetId); |
| 607 | reply->writeInt32(restoreKeys(sessionId, keySetId)); |
| 608 | return OK; |
| 609 | } |
| 610 | |
| 611 | case QUERY_KEY_STATUS: |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 612 | { |
| 613 | CHECK_INTERFACE(IDrm, data, reply); |
| 614 | Vector<uint8_t> sessionId; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 615 | readVector(data, sessionId); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 616 | KeyedVector<String8, String8> infoMap; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 617 | status_t result = queryKeyStatus(sessionId, infoMap); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 618 | size_t count = infoMap.size(); |
| 619 | reply->writeInt32(count); |
| 620 | for (size_t i = 0; i < count; ++i) { |
| 621 | reply->writeString8(infoMap.keyAt(i)); |
| 622 | reply->writeString8(infoMap.valueAt(i)); |
| 623 | } |
| 624 | reply->writeInt32(result); |
| 625 | return OK; |
| 626 | } |
| 627 | |
| 628 | case GET_PROVISION_REQUEST: |
| 629 | { |
| 630 | CHECK_INTERFACE(IDrm, data, reply); |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 631 | String8 certType = data.readString8(); |
| 632 | String8 certAuthority = data.readString8(); |
| 633 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 634 | Vector<uint8_t> request; |
| 635 | String8 defaultUrl; |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 636 | status_t result = getProvisionRequest(certType, certAuthority, |
| 637 | request, defaultUrl); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 638 | writeVector(reply, request); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 639 | reply->writeString8(defaultUrl); |
| 640 | reply->writeInt32(result); |
| 641 | return OK; |
| 642 | } |
| 643 | |
| 644 | case PROVIDE_PROVISION_RESPONSE: |
| 645 | { |
| 646 | CHECK_INTERFACE(IDrm, data, reply); |
| 647 | Vector<uint8_t> response; |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 648 | Vector<uint8_t> certificate; |
| 649 | Vector<uint8_t> wrappedKey; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 650 | readVector(data, response); |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 651 | status_t result = provideProvisionResponse(response, certificate, wrappedKey); |
| 652 | writeVector(reply, certificate); |
| 653 | writeVector(reply, wrappedKey); |
| 654 | reply->writeInt32(result); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 655 | return OK; |
| 656 | } |
| 657 | |
Jeff Tinker | 68b1555 | 2014-04-30 10:19:03 -0700 | [diff] [blame] | 658 | case UNPROVISION_DEVICE: |
| 659 | { |
| 660 | CHECK_INTERFACE(IDrm, data, reply); |
| 661 | status_t result = unprovisionDevice(); |
| 662 | reply->writeInt32(result); |
| 663 | return OK; |
| 664 | } |
| 665 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 666 | case GET_SECURE_STOPS: |
| 667 | { |
| 668 | CHECK_INTERFACE(IDrm, data, reply); |
| 669 | List<Vector<uint8_t> > secureStops; |
| 670 | status_t result = getSecureStops(secureStops); |
| 671 | size_t count = secureStops.size(); |
| 672 | reply->writeInt32(count); |
| 673 | List<Vector<uint8_t> >::iterator iter = secureStops.begin(); |
| 674 | while(iter != secureStops.end()) { |
| 675 | size_t size = iter->size(); |
| 676 | reply->writeInt32(size); |
| 677 | reply->write(iter->array(), iter->size()); |
Jeff Tinker | 423e33c | 2013-04-08 15:23:17 -0700 | [diff] [blame] | 678 | iter++; |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 679 | } |
| 680 | reply->writeInt32(result); |
| 681 | return OK; |
| 682 | } |
| 683 | |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 684 | case GET_SECURE_STOP: |
| 685 | { |
| 686 | CHECK_INTERFACE(IDrm, data, reply); |
| 687 | Vector<uint8_t> ssid, secureStop; |
| 688 | readVector(data, ssid); |
| 689 | status_t result = getSecureStop(ssid, secureStop); |
| 690 | writeVector(reply, secureStop); |
| 691 | reply->writeInt32(result); |
| 692 | return OK; |
| 693 | } |
| 694 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 695 | case RELEASE_SECURE_STOPS: |
| 696 | { |
| 697 | CHECK_INTERFACE(IDrm, data, reply); |
| 698 | Vector<uint8_t> ssRelease; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 699 | readVector(data, ssRelease); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 700 | reply->writeInt32(releaseSecureStops(ssRelease)); |
| 701 | return OK; |
| 702 | } |
| 703 | |
Jeff Tinker | 3c1285e | 2014-10-31 00:55:16 -0700 | [diff] [blame] | 704 | case RELEASE_ALL_SECURE_STOPS: |
| 705 | { |
| 706 | CHECK_INTERFACE(IDrm, data, reply); |
| 707 | reply->writeInt32(releaseAllSecureStops()); |
| 708 | return OK; |
| 709 | } |
| 710 | |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 711 | case GET_PROPERTY_STRING: |
| 712 | { |
| 713 | CHECK_INTERFACE(IDrm, data, reply); |
| 714 | String8 name = data.readString8(); |
| 715 | String8 value; |
| 716 | status_t result = getPropertyString(name, value); |
| 717 | reply->writeString8(value); |
| 718 | reply->writeInt32(result); |
| 719 | return OK; |
| 720 | } |
| 721 | |
| 722 | case GET_PROPERTY_BYTE_ARRAY: |
| 723 | { |
| 724 | CHECK_INTERFACE(IDrm, data, reply); |
| 725 | String8 name = data.readString8(); |
| 726 | Vector<uint8_t> value; |
| 727 | status_t result = getPropertyByteArray(name, value); |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 728 | writeVector(reply, value); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 729 | reply->writeInt32(result); |
| 730 | return OK; |
| 731 | } |
| 732 | |
| 733 | case SET_PROPERTY_STRING: |
| 734 | { |
| 735 | CHECK_INTERFACE(IDrm, data, reply); |
| 736 | String8 name = data.readString8(); |
| 737 | String8 value = data.readString8(); |
| 738 | reply->writeInt32(setPropertyString(name, value)); |
| 739 | return OK; |
| 740 | } |
| 741 | |
| 742 | case SET_PROPERTY_BYTE_ARRAY: |
| 743 | { |
| 744 | CHECK_INTERFACE(IDrm, data, reply); |
| 745 | String8 name = data.readString8(); |
| 746 | Vector<uint8_t> value; |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 747 | readVector(data, value); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 748 | reply->writeInt32(setPropertyByteArray(name, value)); |
| 749 | return OK; |
| 750 | } |
| 751 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 752 | case SET_CIPHER_ALGORITHM: |
| 753 | { |
| 754 | CHECK_INTERFACE(IDrm, data, reply); |
| 755 | Vector<uint8_t> sessionId; |
| 756 | readVector(data, sessionId); |
| 757 | String8 algorithm = data.readString8(); |
| 758 | reply->writeInt32(setCipherAlgorithm(sessionId, algorithm)); |
| 759 | return OK; |
| 760 | } |
| 761 | |
| 762 | case SET_MAC_ALGORITHM: |
| 763 | { |
| 764 | CHECK_INTERFACE(IDrm, data, reply); |
| 765 | Vector<uint8_t> sessionId; |
| 766 | readVector(data, sessionId); |
| 767 | String8 algorithm = data.readString8(); |
| 768 | reply->writeInt32(setMacAlgorithm(sessionId, algorithm)); |
| 769 | return OK; |
| 770 | } |
| 771 | |
| 772 | case ENCRYPT: |
| 773 | { |
| 774 | CHECK_INTERFACE(IDrm, data, reply); |
| 775 | Vector<uint8_t> sessionId, keyId, input, iv, output; |
| 776 | readVector(data, sessionId); |
| 777 | readVector(data, keyId); |
| 778 | readVector(data, input); |
| 779 | readVector(data, iv); |
| 780 | uint32_t result = encrypt(sessionId, keyId, input, iv, output); |
| 781 | writeVector(reply, output); |
| 782 | reply->writeInt32(result); |
| 783 | return OK; |
| 784 | } |
| 785 | |
| 786 | case DECRYPT: |
| 787 | { |
| 788 | CHECK_INTERFACE(IDrm, data, reply); |
| 789 | Vector<uint8_t> sessionId, keyId, input, iv, output; |
| 790 | readVector(data, sessionId); |
| 791 | readVector(data, keyId); |
| 792 | readVector(data, input); |
| 793 | readVector(data, iv); |
| 794 | uint32_t result = decrypt(sessionId, keyId, input, iv, output); |
| 795 | writeVector(reply, output); |
| 796 | reply->writeInt32(result); |
| 797 | return OK; |
| 798 | } |
| 799 | |
| 800 | case SIGN: |
| 801 | { |
| 802 | CHECK_INTERFACE(IDrm, data, reply); |
| 803 | Vector<uint8_t> sessionId, keyId, message, signature; |
| 804 | readVector(data, sessionId); |
| 805 | readVector(data, keyId); |
| 806 | readVector(data, message); |
| 807 | uint32_t result = sign(sessionId, keyId, message, signature); |
| 808 | writeVector(reply, signature); |
| 809 | reply->writeInt32(result); |
| 810 | return OK; |
| 811 | } |
| 812 | |
| 813 | case VERIFY: |
| 814 | { |
| 815 | CHECK_INTERFACE(IDrm, data, reply); |
| 816 | Vector<uint8_t> sessionId, keyId, message, signature; |
| 817 | readVector(data, sessionId); |
| 818 | readVector(data, keyId); |
| 819 | readVector(data, message); |
| 820 | readVector(data, signature); |
| 821 | bool match; |
| 822 | uint32_t result = verify(sessionId, keyId, message, signature, match); |
| 823 | reply->writeInt32(match); |
| 824 | reply->writeInt32(result); |
| 825 | return OK; |
| 826 | } |
| 827 | |
Jeff Tinker | 68d9d71 | 2014-03-04 13:21:31 -0800 | [diff] [blame] | 828 | case SIGN_RSA: |
| 829 | { |
| 830 | CHECK_INTERFACE(IDrm, data, reply); |
| 831 | Vector<uint8_t> sessionId, message, wrappedKey, signature; |
| 832 | readVector(data, sessionId); |
| 833 | String8 algorithm = data.readString8(); |
| 834 | readVector(data, message); |
| 835 | readVector(data, wrappedKey); |
| 836 | uint32_t result = signRSA(sessionId, algorithm, message, wrappedKey, signature); |
| 837 | writeVector(reply, signature); |
| 838 | reply->writeInt32(result); |
| 839 | return OK; |
| 840 | } |
| 841 | |
Jeff Tinker | c0d5f1f | 2013-04-02 13:08:05 -0700 | [diff] [blame] | 842 | case SET_LISTENER: { |
| 843 | CHECK_INTERFACE(IDrm, data, reply); |
| 844 | sp<IDrmClient> listener = |
| 845 | interface_cast<IDrmClient>(data.readStrongBinder()); |
| 846 | reply->writeInt32(setListener(listener)); |
| 847 | return NO_ERROR; |
| 848 | } break; |
| 849 | |
Jeff Tinker | 4c63a23 | 2013-03-30 16:19:44 -0700 | [diff] [blame] | 850 | default: |
| 851 | return BBinder::onTransact(code, data, reply, flags); |
Jeff Tinker | 441a78d | 2013-02-08 10:18:35 -0800 | [diff] [blame] | 852 | } |
| 853 | } |
| 854 | |
| 855 | } // namespace android |