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 KEYSTORE_IKEYSTORESERVICE_H 18 #define KEYSTORE_IKEYSTORESERVICE_H 19 20 #include <utils/RefBase.h> 21 #include <binder/IInterface.h> 22 #include <binder/Parcel.h> 23 24 namespace android { 25 26 /* 27 * This must be kept manually in sync with frameworks/base's IKeystoreService.java 28 */ 29 class IKeystoreService: public IInterface { 30 public: 31 enum { 32 TEST = IBinder::FIRST_CALL_TRANSACTION + 0, 33 GET = IBinder::FIRST_CALL_TRANSACTION + 1, 34 INSERT = IBinder::FIRST_CALL_TRANSACTION + 2, 35 DEL = IBinder::FIRST_CALL_TRANSACTION + 3, 36 EXIST = IBinder::FIRST_CALL_TRANSACTION + 4, 37 SAW = IBinder::FIRST_CALL_TRANSACTION + 5, 38 RESET = IBinder::FIRST_CALL_TRANSACTION + 6, 39 PASSWORD = IBinder::FIRST_CALL_TRANSACTION + 7, 40 LOCK = IBinder::FIRST_CALL_TRANSACTION + 8, 41 UNLOCK = IBinder::FIRST_CALL_TRANSACTION + 9, 42 ZERO = IBinder::FIRST_CALL_TRANSACTION + 10, 43 GENERATE = IBinder::FIRST_CALL_TRANSACTION + 11, 44 IMPORT = IBinder::FIRST_CALL_TRANSACTION + 12, 45 SIGN = IBinder::FIRST_CALL_TRANSACTION + 13, 46 VERIFY = IBinder::FIRST_CALL_TRANSACTION + 14, 47 GET_PUBKEY = IBinder::FIRST_CALL_TRANSACTION + 15, 48 DEL_KEY = IBinder::FIRST_CALL_TRANSACTION + 16, 49 GRANT = IBinder::FIRST_CALL_TRANSACTION + 17, 50 UNGRANT = IBinder::FIRST_CALL_TRANSACTION + 18, 51 GETMTIME = IBinder::FIRST_CALL_TRANSACTION + 19, 52 DUPLICATE = IBinder::FIRST_CALL_TRANSACTION + 20, 53 IS_HARDWARE_BACKED = IBinder::FIRST_CALL_TRANSACTION + 21, 54 CLEAR_UID = IBinder::FIRST_CALL_TRANSACTION + 22, 55 }; 56 57 DECLARE_META_INTERFACE(KeystoreService); 58 59 virtual int32_t test() = 0; 60 61 virtual int32_t get(const String16& name, uint8_t** item, size_t* itemLength) = 0; 62 63 virtual int32_t insert(const String16& name, const uint8_t* item, size_t itemLength, int uid, 64 int32_t flags) = 0; 65 66 virtual int32_t del(const String16& name, int uid) = 0; 67 68 virtual int32_t exist(const String16& name, int uid) = 0; 69 70 virtual int32_t saw(const String16& name, int uid, Vector<String16>* matches) = 0; 71 72 virtual int32_t reset() = 0; 73 74 virtual int32_t password(const String16& password) = 0; 75 76 virtual int32_t lock() = 0; 77 78 virtual int32_t unlock(const String16& password) = 0; 79 80 virtual int32_t zero() = 0; 81 82 virtual int32_t generate(const String16& name, int uid, int32_t flags) = 0; 83 84 virtual int32_t import(const String16& name, const uint8_t* data, size_t length, int uid, 85 int32_t flags) = 0; 86 87 virtual int32_t sign(const String16& name, const uint8_t* data, size_t length, uint8_t** out, 88 size_t* outLength) = 0; 89 90 virtual int32_t verify(const String16& name, const uint8_t* data, size_t dataLength, 91 const uint8_t* signature, size_t signatureLength) = 0; 92 93 virtual int32_t get_pubkey(const String16& name, uint8_t** pubkey, size_t* pubkeyLength) = 0; 94 95 virtual int32_t del_key(const String16& name, int uid) = 0; 96 97 virtual int32_t grant(const String16& name, int32_t granteeUid) = 0; 98 99 virtual int32_t ungrant(const String16& name, int32_t granteeUid) = 0; 100 101 virtual int64_t getmtime(const String16& name) = 0; 102 103 virtual int32_t duplicate(const String16& srcKey, int32_t srcUid, const String16& destKey, 104 int32_t destUid) = 0; 105 106 virtual int32_t is_hardware_backed() = 0; 107 108 virtual int32_t clear_uid(int64_t uid) = 0; 109 }; 110 111 // ---------------------------------------------------------------------------- 112 113 class BnKeystoreService: public BnInterface<IKeystoreService> { 114 public: 115 virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, 116 uint32_t flags = 0); 117 }; 118 119 } // namespace android 120 121 #endif 122