blob: 74de2b5fb2ba50c2b9b358e736fbc369429ab5da [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
45 virtual status_t decrypt(
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,
52 void *dstPtr);
53
Andreas Hubered3e3e02012-03-26 11:13:27 -070054private:
Andreas Huber1bd139a2012-04-03 14:19:20 -070055 mutable Mutex mLock;
56
57 status_t mInitCheck;
58 void *mLibHandle;
59 CryptoFactory *mFactory;
60 CryptoPlugin *mPlugin;
61
62 status_t init();
63
Andreas Hubered3e3e02012-03-26 11:13:27 -070064 DISALLOW_EVIL_CONSTRUCTORS(Crypto);
65};
66
67} // namespace android
68
69#endif // CRYPTO_H_