Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 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> |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 19 | #include <media/hardware/CryptoAPI.h> |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 20 | |
| 21 | #ifndef ANDROID_ICRYPTO_H_ |
| 22 | |
| 23 | #define ANDROID_ICRYPTO_H_ |
| 24 | |
| 25 | namespace android { |
| 26 | |
Andreas Huber | 5b8987e | 2012-04-19 12:52:20 -0700 | [diff] [blame] | 27 | struct AString; |
Lajos Molnar | ee4e1b1 | 2015-04-17 13:46:19 -0700 | [diff] [blame] | 28 | class IMemory; |
Andreas Huber | 5b8987e | 2012-04-19 12:52:20 -0700 | [diff] [blame] | 29 | |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 30 | struct ICrypto : public IInterface { |
| 31 | DECLARE_META_INTERFACE(Crypto); |
| 32 | |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 33 | virtual status_t initCheck() const = 0; |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 34 | |
Jeff Tinker | bafb682 | 2013-03-22 15:26:39 -0700 | [diff] [blame] | 35 | virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) = 0; |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 36 | |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 37 | virtual status_t createPlugin( |
| 38 | const uint8_t uuid[16], const void *data, size_t size) = 0; |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 39 | |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 40 | virtual status_t destroyPlugin() = 0; |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 41 | |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 42 | virtual bool requiresSecureDecoderComponent( |
| 43 | const char *mime) const = 0; |
| 44 | |
Jeff Tinker | 2514d08 | 2014-11-03 13:29:35 -0800 | [diff] [blame] | 45 | virtual void notifyResolution(uint32_t width, uint32_t height) = 0; |
| 46 | |
Jeff Tinker | 1849570 | 2015-04-10 04:10:59 -0700 | [diff] [blame] | 47 | virtual status_t setMediaDrmSession(const Vector<uint8_t> &sessionId) = 0; |
| 48 | |
Jeff Tinker | 9ac86b3 | 2016-01-23 17:27:58 -0800 | [diff] [blame] | 49 | enum DestinationType { |
| 50 | kDestinationTypeVmPointer, // non-secure |
| 51 | kDestinationTypeOpaqueHandle, // secure |
| 52 | kDestinationTypeNativeHandle // secure |
| 53 | }; |
| 54 | |
Edwin Wong | fa2b8f2 | 2012-07-10 20:01:13 -0700 | [diff] [blame] | 55 | virtual ssize_t decrypt( |
Jeff Tinker | 9ac86b3 | 2016-01-23 17:27:58 -0800 | [diff] [blame] | 56 | DestinationType dstType, |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 57 | const uint8_t key[16], |
| 58 | const uint8_t iv[16], |
| 59 | CryptoPlugin::Mode mode, |
Jeff Tinker | 18cb1ec | 2015-12-18 11:55:22 -0800 | [diff] [blame] | 60 | const CryptoPlugin::Pattern &pattern, |
Jeff Tinker | c481b50 | 2015-04-06 18:21:05 -0700 | [diff] [blame] | 61 | const sp<IMemory> &sharedBuffer, size_t offset, |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 62 | const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, |
Andreas Huber | 5b8987e | 2012-04-19 12:52:20 -0700 | [diff] [blame] | 63 | void *dstPtr, |
| 64 | AString *errorDetailMsg) = 0; |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 65 | |
| 66 | private: |
| 67 | DISALLOW_EVIL_CONSTRUCTORS(ICrypto); |
| 68 | }; |
| 69 | |
| 70 | struct BnCrypto : public BnInterface<ICrypto> { |
| 71 | virtual status_t onTransact( |
| 72 | uint32_t code, const Parcel &data, Parcel *reply, |
| 73 | uint32_t flags = 0); |
Jeff Tinker | 1849570 | 2015-04-10 04:10:59 -0700 | [diff] [blame] | 74 | private: |
| 75 | void readVector(const Parcel &data, Vector<uint8_t> &vector) const; |
| 76 | void writeVector(Parcel *reply, Vector<uint8_t> const &vector) const; |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | } // namespace android |
| 80 | |
| 81 | #endif // ANDROID_ICRYPTO_H_ |