ICrypto.h revision 2514d080c8a54ff603a45d7e336de668fe7329db
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>
19#include <media/hardware/CryptoAPI.h>
20
21#ifndef ANDROID_ICRYPTO_H_
22
23#define ANDROID_ICRYPTO_H_
24
25namespace android {
26
27struct AString;
28
29struct ICrypto : public IInterface {
30    DECLARE_META_INTERFACE(Crypto);
31
32    virtual status_t initCheck() const = 0;
33
34    virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) = 0;
35
36    virtual status_t createPlugin(
37            const uint8_t uuid[16], const void *data, size_t size) = 0;
38
39    virtual status_t destroyPlugin() = 0;
40
41    virtual bool requiresSecureDecoderComponent(
42            const char *mime) const = 0;
43
44    virtual void notifyResolution(uint32_t width, uint32_t height) = 0;
45
46    virtual ssize_t decrypt(
47            bool secure,
48            const uint8_t key[16],
49            const uint8_t iv[16],
50            CryptoPlugin::Mode mode,
51            const void *srcPtr,
52            const CryptoPlugin::SubSample *subSamples, size_t numSubSamples,
53            void *dstPtr,
54            AString *errorDetailMsg) = 0;
55
56private:
57    DISALLOW_EVIL_CONSTRUCTORS(ICrypto);
58};
59
60struct BnCrypto : public BnInterface<ICrypto> {
61    virtual status_t onTransact(
62            uint32_t code, const Parcel &data, Parcel *reply,
63            uint32_t flags = 0);
64};
65
66}  // namespace android
67
68#endif // ANDROID_ICRYPTO_H_
69