blob: d066774fd8b1cec09fe102ff7b44f2509846bc21 [file] [log] [blame]
Andreas Hubered3e3e02012-03-26 11:13:27 -07001/*
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
24namespace android {
25
Andreas Huber1bd139a2012-04-03 14:19:20 -070026struct CryptoFactory;
27struct CryptoPlugin;
28
Andreas Hubered3e3e02012-03-26 11:13:27 -070029struct Crypto : public BnCrypto {
30 Crypto();
Andreas Hubered3e3e02012-03-26 11:13:27 -070031 virtual ~Crypto();
32
Andreas Huber1bd139a2012-04-03 14:19:20 -070033 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 Wongfa2b8f22012-07-10 20:01:13 -070045 virtual ssize_t decrypt(
Andreas Huber1bd139a2012-04-03 14:19:20 -070046 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 Huber5b8987e2012-04-19 12:52:20 -070052 void *dstPtr,
53 AString *errorDetailMsg);
Andreas Huber1bd139a2012-04-03 14:19:20 -070054
Andreas Hubered3e3e02012-03-26 11:13:27 -070055private:
Andreas Huber1bd139a2012-04-03 14:19:20 -070056 mutable Mutex mLock;
57
58 status_t mInitCheck;
59 void *mLibHandle;
60 CryptoFactory *mFactory;
61 CryptoPlugin *mPlugin;
62
63 status_t init();
64
Andreas Hubered3e3e02012-03-26 11:13:27 -070065 DISALLOW_EVIL_CONSTRUCTORS(Crypto);
66};
67
68} // namespace android
69
70#endif // CRYPTO_H_