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 | #ifndef CRYPTO_H_ |
| 18 | |
| 19 | #define CRYPTO_H_ |
| 20 | |
| 21 | #include <media/ICrypto.h> |
| 22 | #include <utils/threads.h> |
| 23 | |
| 24 | namespace android { |
| 25 | |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 26 | struct CryptoFactory; |
| 27 | struct CryptoPlugin; |
| 28 | |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 29 | struct Crypto : public BnCrypto { |
| 30 | Crypto(); |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 31 | virtual ~Crypto(); |
| 32 | |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 33 | virtual status_t initCheck() const; |
| 34 | |
| 35 | virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) const; |
| 36 | |
| 37 | virtual status_t createPlugin( |
| 38 | const uint8_t uuid[16], const void *data, size_t size); |
| 39 | |
| 40 | virtual status_t destroyPlugin(); |
| 41 | |
| 42 | virtual bool requiresSecureDecoderComponent( |
| 43 | const char *mime) const; |
| 44 | |
Edwin Wong | fa2b8f2 | 2012-07-10 20:01:13 -0700 | [diff] [blame^] | 45 | virtual ssize_t decrypt( |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 46 | bool secure, |
| 47 | const uint8_t key[16], |
| 48 | const uint8_t iv[16], |
| 49 | CryptoPlugin::Mode mode, |
| 50 | const void *srcPtr, |
| 51 | const CryptoPlugin::SubSample *subSamples, size_t numSubSamples, |
Andreas Huber | 5b8987e | 2012-04-19 12:52:20 -0700 | [diff] [blame] | 52 | void *dstPtr, |
| 53 | AString *errorDetailMsg); |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 54 | |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 55 | private: |
Andreas Huber | 1bd139a | 2012-04-03 14:19:20 -0700 | [diff] [blame] | 56 | mutable Mutex mLock; |
| 57 | |
| 58 | status_t mInitCheck; |
| 59 | void *mLibHandle; |
| 60 | CryptoFactory *mFactory; |
| 61 | CryptoPlugin *mPlugin; |
| 62 | |
| 63 | status_t init(); |
| 64 | |
Andreas Huber | ed3e3e0 | 2012-03-26 11:13:27 -0700 | [diff] [blame] | 65 | DISALLOW_EVIL_CONSTRUCTORS(Crypto); |
| 66 | }; |
| 67 | |
| 68 | } // namespace android |
| 69 | |
| 70 | #endif // CRYPTO_H_ |